han*_*ism 2 javascript video html5
如何在javascript而不是html5视频标签中使用webkit-playsinline?我想使用它就像在javascript中使用视频标签控制/自动播放属性一样,或者如果你们有任何其他方法正常工作?我正在开发一个流式视频的PhoneGap iOS应用程序.
以下是我尝试过的一些方法,但没有一种方法可行:
videoPlayer.WebKitPlaysInline ="webkit-playsinline"; videoPlayer.WebKitPlaysInline ="WebKitPlaysInline"; videoPlayer.webkit-playsinline ="webkit-playsinline"; videoPlayer.WebKitPlaysInline ="true"; videoPlayer.WebKitPlaysInline = true; videoPlayer.webkit-playsinline ="true"; videoPlayer.webkit-playsinline = true;
我目前的代码(js):
function loadPlayer() {
var videoPlayer = document.createElement('video');
videoPlayer.controls = "controls";
videoPlayer.autoplay = "autoplay";
videoPlayer.WebKitPlaysInline = true;
document.getElementById("vidPlayer").appendChild(videoPlayer);
nextChannel();
}
Run Code Online (Sandbox Code Playgroud)
我目前的代码(html):
<body onload="loadPlayer(document.getElementById('vidPlayer'));"><!-- load js function -->
<li><span class="ind_player"><div id="vidPlayer"></div></span></li><!-- video element creat here -->
Run Code Online (Sandbox Code Playgroud)
任何帮助都非常感激.谢谢.
小智 5
你可以不用jQuery做到这一点:
var videoElement = document.createElement( 'video' );
videoElement.setAttribute('webkit-playsinline', 'webkit-playsinline');
Run Code Online (Sandbox Code Playgroud)
您必须在iOs应用程序的WebView中激活此功能:
webview.allowsInlineMediaPlayback = true;
Run Code Online (Sandbox Code Playgroud)
您可以查看此帖子了解更多详情: