MPMoviePlayer 声音在模拟器和 ipad 设备中工作,但在 iPhone 设备中不工作
我的 MPMoviePlayerController 有问题,即我正在以(m3u8 格式)MPMoviePlayer 播放实时流 url,如下所示
player = [[MPMoviePlayerController alloc] initWithContentURL:audioUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(loadStateDidChange:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:player];
if ([player respondsToSelector:@selector(loadState)])
{
// Set movie player layout
[player setMovieSourceType:MPMovieSourceTypeStreaming];
[player setControlStyle:MPMovieControlModeVolumeOnly];
[player setFullscreen:YES];
[player prepareToPlay];
[player play];
}
}
: iPad 设备装有 ios 5 版本,但我拥有的任何 iPhone 设备都无法提供音频。
请帮帮我... 提前致谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
simham 先生...检查下面的网址,它对我们有帮助 becoZ
在移动 safari 中调用流网址。如果结果相同,则您的代码是正确的,而流则不正确。那么这将是一个编码错误的音频流。
这也取决于带宽,也低于参考网址关于带宽检查一次....您的参考流URL准备,根据BandWith
参考 URL:
mr simham ... check this below url it help for us becoZ
Call stream-url within mobile safari. If that has the same results, then your code is correct and the stream is not. It would be an incorrectly encoded audio stream then.
it depends on bandwidth also below ref url regards to bandwidth check it once.... u r ref Stream URL prepare,according to BandWith
REFERENCE URL:
您正在为需要
MPMovieControlStyle
的controlStyle
属性分配已弃用的MPMovieControlMode
(MPMovieControlModeVolumeOnly
)。此外,您的代码缺少将 MPMoviePlayerController.view 分配给任何超级视图的部分,并且其大小也丢失。
最后但我想对你来说最重要的是,我猜你正在尝试的 iPhone 已经将音量一直调到静音。或者,音频路由可能未设置为扬声器输出。对于后者,请确保您没有在应用程序的其他任何地方错误地设置音频会话。如有疑问,请尝试摆弄
useApplicationAudioSession
属性。尝试将其设置为NO
,看看这是否会改变您的结果。如果上述所有操作均失败,则另一项检查将是在 mobile safari 中调用stream-url。如果结果相同,则您的代码是正确的,而流则不正确。那么这将是一个编码错误的音频流。
You are assigning a deprecated
MPMovieControlMode
(MPMovieControlModeVolumeOnly
) towards thecontrolStyle
property which is expecting aMPMovieControlStyle
.Additionally, your code is missing the part that assigns the
MPMoviePlayerController.view
towards any superview and also its sizing is missing.Last but I guess most importantly for you, I am guessing that the iPhone you are trying it with has set the volume all the way down to silence. Or, maybe the audio-routing is not set towards speaker-output. For the latter, make sure you are not setting up the audio session incorrectly anywhere else in your App. When in doubt, try fiddling with the
useApplicationAudioSession
property. Try setting it towardsNO
and see if that changes your results.If all above fails, then one additional check would be to call the stream-url within mobile safari. If that has the same results, then your code is correct and the stream is not. It would be an incorrectly encoded audio stream then.
检查您的 iPhone 是否处于扬声器模式 -
如果没有,请使用此设置 -
Check if your iPhone is on loudspeaker mode or not -
if not than set it using this-
检查 iPhone 是否处于静音模式。要在静音模式下也播放音频,请在 AppDelegate 的 中添加以下代码 application:didFinishLaunchingWithOptions:
Check if the iPhone is in silent mode. To play audio even in silent mode, add the following code in AppDelegate's application:didFinishLaunchingWithOptions: