2

有谁知道如何在 Airplaying 时显示“此视频正在播放...”屏幕AVPlayer?来自 VEVO iPhone 应用程序的示例:

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

默认情况下,AVPlayer只显示黑屏。我是否必须自己实现这样的屏幕,或者是否有可用的默认组件?

4

2 回答 2

1

可能这有点晚了,但我想出了或者至少是一个解决方法。我添加了一个 UILabel,并通过执行以下操作来获取所选设备的名称:

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"]);
            }
        }
    }
}

应该有更好的方法,但这是一个很好的方法。此外,不推荐使用 AudioSessionGetProperty,这可以使用 AVAudioSession 来完成。

希望这可以帮助

于 2013-09-24T23:08:53.080 回答
0

使用 MPMoviePlayerController 时默认显示该图像。由于 AVPlayer 没有 UI,因此如果不使用 MPMoviePlayerController,则该图像也不可用。

另外,我认为图像不能作为 MPMoviePlayerController 之外的组件使用。

于 2014-12-05T12:00:00.867 回答