iphone - 如何分配 AVPlayer 播放/暂停按钮 iOS?

标签 iphone ios ipad avplayer

几天前我问过这个问题,但没有人回答我,我找不到解决方案。

所以我想再次问同样的问题,如果你知道答案请回答我。

我想将图片中的这些按钮分配给我的 avplayer 播放/暂停按钮。

enter image description here

注意:我的应用程序图标出现在正在播放的栏中而不是音乐图标,我的应用程序在后台运行正常。

请帮忙。

最佳答案

要允许传送远程控制事件,您必须调用 beginReceivingRemoteControlEvents UIApplication 的方法。

然后您通过实现 remoteControlReceivedWithEvent: 来响应远程控制事件像这样的方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [[UIApplication sharedApplication] becomeFirstResponder];


    return YES;
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event
{
    switch (event.subtype)
    {
        case UIEventSubtypeRemoteControlPlay:
            // play code
            ...
            break;
        case UIEventSubtypeRemoteControlTogglePlayPause:
            // toggle code
            ...    
            break;
        case UIEventSubtypeRemoteControlNextTrack:
            // next code
            ...
            break;
        default:
            break;
    }
}

关于iphone - 如何分配 AVPlayer 播放/暂停按钮 iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14960747/

相关文章:

iphone - InterfaceBuilder - UIViewController 子类未被识别为子类

iphone - 如何减小 UIFont 大小并显示大句子一行 UILabel iPhone?

android - 在 iOS 和 Android 上的 AS3 中找到我的 air 应用程序版本

iphone - 登录注销 View Controller

iphone - 核心数据轻量级迁移 : Can't find or automatically infer mapping model for migration

ios - 为不同的 UITableViewCell 类创建单个 .xib

ios - 如何使用 cocoa pod 的 Storyboard引用?

iphone - Monotouch.Dialog - 设置后退按钮

javascript - 即使在 ractive 解析之后,网站也不会仅在 ipad ios9.3.5 中加载

iphone - XCode 在第二页安装调试应用程序?