简体   繁体   中英

How to display “This video is playing on …” when Airplaying with AVPlayer?

Does anyone know how to display a "This video is playing on ..." screen when Airplaying with AVPlayer ? Example from the VEVO iPhone app:

VEVO应用程序将视频播放到Apple TV

By default, AVPlayer just displays a black screen. Do I have to implement such a screen myself or is a default component available for this?

May be this is a little late, but I figured out or at least a workaround for this. I added a UILabel, and to obtain the name of the selected device by using doing something like this:

CFDictionaryRef description;
UInt32 dataSize = sizeof(description);
if (AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &dataSize, &description) == kAudioSessionNoError)  {
    CFArrayRef outputs = CFDictionaryGetValue(description, kAudioSession_AudioRouteKey_Outputs);
    if (outputs) {
        if(CFArrayGetCount(outputs) > 0) {
            CFDictionaryRef currentOutput = CFArrayGetValueAtIndex(outputs, 0);
            NSLog(@"%@", currentOutput);
            CFStringRef outputType = CFDictionaryGetValue(currentOutput, kAudioSession_AudioRouteKey_Type);
            if (CFStringCompare(outputType, kAudioSessionOutputRoute_AirPlay, 0) == kCFCompareEqualTo) {
                NSDictionary *desc = (__bridge NSDictionary *)(currentOutput);
                NSLog(@"%@", [desc objectForKey:@"RouteDetailedDescription_Name"]);
            }
        }
    }
}

There should be a better way, but this is a good approach. Also, AudioSessionGetProperty is deprecated, and this can be done using AVAudioSession.

Hope this helps

That image is displayed by default when using the MPMoviePlayerController. Since AVPlayer doesn't have an UI, that image is also not available if MPMoviePlayerController is not used.

Also, I don't think that the image is available as a component outside of the MPMoviePlayerController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM