I'm playing a .mp4 video using StageWebView, Air 3.0 for iOS, iPad 2.
With the latest software version for the iPad2, when I dispose of the StageWebView instance, the .mp4 doesn't seem to close.
Well, at minimum the video's audio continues to play.
Anyone else encountered similar issues after the latest software update?
Hi Donny1985,
This is a bug, I am also able to see it on iPad 2, iOS 5. Could you please file a bug at http://bugbase.adobe.com and post the bug number here?
Thanks,
Sanika
I actually just came across this issue while creating an iPad app for a client.
If you're still looking for a descent solution check out this article I just wrote at http://poopcode.com/playing-mp4-videos-in-the-native-ios-video-player- with-stagewebview/. It's a bit of a hack, but it gets the job done for now.
Let me know if it works for you.
You can consider a 3rd party helper like StageWebViewBridge which allows you to communicate with JavaScript in the StageWebView. Then you can tell JavaScript to properly dispose of the video and when done close your SWV.
I would still run a dispose() and null the object for garbage collection ala:
webView.stage = null; // just make instantiated webview invisible, but still exists
webView.dispose(); // run self destroying sequence, who knows what adobe does in this
webView = null; // nullify reference marking for garbage collection
Just taking it off the active stage won't destroy it until nothing references it. You could hope adobe accurately derefrences it if you do another webView = new StageWebView(); as long as webView's scope is the same as the prior, e.g. class variable..
Have you tried StageWebViewBridge? Javascript can certainly stop a html5 video.
Regardless each page, as well as an onload handler, has an onunload handler. If you're embedding the video in a HTML5 page you might be able to fire off the onunload handler to make sure your video stops via JavaScript without StageWebViewBridge.
I had the same issue, and then they implemented StageVideo, so I play it directly without a StageWebView. Why not just use that GPU accelerated class?
My client wants an intro video to autoplay and I had to use StageWebViewBridge to talk to JavaScript after the page loaded to start the video automatically and it was a pain. Though Adobe has clearly stated not to use any items that are beta in a final product and at this moment StageWebView is marked Beta. Have you considered that?
StageVideo is no longer beta.
I believe it's not a bug. We need to dispose the object and have the garbage collection, set the StageWebView variable to null, so that we have no references to the actual StageWebView object.
Try something like:
stageWebView.reload();
stageWebView.viewPort = null;
stageWebView.dispose();
stageWebView = null;
I actually wrote about that here. If you scroll down the comments there is an answer for the StageVideo API as well.
The reason you are not seeing the video is most likely caused by it not being added to the display list. The StageVideo object is actually behind all of the display objects on the stage unlike StageWebView which is displayed on top. The trick is to house all of the objects on the stage inside of a containing sprite and hiding them all when the video is loaded.
StageVideo is really supposed to be used as a video player allowing you to place the controls on top.
@Gabriel - Glad to see it worked for you! ![]()
If you don't need to kill it (in other words, desire to have it continue to exist to reopen) why are you killing it? If you just want to hide it set the .stage property to null and it will disappear. Although if media is playing in it you may hear it. In that case you'd need to dispose and null which stops all movies just fine for me.
The stageWebView.reload(); is not necessary, perhaps due to 3.1. I never needed this with 3.0 either however.
If you want to use the same webview (class-level variable?) just stageWebView = new StagWebView(); and set the stage, viewPort and load something in it. If you null it you need to completely remake it. I re-use a class level variable to reference the same webview all the time. Works fine.
I just do:
var sFileName:String = 'assets/video/some.mp4';
var rVideoFile:File = File.applicationDirectory.resolvePath(sFileName);
if (rVideoFile.exists)
{
_stageWebView = new StageWebView();
_stageWebView.stage = this.stage;
_stageWebView.viewPort = new Rectangle(x, x, x, x); // predetermined with baked in assets
_stageWebView.loadURL(rVideoFile.nativePath);
}
When I need to get rid of the video I do the code I've mentioned several times..
_stageWebView.stage = null;
_stageWebView.viewPort = null;
_stageWebView.dispose();
_stageWebView = null;
Video or audio stops playing just fine. Also autoplays upon launching.
I got the video playing, but the "done" button on the native player closes the video and gets back to the StageWebView, how do I close it and get back to my application?
is it with the Event.COMPLETE? does not work, it's not distached
view = new StageWebView();
view.addEventListener(Event.COMPLETE,handleLoad);
view.stage = this.stage;
view.viewPort = new Rectangle( x, y, 320, 480);
view.loadURL(path);
function handleLoad(event : Event) : void
{
view.reload();
view.viewPort = null;
view.dispose();
view = null;
}
You can't communicate with StageWebView. There's no easy way unless you have an native extension to utilize native iOS UIWebView. There's a UIWebView and VideoPlayer native extension available at http://darkredz.com/introducing-ios-uiwebview-and-videoplayer-native-e xtension-for-air-mobile/
You can listen on full screen exit event and dispose the video player from there.
North America
Europe, Middle East and Africa
Asia Pacific