Skip to main content
June 8, 2011
Question

Launching media from my app in native media player/s

  • June 8, 2011
  • 1 reply
  • 2150 views

Hi,

I am a little lost at the moment as to how I can play video from my app in the devices local media player, and if it is at all possible to have it launch the media player, play the media and then re-focus/return to my mobile app when media has finished.

In other words:

1. I run my mobile app

2. A button within my app when pressed will play media (e.g, video) in the Mobile Devices media player. So it will open Media player and launch my video. I am not worried about formatting/ encoding anything. Assume we are only playing a compatible format

3. When media has finished, the player will close and return focus to my app

Developing in FB4.5/ flex mobile project/ AS3/ SDK4.5

Any help with steps 1 & 2 above will be very welcome, as for step 3 well if anyone can assist that would be magical :). Any info will be greatly recieved and any solution I come up with will be posted

Thanks

This topic has been closed for replies.

1 reply

relaxatraja
Inspiring
June 9, 2011

Use the StageWebView class to play video on ipad with native player controls. but you'r not able to control the player with your scripts. The below code will work with native players.

import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.filesystem.File;
import flash.utils.Timer;
import flash.events.TimerEvent;

stop();

var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
var fPath:String = new File(new File("app:/MyMovie.mp4").nativePath).url;
webView.loadURL( fPath );

To know the end of the video, Just create an timer and activate the event when equal to the video timing (manually find that) and use the below code to remove the video:

webView.stage = null

June 10, 2011

Firstly I want to say thanks this was very helpful and I could achieve whatI wanted.

I am however dubious about the timer requriement for playing video and closing the webstageview. What would be the alternative in the Flex app itself. I do not see a videoplayback component in Flash Builder 4.5. Also while this may be for another discussion I was wondering if there is a component of any kind to view PDF;s

Thanks