最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - iOS Autoplay Video WebView - Stack Overflow

programmeradmin0浏览0评论

I want to add into the body a video (local video) that should be on auto play Any easy solution for that?

<!DOCTYPE html>
<html>
    <head>
        <link href="fuctions/style.css" rel="stylesheet" media="screen" type="text/css" />
        <script type="text/javascript" charset="utf-8" src="fuctions/cordova-2.3.0.js"></script>
        <script type="text/javascript" charset="utf-8" src="fuctions/functions.js"></script>
    </head>
<body onload="onBodyLoad()">
    <script type="text/javascript">
        checkFirstRun();
    </script>
</body>
</html>

I want to add into the body a video (local video) that should be on auto play Any easy solution for that?

<!DOCTYPE html>
<html>
    <head>
        <link href="fuctions/style.css" rel="stylesheet" media="screen" type="text/css" />
        <script type="text/javascript" charset="utf-8" src="fuctions/cordova-2.3.0.js"></script>
        <script type="text/javascript" charset="utf-8" src="fuctions/functions.js"></script>
    </head>
<body onload="onBodyLoad()">
    <script type="text/javascript">
        checkFirstRun();
    </script>
</body>
</html>
Share asked Jan 23, 2013 at 13:05 Fabian BoulegueFabian Boulegue 6,60814 gold badges51 silver badges72 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

There is a property on UIWebView called mediaPlaybackRequiresUserAction which defaults to YES. Change it to NO.

Apple and Google decided to allow autoplay in their mobile browsers. But only if videos are muted. On iOS you also have to set the playsinline attribute, because by default videos will play fullscreen.

To get autoplay use the following setup:

<video controls autoplay loop muted playsinline>

<source src="video.mp4" type="video/mp4">

<source src="video.webm" type="video/webm">

</video>
发布评论

评论列表(0)

  1. 暂无评论