ios 个应用的自定义音频控制

Custom audio control for ios apps

我们正在 IOS 上使用 Swift 创建一个需要使用自定义音频控件的应用程序:播放按钮、停止按钮、当前 time/pos 指示器、持续时间和甚至可能是用于播放应用程序内置的 1 个音频文件的搜索栏。我的朋友在这个项目上很努力,但到目前为止还没有找到解决方案。是否可以使用 mediaplayer 或另一个 api 更简单,可能类似于 android 应用程序的 exoplayer。

谢谢。

在我看来,我认为使用 AVFoundation 可能是最简单的,因为它内置于 swift 中,您只需要做 import AVFoundation 并且您可能想要创建一个 AVAudioPlayer 来收听音乐。 API 也很简单。如果您需要任何入门帮助,我在 Mashable 上找到了这篇文章,其中展示了如何播放音频以及如何使用自定义播放和暂停按钮来控制它。 https://medium.com/yay-its-erica/creating-a-music-player-app-in-swift-3-53809471f663. Also I found on Apple's documentation how to get the current time of the audio playing https://developer.apple.com/documentation/avfoundation/avaudioplayer/1387297-currenttime。希望我能帮到您,如果您还有其他问题,请随时提问!