Skip to main content
October 28, 2011
Question

StageWebView.dispose() no longer functioning properly with iOS5?

  • October 28, 2011
  • 7 replies
  • 9049 views

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?

This topic has been closed for replies.

7 replies

Participating Frequently
March 13, 2012

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;

}

July 15, 2012

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-extension-for-air-mobile/

You can listen on full screen exit event and dispose the video player from there.

http://darkredz.com/ane/UIWebView/apidoc/com/darkredz/mobile/ane/VideoPlayer.html#event:fullscreenExit

Participant
November 17, 2011

stageWebView.reload();

stageWebView.viewPort = null;

stageWebView.dispose();

stageWebView = null;

worked for me. Perfect! I still have a problem with StageVideo on my iPad 1 iOS 5. Audio plays fine but i see no video. So i will use WebView.

Participant
November 17, 2011

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!

November 11, 2011

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;

Inspiring
December 9, 2011

stageWebView.reload();

stageWebView.viewPort = null;

stageWebView.dispose();

stageWebView = null;

This works perfectly for me...   Only problem is that now since I kill the webView .. I can't re-open it again.     How can I get around this ?

sinious
Legend
December 9, 2011

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.

November 4, 2011

I am using stageWebView to play and mp4 my stageWebView variable is called webView so to kill it this line seems to work webView.stage = null;

edit: I am in iOS 5 on iPad2 and iOS4 latest on iPhone 4, both work.

sinious
Legend
November 5, 2011

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..

November 6, 2011

None of those solutions worked unfortunately.

I imagine the StageWebView is being disposed, but the audio channel remains.

For now I can only stop the movies audio channel once I load another video with audio.

sinious
Legend
November 3, 2011

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.

Participating Frequently
November 4, 2011

Hi,

Update on the bug. It should be fixed in the next release of AIR.

Thanks,

Sanika

sinious
Legend
November 4, 2011

Any idea when that next air update will be? I've read forum rumors of them ditching StageWebView overall (inconceivable to me) and I'm hoping they'll both keep it and remove beta status from it. Works great for me.

Participant
November 3, 2011

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.

Participating Frequently
October 28, 2011

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

October 28, 2011

Here we are: Bug 3014137