Created
September 6, 2014 12:57
-
-
Save isseium/9c70a303531b60148b80 to your computer and use it in GitHub Desktop.
WebView に表示した Video タグをオートプレイ設定する方法 ref: http://qiita.com/isseium/items/18b4c78e6e450310922a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.webview.url = "video.html" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window class="container"> | |
<WebView id="webview" /> | |
</Window> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://www.google.com/jsapi"></script> | |
<script>google.load("jquery", "1.3");</script> | |
<script type="text/javascript"> | |
jQuery.noConflict(); var j$ = jQuery; | |
function fakeClick(fn) { | |
var $a = j$('<a href="#" id="fakeClick"></a>'); | |
$a.bind("click", function(e) { | |
e.preventDefault(); | |
fn(); | |
}); | |
j$("body").append($a); | |
var evt, | |
el = j$("#fakeClick").get(0); | |
if (document.createEvent) { | |
evt = document.createEvent("MouseEvents"); | |
if (evt.initMouseEvent) { | |
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
el.dispatchEvent(evt); | |
} | |
} | |
j$(el).remove(); | |
} | |
j$(function() { | |
var video = j$("#my-video").get(0); | |
document.getElementById("my-video").playbackRate = 1; | |
fakeClick(function() { | |
video.play(); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<video id="my-video" width="340" height="273" src="filename.mp4" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment