要继续从HTML5播放器在iOS的后台模式下播放音频 [英] Continue playing audio from html5 player when in iOS background mode

查看:1609
本文介绍了要继续从HTML5播放器在iOS的后台模式下播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们建立了我们面向音乐的应用程序在HTML5和JavaScript与煎茶触摸。对于分发我们在X code。与UIWebView中包裹着它。一切都正常运行,除了一件事,不工作:在多任务模式下的音频播放

We built our music-oriented app in html5 and javascript with Sencha touch. For distribution we wrapped it in xcode with UIwebView. Everything runs fine except one thing that does not work: audio playing in multitask mode.

我知道的总体思路:增加UIBackgroundModes在info.plist中

I know the general idea: add the UIBackgroundModes in info.plist.

完成。现在,我们甚至可以在后台模式下播放音频。

Done. Now we can play the audio even in background mode.

直到我们到达乐曲的结尾。要开始下一首歌曲,我们必须把应用程序重新前景或我们能打到iPhone音频控制器上的播放或下一首歌曲按钮。

Until we reach the end of the song. To start the next song we have to bring the app to foreground again or we can hit the play or 'next song' button on the iPhone audio controller.

经过一番研究,我发现了一个有前途的解决办法的:<一个href=\"http://stackoverflow.com/questions/3161635/entering-background-on-ios4-to-play-audio/3161899#3161899\">Entering在iOS4的后台播放音频里的解决方法是编辑AVAudioSessionCategoryPlayback并与UIBackgroundTaskIdentifier工作。
对我来说,问题是(就像任何其他的修复,我发现到目前为止),这些解决方案总是假设音频播放或者与AVaudioPlayer或MPMusicPlayerController。但是,在我来说,我既没有用户,我们的声音是我们的HTML5播放器包裹在UIWebView中播放。

After some research I found a promising workaround at: " Entering background on iOS4 to play audio " where the workaround is to edit AVAudioSessionCategoryPlayback and work with the UIBackgroundTaskIdentifier. The problem for me is (just like in any other fix I found so far) that those solutions always assume that the audio is played either with AVaudioPlayer or MPMusicPlayerController. But in my case I user neither, our audio is played by our html5 player wrapped in UIwebView.

任何人有如何继续播放音频iOS中多任务模式下的音频播放器是一个HTML5 / JavaScript的球员?任何意见

Anyone has any advice on how to continue playing the audio in iOS multitask mode when the audio player is a html5/javascript player?

推荐答案

谢谢,伙计们,但是我最终只是在保持应用程序忙于在一个循环的背景模式。这足以连接到播放列表中的下一首歌曲时弥合的时间。
在code我采用的是类似于此:
iPhone - 一个后台轮​​询事件

Thanks, guys, but I ended up simply keeping the app busy in a loop when in background mode. This was enough to bridge the time when connecting to the next song on the playlist. The code I used is similar to this one: iPhone - Backgrounding to poll for events

这篇关于要继续从HTML5播放器在iOS的后台模式下播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆