将 AirPlay 添加到 AVAudioPlayer (Swift)
Adding AirPlay To AVAudioPlayer (Swift)
我正在制作一款带有 AVAudioPlayer
的音乐应用。我希望用户能够打开 AirPlay 选择器视图...
...通过点击 UIToolBar
中的 UIBarButtonItem
来流式传输从我的应用程序播放的音乐。我该怎么做?
从没有音量滑块的 MPVolumeView
开始:
MPVolumeView* myVolumeView = [[MPVolumeView alloc] initWithFrame: CGRectMake(...)];
myVolumeView. showsVolumeSlider = NO;
请参阅 Add MPVolumeView to bottom toolbar 了解如何将 MPVolumeView
添加到 UIBarButtonItem
,即:
UIBarButtonItem* b = [[UIBarButtonItem alloc] initWithCustomView: myVolumeView];
Swift 4
var myVolumeView = MPVolumeView(frame: CGRect(x: x, y: y, width: width, height: height))
myVolumeView.showsVolumeSlider = false
var airplayButton = UIBarButtonItem(customView: myVolumeView)
我正在制作一款带有 AVAudioPlayer
的音乐应用。我希望用户能够打开 AirPlay 选择器视图...
...通过点击 UIToolBar
中的 UIBarButtonItem
来流式传输从我的应用程序播放的音乐。我该怎么做?
从没有音量滑块的 MPVolumeView
开始:
MPVolumeView* myVolumeView = [[MPVolumeView alloc] initWithFrame: CGRectMake(...)];
myVolumeView. showsVolumeSlider = NO;
请参阅 Add MPVolumeView to bottom toolbar 了解如何将 MPVolumeView
添加到 UIBarButtonItem
,即:
UIBarButtonItem* b = [[UIBarButtonItem alloc] initWithCustomView: myVolumeView];
Swift 4
var myVolumeView = MPVolumeView(frame: CGRect(x: x, y: y, width: width, height: height))
myVolumeView.showsVolumeSlider = false
var airplayButton = UIBarButtonItem(customView: myVolumeView)