- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我尝试用 Swift 制作我自己的音乐播放器。我需要跳转到我的 MPMediaItemCollection 的特定歌曲/索引并开始播放它,但我只能找到像 skipToNextItem() 和 skipToPreviousItem() 这样的方法。除了循环之外,还有其他方法可以做到这一点吗?
let player = MPMusicPlayerController.systemMusicPlayer()
player.setQueueWithItemCollection(mediaCollection)
player.play()
最佳答案
根据 the documentation ,我们使用 nowPlayingItem
属性。
To specify that playback should begin at a particular media item in the playback queue, set this property to that item while the music player is stopped or paused.
因此,听起来您应该停止或暂停播放器,设置 nowPlayingItem
,然后再次调用 play
。
player.nowPlayingItem = mediaCollection.items[selectedIndex]
player.play()
关于ios - 在 Swift 的 MPMediaItemCollection 的特定索引处播放歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31292774/
所以,我已经在 NSUserDefaults 中存储了一些mpmediaitemcollection。我已经在 UICollectionView 上检索到它。 这是我的代码: func collect
我正在尝试将我的旧播放器从 Objective-C 重写为 Swift(凭内存),但遇到了麻烦。我有很多这样的歌曲 let query = MPMediaQuery.songsQuery() quer
我正在制作一个允许用户使用 MPMusicPlayerController 制作播放列表和编辑播放列表的应用程序。我已经能够制作播放列表然后检索它以便播放。我不知道的是如何将 playlist(MPM
我的目标是获取 iPod 库中播放列表的封面图片。我做了类似的事情 playlistMediaItemCollections = MPMediaQuery.playlistsQuery().coll
希望玩MPMediaItemcollection使用 MPMusicPlayerController . musicPlayer = [MPMusicPlayerController applicat
为什么以下结果会产生一个充满“艺术家”的表格 View ,而不是一个充满实际艺术家姓名的表格 View ?我哪里做错了?如何从收藏中提取艺术家值(value)?感谢所有帮助... var tableD
我的应用程序中有一个播放列表屏幕,用户可以在其中选择播放列表中的任何歌曲,应用程序将从该歌曲开始播放。 我使用以下代码: - (void)tableView:(UITableView *)tableV
我在 MPMediaItemsCollection 中设置 N 个项目,其中一些项目不是唯一的(该集合代表一个播放列表,其中同一首歌曲可能出现两次)。 - (void)setLastSongWithI
我正在开发一个与 iOS 上的 iPod Music 应用程序集成的应用程序。它显示不同的音乐分组(即 MPMediaItemCollections),并允许用户使用 [MPMusicPlayerCo
如何使用 NSUserDefaults 持久化 MPMediaItemCollection 对象? MPMediaItemCollection 对象是从 iPod 中选择的一首歌曲。 我已经为此苦苦挣
我正在制作一个应用程序,用户可以在其中的设置选项卡中选择一首歌曲,并根据需要在不同的 View 中播放。我想要它,以便在用户关闭应用程序并再次打开它时可以存储该项目。 我已经设法允许用户选择歌曲并将其
我尝试用 Swift 制作我自己的音乐播放器。我需要跳转到我的 MPMediaItemCollection 的特定歌曲/索引并开始播放它,但我只能找到像 skipToNextItem() 和 skip
我使用这段代码来选择轨道 //open the media picker, allow the inport of any type of audio MPMediaPickerController
我想在我的应用程序中使用 avplayer 播放设备歌曲。在 NSLog 中,我得到数组值 ===> “18023427656013653237”, "15946441828903552798", "
事情是这样的,我有一个 MPMediaItemCollection,其中包含用户选择的项目(来自库)。我使用 mediaPicker 来做到这一点。现在,我需要从这些项目中获取 URL,以便我可以在
在 iPhone SDK 中使用应用内音频时,可以允许用户从其 iPod 库中选择列表并创建应用内本地播放列表。如果我想坚持这个选择,很容易序列化数据并写入文件,然后恢复。 然而,只是像这样的 Van
我正在使用 xcode 中的苹果 addMusic 示例应用程序,因为我希望能够添加类似的功能(在应用程序的后台播放用户选择的音乐队列)。 它会做一件恼人的事情,当用户在内置 MediaPicker
我是一名优秀的程序员,十分优秀!