AirPlay button on custom view

两盒软妹~` 提交于 2019-11-27 11:23:26

问题


4.3 finally :) I am searching right now how to add air play button to custom view. I have MPMoviePlayer that load movie. I disabled standard controls and added overlay view with my custom play, pause, stop, volume buttons. If anybody know how to add button that will be air play please share knowledge? I cant't find what notification to send, what to listen...:(


回答1:


EDIT It seems I've been misguided in my previous answer because the device was not running the released version iOS 4.3.

There is a way to provide the AirPlay button on a custom interface.
Use a MPVolumeView and add it to your view hierarchy

MPVolumeView *myVolumeView =
[[MPVolumeView alloc] initWithFrame: overlayView.bounds];
[overlayView addSubview: myVolumeView];
[myVolumeView release];

The MPVolumeView provides the volume slider and the route button (see image below). But I don't think it's possible to only display the button.




回答2:


If you want just the AirPlay button without the volume slider follow the instructions in Jilouc's answer and then set the following properties on the myVolumeView:

[myVolumeView setShowsVolumeSlider:NO];
[myVolumeView setShowsRouteButton:YES];

That will hide the volume slider but keep the route button.




回答3:


In the Documentation Apple also includes a snippet for that:

MPVolumeView *volumeView = [ [MPVolumeView alloc] init] ;
[volumeView setShowsVolumeSlider:NO];
[volumeView sizeToFit];
[view addSubview:volumeView];


来源:https://stackoverflow.com/questions/5311373/airplay-button-on-custom-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!