PhoneGap iOS can't play video using HTML 5

戏子无情 提交于 2019-12-07 11:55:05

问题


I'm building phonegap app and I need to play video in it. I know in order to play video on Android, I need to use one of the plugins available, but to play video on iOS, I can use HTML 5 video tag. I have these lines of code:

 <div id="video">
    <video id="video01" width="300" height="300" controls>
        <source src="images/test2.mp4" type="video/mp4" />
    </video>
</div>

I can see "video box", but I cannot play video for some reason. In console I don't see any errors.

Video I'm using is from this page: http://www.quirksmode.org/html5/tests/video.html

And in iPhone Safari I can load MP4 version from that page without any problems.


回答1:


I know it has been a while, but I was looking at some of my old questions, and I've noticed that I completely forgot to post solution to my problem.

In the end I've managed to fix the issue using Cordova File api, and solution looks smth. like this:

 window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
                console.log("gotFS");


                getFolder(fileSystem, "video", function(folder) {
                    filePath = folder.toURL() + "\/" + "videotest.mp4";

                    playVideo(filePath);

                }, function() {
                    console.log("failed to get folder");
                });

            },
            function() {
                console.log("failed to get filesystem");
            });



function playVideo(uri) {


        var player = document.getElementById("videoPlayer");
        var source = document.createElement("source");

        source.src = uri;
        source.type = "video/mp4";

        player.appendChild(source);
        player.load();
    }


来源:https://stackoverflow.com/questions/30279719/phonegap-ios-cant-play-video-using-html-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!