use webkit-playsinline in javascript

后端 未结 2 948
忘掉有多难
忘掉有多难 2021-01-14 16:53

How do I use webkit-playsinline in javascript instead of in html5 video tag? I want to use it just like using video tag control/autoplay attribute in javascript or if you gu

相关标签:
2条回答
  • 2021-01-14 17:32

    You can do this without jQuery:

    var videoElement = document.createElement( 'video' );
    videoElement.setAttribute('webkit-playsinline', 'webkit-playsinline');
    

    You have to activate this functionality in your iOs application's WebView :

    webview.allowsInlineMediaPlayback = true;
    

    You can check this post for more details:

    HTML5 inline video on iPhone vs iPad/Browser

    0 讨论(0)
  • 2021-01-14 17:33

    You need to attach it to the video element and set it as video's attribute

    such as :

    <video class="" poster="" webkit-playsinline>
        <source src="" type="video/ogg" preload="auto">
        <source src="" type="video/mp4" preload="auto">                
    </video>
    

    so you could do (with jQuery) :

    $('video').attr('webkit-playsinline', '');
    
    0 讨论(0)
提交回复
热议问题