简体   繁体   中英

How to stop video autoplaying (stageWebView in Air for iOS - Flash)

Is there a reason a stageWebView may be autoplaying? As soon as it loads, it will start playing, but the funny thing with it is that the Play Icon stays there even while it's already playing. I was hoping to have it paused when it loads and only play if the user requires it to be played.

import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.filesystem.File;

var webView:StageWebView = new StageWebView();
var path:String = new File(new File("app:/video.mp4").nativePath).url;

webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(100, 100, 400, 300);
webView.loadURL(path);

I can't pick anything out of my code that looks like it would be causing the error?

Consider using StageVideo instead. It is supported on iOS.

From Adobe Air 21 release notes ( http://fpdownload.macromedia.com/pub/labs/flashruntimes/shared/air21_flashplayer21_releasenotes.pdf )

Media Auto Play for iOS & Android Starting AIR 21, we are introducing Media Auto Play support for AIR iOS & Android applications. Using this feature, ActionScript developers can enable media auto play inside StageWebView. To enable this, autoplay should also be enabled in the HTML5 video tag. (More info on HTML5 video tag : http://www.w3schools.com/tags/tag_video.asp ). Please use swf-version 32 or greater and namespace 21.0 or greater to access this feature.

var webView:StageWebView = new StageWebView();
webView.stage = stage;
webView.viewPort = new Rectangle( 0, 0, 400, 300 );
webView.mediaPlaybackRequiresUserAction = false;// To enable autoplay in given web view
webView.addEventListener(Event.COMPLETE, <handleComplete>);
webView.addEventListener(ErrorEvent.ERROR, <handleError>);
webView.loadURL("http://any/webpage/with/autoplay/enabled/video.html”)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM