iphone - 为什么此代码无法使用 MPMoviePlayerController 播放歌曲

标签 iphone ios cocoa-touch media-player

我很难弄清楚这个问题,欢迎提出任何建议:

NSURL *songUrl = [NSURL URLWithString:@"http://a1804.phobos.apple.com/us/r1000/064/Music/v4/9b/b3/c7/9bb3c7dc-a06f-f18c-3e41-2ce1e36f73b4/mzaf_7432104896053262141.aac.m4a"];

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:songUrl];

[[NSNotificationCenter defaultCenter] addObserver:self

                                         selector:@selector(moviePlayBackDidFinish:)

                                             name:MPMoviePlayerPlaybackDidFinishNotification

                                           object:nil];



[mp setControlStyle:MPMovieControlStyleFullscreen];

[mp setMovieSourceType:MPMovieSourceTypeStreaming];

[mp setFullscreen:YES];



[self.view addSubview:[mp view]];



[mp prepareToPlay];

[mp play];

最佳答案

尝试使用 MPMoviePlayerViewController 而不是 MPMoviePlayerController

关于iphone - 为什么此代码无法使用 MPMoviePlayerController 播放歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17006644/

相关文章:

iphone - 使用 NSMutableArrays 创建 NSDictionary 的内存管理

ios - 自动布局约束无法正常工作

iphone - 在 Objective-c 中实现协议(protocol)方法

iphone - 隐藏删除按钮时自定义 uitableviewcell 内容不动画

ios - Iphone 模拟器屏幕键盘问题

iPhone:对象保留其委托(delegate)是否有意义?

iphone - 不会与CFRelease一起运行,但僵尸会失去它

ios - 在 iOS 11/iPhone 7/8plus 的第 3 方应用程序中使用 "portrait"模式( Bokeh )拍照?

ios - 从另一个 View Controller 访问数组数据

iphone - 在启动时调用选项卡栏的 View 方法