admin管理员组

文章数量:1406943

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>

本文标签: javascriptiOS Autoplay Video WebViewStack Overflow