문제

I have multiple videos being played from my iphone app and when I use airplay to view it, it shows up fine. I want to be able to turn off the iphone in order to not waste battery etc.

How can I use airplay with video while the iphone is in sleep-mode/locked?

도움이 되었습니까?

해결책

After toying with a thousand other things I found what I needed to do.

All I needed to do was make two adjustments:

  1. Add this to the AppDelegate.m in the application: didFinishLaunchingWithOptions: method:

    NSError *error = nil;
    
    BOOL success = [[AVAudioSession sharedInstance]
                setCategory: AVAudioSessionCategoryPlayback
                error: &error];
    
    if (success == false) { /* handle error */ }
    
  2. Add the following to your info.plist after you drag it into a text editor like Sublime:

    <key>UIBackgroundModes</key>
    <array>
            <string>audio</string>
    </array>
    

If you setup your video correctly you will be able to listen to the audio from the video while using other apps and while the screen is in sleep mode and use airplay while iphone is in sleep mode.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top