• [转]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;
            }
        }
    }
  • 相关阅读:
    WebClient设置Expect: 100-continue
    ActiveX控件注册不起作用的解决办法
    RadioButtonFor值为false.默认选中的问题
    Ueditor插入script标签
    Ueditor上传图片到本地改造到上传图片到七牛云存储
    让网页显示ajax的查询数据
    今天升级win10.vs调试程序各种崩溃
    visual assist x vs2012不智能提示
    几道 javascript 题,你全对了吗?
    Node.js中使用TCP套接字编程
  • 原文地址:https://www.cnblogs.com/cklxmu/p/2378932.html
Copyright © 2020-2023  润新知