• 如何在后台播放音乐


    - (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


  • 相关阅读:
    asy for
    asy html !
    lib
    git clone 指定 version tag
    git tag
    git clone <url>--depth 、 git clone <url> --recursive
    xelatex CLI
    rsync
    curl options
    [转自]C语言offset_of宏和container_of宏
  • 原文地址:https://www.cnblogs.com/qq78292959/p/2076928.html
Copyright © 2020-2023  润新知