• <tfoot id='UyYAH'></tfoot>

      <legend id='UyYAH'><style id='UyYAH'><dir id='UyYAH'><q id='UyYAH'></q></dir></style></legend>

      <small id='UyYAH'></small><noframes id='UyYAH'>

        <bdo id='UyYAH'></bdo><ul id='UyYAH'></ul>

      <i id='UyYAH'><tr id='UyYAH'><dt id='UyYAH'><q id='UyYAH'><span id='UyYAH'><b id='UyYAH'><form id='UyYAH'><ins id='UyYAH'></ins><ul id='UyYAH'></ul><sub id='UyYAH'></sub></form><legend id='UyYAH'></legend><bdo id='UyYAH'><pre id='UyYAH'><center id='UyYAH'></center></pre></bdo></b><th id='UyYAH'></th></span></q></dt></tr></i><div id='UyYAH'><tfoot id='UyYAH'></tfoot><dl id='UyYAH'><fieldset id='UyYAH'></fieldset></dl></div>
      1. UIWebView:当应用程序进入后台时,iOS 6 中的 HTML5 音频暂停

        UIWebView: HTML5 audio pauses in iOS 6 when app enters background(UIWebView:当应用程序进入后台时,iOS 6 中的 HTML5 音频暂停)
        <legend id='JEtth'><style id='JEtth'><dir id='JEtth'><q id='JEtth'></q></dir></style></legend>

          <tfoot id='JEtth'></tfoot>
          • <bdo id='JEtth'></bdo><ul id='JEtth'></ul>

              <i id='JEtth'><tr id='JEtth'><dt id='JEtth'><q id='JEtth'><span id='JEtth'><b id='JEtth'><form id='JEtth'><ins id='JEtth'></ins><ul id='JEtth'></ul><sub id='JEtth'></sub></form><legend id='JEtth'></legend><bdo id='JEtth'><pre id='JEtth'><center id='JEtth'></center></pre></bdo></b><th id='JEtth'></th></span></q></dt></tr></i><div id='JEtth'><tfoot id='JEtth'></tfoot><dl id='JEtth'><fieldset id='JEtth'></fieldset></dl></div>

                <tbody id='JEtth'></tbody>

              <small id='JEtth'></small><noframes id='JEtth'>

                1. 本文介绍了UIWebView:当应用程序进入后台时,iOS 6 中的 HTML5 音频暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  早安,

                  我的应用是一个音乐播放应用.我用 Javascript 控制 <audio>-Tag.到目前为止没有问题,播放、暂停、下一个和上一个按钮都可以正常工作.当我在 iOS 5 中待机设备时,音乐继续播放,但自动下一首歌曲不起作用.当它不处于待机状态时,它可以工作.而在 iOS 6 中,只需按下按钮,音乐就会淡出.

                  My app is a music playing app. I control the <audio>-Tag with Javascript. So far no problems, play, pause, next and previous buttons are working. When I stand-by the device in iOS 5, the music keeps playing, but the automatic next song doesn't work. When it isn't in stand-by, it works. And in iOS 6, just after pressing the button, the music fades out.

                  锁屏上的播放/暂停按钮适用于 iOS 5,但不适用于 iOS 6.

                  The Play/Pause button on the lockscreen works in iOS 5, but not in iOS 6.

                  推荐答案

                  从 iOS 6 开始,您必须在创建 UIWebView 之前将音频会话类别设置为播放".这就是你所要做的.不必激活会话.

                  Starting with iOS 6, you MUST set the audio session category to 'playback' before creating the UIWebView. This is all you have to do. It is not necessary to make the session active.

                  这也应该用于 html 视频,因为如果您不配置会话,当铃声开关关闭时,您的视频将被静音.

                  This should be used for html video as well, because if you don't configure the session, your video will be muted when the ringer switch is off.

                  #import <AVFoundation/AVFoundation.h>
                  
                  AVAudioSession *audioSession = [AVAudioSession sharedInstance];
                  BOOL ok;
                  NSError *setCategoryError = nil;
                  ok = [audioSession setCategory:AVAudioSessionCategoryPlayback
                                           error:&setCategoryError];
                  if (!ok) {
                    NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
                  }
                  

                  确保您的目标链接到 AVFoundation 框架.

                  Ensure that your target links to the AVFoundation framework.

                  如果使用 Cordova,您需要修改的文件是 platforms/ios/MyApp/Classes/AppDelegate.m,最终将如下所示:

                  If using Cordova, the file you need to modify is platforms/ios/MyApp/Classes/AppDelegate.m, and will end up looking like this:

                  #import "AppDelegate.h"
                  #import "MainViewController.h"
                  #import <AVFoundation/AVFoundation.h>
                  
                  @implementation AppDelegate
                  
                  - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
                  {
                      AVAudioSession *audioSession = [AVAudioSession sharedInstance];
                      BOOL ok;
                      NSError *setCategoryError = nil;
                      ok = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
                      if (!ok) {
                          NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
                      }
                  
                      self.viewController = [[MainViewController alloc] init];
                      return [super application:application didFinishLaunchingWithOptions:launchOptions];
                  }
                  
                  @end
                  

                  此外,如评论中所述,您需要链接 AVFoundation 框架,如 这个答案:

                  Also, as mentioned in the comments, you need to link the AVFoundation Framework, as explained in this answer:

                  • 用 xcode 打开你的项目 open ./platforms/ios/MyApp.xcworkspace/
                  • 项目导航器 > 定位我的应用程序 > 常规
                  • 滚动到底部以查找链接的框架和库

                  这篇关于UIWebView:当应用程序进入后台时,iOS 6 中的 HTML5 音频暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                  Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                  ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                  How to get indexPath.row of tableView which is currently being displayed?(如何获取当前正在显示的 tableView 的 indexPath.row?)
                  Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                  MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                  <tfoot id='nYgFa'></tfoot>

                      <legend id='nYgFa'><style id='nYgFa'><dir id='nYgFa'><q id='nYgFa'></q></dir></style></legend>

                            <tbody id='nYgFa'></tbody>
                        1. <i id='nYgFa'><tr id='nYgFa'><dt id='nYgFa'><q id='nYgFa'><span id='nYgFa'><b id='nYgFa'><form id='nYgFa'><ins id='nYgFa'></ins><ul id='nYgFa'></ul><sub id='nYgFa'></sub></form><legend id='nYgFa'></legend><bdo id='nYgFa'><pre id='nYgFa'><center id='nYgFa'></center></pre></bdo></b><th id='nYgFa'></th></span></q></dt></tr></i><div id='nYgFa'><tfoot id='nYgFa'></tfoot><dl id='nYgFa'><fieldset id='nYgFa'></fieldset></dl></div>

                          <small id='nYgFa'></small><noframes id='nYgFa'>

                          • <bdo id='nYgFa'></bdo><ul id='nYgFa'></ul>