HTML5 video on iPad

后端 未结 8 1121
深忆病人
深忆病人 2020-12-30 03:07

I have a dynamic video gallery and it works great on a computer. When moving to an iPad, the video starts loading and it shows the cannot play icon. Instead of this I\'d r

相关标签:
8条回答
  • 2020-12-30 03:58

    Check to see if the browser can play the video before you attempt to load it:

    function canPlayVorbis() {
        var v = document.createElement('video');
        return !!(v.canPlayType && v.canPlayType('video/ogg; codecs="theora, vorbis"').replace(/no/, ''));
    }
    
    function canPlayMP4() {
        var v = document.createElement('video');
        return !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
    }
    
    function canPlayWebM() {
        var v = document.createElement('video');
        return !!(v.canPlayType && v.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, ''));
    }
    

    Taken from Dive Into HTML5 Appendix A.

    0 讨论(0)
  • 2020-12-30 04:00

    Here's a GREAT place to get familiar with HTML5 events.

    http://www.w3.org/2010/05/video/mediaevents.html

    0 讨论(0)
提交回复
热议问题