zoukankan      html  css  js  c++  java
  • 如何在后台播放音乐

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

    audioSession = [AVAudioSession sharedInstance];

    NSError *err = nil;

    UIDevice *device = [UIDevice currentDevice];

        BOOL backgroundSupported = NO;

    if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {

    backgroundSupported = device.multitaskingSupported;

    }

    if (backgroundSupported) {

    NSLog(@"Supports multitasking");

    [audioSession setCategory :AVAudioSessionCategoryPlayback error:&err];

    }

    else {

    NSLog(@"Does not support multitasking");

    [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];

    }

    if(err){

    NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);

    }

    [audioSession setActive:YES error:&err];

    err = nil;

    if(err){

    NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);

    }

        // Override point for customization after application launch.

        [self.window makeKeyAndVisible];


    return YES;

    }

     

    官方文档:

    http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html


  • 相关阅读:
    core 3.7.1 报错 SDK.InvalidRegionId : Can not find endpoint to access.
    定时30分钟清除缓存,重置
    文件的分割与合并
    mybatis <collection property="GoodsList" column="orderId" javaType="java.util.List" ofType="ui.model.vo.GoodsList" select="selectOrderDetail" fetchType="eager"/>
    hashMap 源码注释分析(二)
    hashMap 源码注释分析(一)
    ElasticSearch 入门
    Java 三高 ,高并发 ,高可用 。高性能
    使用MyBatis返回map对象,字段值为null时不返回或返回null,目标返回自定义的默认值...
    idea html 中文乱码,控制台中文乱码,工程文件中文乱码
  • 原文地址:https://www.cnblogs.com/qq78292959/p/2076928.html
Copyright © 2011-2022 走看看