【问题标题】:Use Built-in Audio Controls with cocoalibspotify on iOS在 iOS 上使用带有 cocoalibspotify 的内置音频控件
【发布时间】:2013-06-18 06:55:13
【问题描述】:

如何让我的 iOS 版 cocoalibspotify 应用响应内置的暂停/播放和下一个/上一个控件?我没有看到这方面的文档。

【问题讨论】:

    标签: ios cocoalibspotify-2.0


    【解决方案1】:

    在主视图控制器中,应用需要订阅远程控制事件。

    - (void)viewDidLoad {
        // ...
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
        // ...
    }
    

    远程控制按钮按下将在您的视图控制器上触发remoteControlReceivedEvent:。该事件可以如下处理。

    - (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
        if (receivedEvent.type == UIEventTypeRemoteControl) {
            switch (receivedEvent.subtype) {                
                case UIEventSubtypeRemoteControlPause:
                    // Handle pause
                    break;
                case UIEventSubtypeRemoteControlPlay:
                    // Handle play
                    break;
                case UIEventSubtypeRemoteControlPreviousTrack:
                    // Handle Previous
                    break;
                case UIEventSubtypeRemoteControlNextTrack:
                    // Handle Next
                    break;
                default:
                    break;
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-07-16
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-22
      • 1970-01-01
      • 2020-02-18
      相关资源
      最近更新 更多