本文介绍了App上Apple TV上的AirPlay元数据(AVPlayer-MPVolumeView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有我的应用程序通过AVPlayer成功流式传输了MP3.我实现了MPVolumeView来获得对AirPlay的支持,效果很好,但我注意到苹果电视上的标题信息不会显示流式MP3的任何内容,而只会显示未知"信息.无论如何,可以通过应用程序控制此信息,还是这是由流式MP3引起的问题?任何帮助将不胜感激!

I have my app successfully streaming an MP3 via AVPlayer. I implemented a MPVolumeView to pull in AirPlay support which works great but I notice that the title info on my apple tv, does not show anything from the streamed MP3 but rather just "Unknown" info. Is there anyway to control this info from the app or is this an issue caused by the MP3 being streamed? Any help would be much appreciated!!

推荐答案

我想更新此问题,以防其他人需要控制AirPlay期间Apple TV上显示的内容.此功能适用于iOS5,但以下代码示例将在包含iOS4支持的应用程序上正确编译.

I wanted to update this question in case someone else needed to control what is seen on their Apple TV during AirPlay. This functionality is for iOS5 yet the code sample below will compile properly on an app that includes iOS4 support.

Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");

if (playingInfoCenter) {
            UIImage *albumArtImage = [UIImage imageNamed:@"Album-Image-Name.png"];
            MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:albumArtImage];

            MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
            NSDictionary *songInfo = [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"Artist Name", MPMediaItemPropertyArtist,
                                      @"Title Name", MPMediaItemPropertyTitle,
                                      @"Album Name", MPMediaItemPropertyAlbumTitle,
                                      artwork, MPMediaItemPropertyArtwork,
                                      nil];
            center.nowPlayingInfo = songInfo;
}

这是在媒体播放器(例如AVPlayer)上调用播放方法时的所有设置.

This is all setup when you call the play method on your media player, such as AVPlayer.

这篇关于App上Apple TV上的AirPlay元数据(AVPlayer-MPVolumeView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:29