zoukankan      html  css  js  c++  java
  • [转]iPhone 多媒体遥控(iPhone Remote Control of Multimedia)后台音乐播放

    原地址:http://geagle001.blog.163.com/blog/static/188226090201173110404762/

    用户要实现后台的播放的控制,需要按下面的方法来实现。这样实现的效果就是和iPod后台播放的效果一样。在后台播放音乐的时候可以通过任务栏来控制。任务栏通过双击Home键来调出,调出后向左滑到最前门可以看到这个控制按钮。如下图:

    iPhone 多媒体遥控(iPhone Remote Control of Multimedia) - geaglew - 工作随记
     
     
     
     1.在View显示的时候接收remote-control事件
    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
        [self becomeFirstResponder];
    }

    2.在View消失或者我们不需要响应控制的时候取消接收remote-control 事件

    - (void)viewWillDisappear:(BOOL)animated {
        [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
        [self resignFirstResponder];
        [super viewWillDisappear:animated];
    }
                                 

    3 重新下面的函数

    - (BOOL) canBecomeFirstResponder  {
        return YES;  
    }

     

    4 接收遥控事件

    - (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
     
        if (receivedEvent.type == UIEventTypeRemoteControl) {
     
            switch (receivedEvent.subtype) {
     
                case UIEventSubtypeRemoteControlTogglePlayPause:
                    [self playOrStop: nil];
                    break;
     
                case UIEventSubtypeRemoteControlPreviousTrack:
                    [self previousTrack: nil];
                    break;
     
                case UIEventSubtypeRemoteControlNextTrack:
                    [self nextTrack: nil];
                    break;
     
                default:
                    break;
            }
        }
    }
  • 相关阅读:
    Maven初步踩坑
    Sql Server Snapshot和mysql MVCC
    改良程序的11个技巧
    Lucene基础学习笔记
    关于JQuery
    关于JQuery
    JS性能细节学习初步总结
    hibernate.cfg配置mysql方言
    Java 从静态代理到动态代理
    基础复习 关于事务
  • 原文地址:https://www.cnblogs.com/cklxmu/p/2378932.html
Copyright © 2011-2022 走看看