13

我有以下 MPNowPlayingInfoCenter 字典

@{MPMediaItemPropertyAlbumTitle: @"First Title",
                                MPMediaItemPropertyArtwork: [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"Album-Cover.jpg"]],
                                MPMediaItemPropertyPlaybackDuration:[NSNumber numberWithDouble:self.storyAudioPlayer.duration],
                                MPNowPlayingInfoPropertyElapsedPlaybackTime:[NSNumber numberWithDouble:self.storyAudioPlayer.currentTime],
                                MPNowPlayingInfoPropertyPlaybackRate:@1.0
                                }

其他一切工作正常,但我无法使用滑块寻找歌曲。如图所示。我缺少什么参数?

锁屏截图

4

3 回答 3

3

你不能。您可以向 Apple 提交错误报告,以便他们有一天会实施。

编辑:现在可以从 iOS 9 开始执行此操作

于 2014-01-03T17:59:10.427 回答
3

斯威夫特 5

你可以用MPRemoteCommandCenter.changePlaybackPositionCommand.

用于更改媒体项中播放位置的命令对象。

let commandCenter = MPRemoteCommandCenter.shared()
    commandCenter.changePlaybackPositionCommand.isEnabled = true
    commandCenter.changePlaybackPositionCommand.addTarget { event in
        if let event = event as? MPChangePlaybackPositionCommandEvent {
            let time = CMTime(seconds: event.positionTime, preferredTimescale: 1000000)
            self.avplayer.seekTo(time)
        }
        return .success
    }
于 2019-06-20T08:24:58.247 回答
3

您可以借助 MPRemoteCommandCenter 和 changePlaybackPositionCommand 在 iOS 9.1 及更高版本上执行此操作。

看我的回答

于 2016-10-16T21:55:38.983 回答