MPMoviePlayerController playing audio stream in the background

后端 未结 2 1244
不思量自难忘°
不思量自难忘° 2021-01-03 03:55

I am running into trouble with playing an audio stream when the application enters background.

I use the code to start the stream:

NSURL *mediaURL =          


        
2条回答
  •  [愿得一人]
    2021-01-03 04:56

    I didn't tried it myself but this looks promising: iOS Multitasking: Background Audio

    Once the project has been created go to APP-Info.plist and add UIBackgroundModes as a new row. It should then create the array.

    Open the array and to the right of Item 0 set it to audio.

    EDIT

    Is your AVAudioSession set up properly?

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
    [audioSession setActive:YES error:nil];
    

提交回复
热议问题