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

    1. <small id='cRA45'></small><noframes id='cRA45'>

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

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

    2. <tfoot id='cRA45'></tfoot>
    3. 在 IOS 的 UIWebView 中播放 youtube 视频时设备中没有声音的问题

      时间:2023-11-09

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

            2. <legend id='yPpQb'><style id='yPpQb'><dir id='yPpQb'><q id='yPpQb'></q></dir></style></legend>
              • 本文介绍了在 IOS 的 UIWebView 中播放 youtube 视频时设备中没有声音的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 UIWebView 播放 Yoytube 视频.
                我的代码是这样的

                I am using a UIWebView to play Yoytube Video.
                My code is like that

                self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0,320, 240)];
                [self.webView setBackgroundColor:[UIColor clearColor]];
                [self.webView setOpaque:NO];
                self.webView.delegate=self;
                [self.webView setAllowsInlineMediaPlayback:YES];
                [self.webView setMediaPlaybackRequiresUserAction:NO];
                [self.viewContent addSubview:self.webView];
                
                NSString* embedHTML = [NSString stringWithFormat:@"
                                                   <html>
                                                   <body style='margin:0px;padding:0px;'>
                                                   <script type='text/javascript' src='http://www.youtube.com/iframe_api'></script>
                                                   <script type='text/javascript'>
                                                   function onYouTubeIframeAPIReady()
                                                   {
                                                   ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})
                                                   }
                                                   function onPlayerReady(a)
                                                   { 
                                                   a.target.playVideo(); 
                                                   }
                                                   </script>
                                                   <iframe id='playerId' type='text/html' width='%d' height='%d' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'>
                                                   </body>
                                                   </html>", 320, 240, [dictIW valueForKey:@"embedCode"]];
                [self.webView loadHTMLString:embedHTML baseURL:[[NSBundle mainBundle] resourceURL]];
                

                在模拟器中玩得非常好.但是当我在 iPhone 或 iPad 上播放此视频时,视频正在播放,但声音却没有.
                请帮忙.

                In Simulator it is playing absolutely fine. But when I play this video in iPhone or iPad, the video is showing, but the sound is not getting.
                please help.

                推荐答案

                在创建 UIWebView 之前将音频会话类别设置为播放"

                Set the audio session category to 'playback' before creating the UIWebView

                AVAudioSession *audioSession = [AVAudioSession sharedInstance];
                BOOL flag;
                NSError *setCategoryError = nil;
                flag = [audioSession setCategory:AVAudioSessionCategoryPlayback
                                     error:&setCategoryError];
                

                这篇关于在 IOS 的 UIWebView 中播放 youtube 视频时设备中没有声音的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:UIWebView 没有完成加载? 下一篇:如何解决“帧加载中断"UIWebView 中的错误?

                相关文章

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

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

                1. <tfoot id='opuV1'></tfoot>
                2. <legend id='opuV1'><style id='opuV1'><dir id='opuV1'><q id='opuV1'></q></dir></style></legend>