/* Simple wrapper for the JwPlayer, load the thing and a sking. PURE AS3 (no flash or flex dependencies, compiles on command line via free mxmlc) ala mxmlc Wrapper.as */ package { //import flash.display.* import flash.display.Sprite; import flash.display.Loader; import flash.display.MovieClip; import flash.events.Event; import flash.net.URLRequest; import flash.external.ExternalInterface; //import flash.system.* import flash.system.ApplicationDomain; import flash.system.SecurityDomain; import flash.system.LoaderContext; //import flash.text.TextField; //import com.jeroenwijering.*; import com.jeroenwijering.events.*; import com.jeroenwijering.player.*; import com.jeroenwijering.plugins.*; import com.jeroenwijering.utils.Configger; public class Wrapper extends Sprite { private var loader:Loader = new Loader; private var playerObject : Object; /* Pass FlashVars to the Player here. Player.swf should be in the source root of your Flex application */ private var file:String = "player.swf?file=video.flv&" + "controlbar=bottom&" + //"skin=./skin/stylish2.swf&"+ "link=javascript:closeit()&"+ "resizing=false&"+ "fullscreen=true&"+ "allowscriptaccess=always&"+ "height=288&"+ "width=163&" + //width of the display (not the entire player!) in pixels "volume=0&" + ""; public function Wrapper() { trace('Wrapper()!'); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderFinished); var loaderContext:LoaderContext = new LoaderContext; loaderContext.checkPolicyFile = false; loaderContext.applicationDomain = ApplicationDomain.currentDomain; loaderContext.securityDomain = SecurityDomain.currentDomain; var playerUrl:URLRequest = new URLRequest( file ); loader.load( playerUrl, loaderContext); //loader.load( playerUrl ); //loader.width = 400; //loader.height = 100; addChild(loader); trace('Wrapper() is done'); } private function loaderFinished(e:Event = null) : void { trace('loaderFinished()!'); playerObject = e.target.content as Object; if(playerObject.view == null) { playerObject.addEventListener(PlayerEvent.READY, this.playerReady); } else { playerReady(); } } /* Once the Player has been initialized, we can begin to send and receive events from it */ private function playerReady(e:Event=null) : void { // Wait for the view to load the file. playerObject.view.addViewListener(ViewEvent.LOAD, loadedHandler); // Set the player screen to the correct dimensions. resizePlayer(); } /* The event loading the file has fired, we can now start the video playback. */ private function loadedHandler(e:Event=null):void { playerObject.view.addModelListener(ModelEvent.TIME, timeHandler); playerObject.view.sendEvent(ViewEvent.PLAY, true); } /* To resize the player, simply set its width and height, and send the view a ViewEvent.REDRAW event. */ private function resizePlayer() : void { trace('resizePlayer()!'); if(playerObject != null && playerObject.view != null) { playerObject.config['width'] = 288; //seems to be display width again, not entire player playerObject.config['height'] = 163; playerObject.view.sendEvent(ViewEvent.REDRAW); } } /* Respond to time events */ private function timeHandler(evt:ModelEvent) : void { if(evt.data.position > 3.0) { // Pause the video after 3 seconds) playerObject.view.sendEvent(ViewEvent.PLAY, false); } //timelabel.text = "Time tracker: " + evt.data.position; } } //end class }//end package /* FAQ Q: the back contains graidient outside of the 288 width of the player. is there a way to include that gradient in the skin or should it be moved outside the skin? A: maybe when you're embedding the jwplayer directly on a page but it doesn't seem like there's a solution when you're loading it into another swf. Q: can i change the width of stylish2.fla stage? A: yes, 288 is a fine width. Q: why does the jwplayer go full size of stage when a skin is loaded? A: i forgot the &"+ after the skin parmeter so the resizing & following parameters were not used Q: Juniper video dimentions? A: 288x163 for new Juniper player A: 320x240 example came from Mark Haren, some videos won't be resized Q: the timeSlider is 176 wide, i want it 76 wide A: timeSlider is only as wide as it's contents. change width of done, mark, and rail inside of it. Q: how big should the black out be for the play button A: 288x163 possitioned @ 144x81.5 Q: how big should the entire player be to fit the controlBarBackground? A: 307px (it's 35px high) Q: why does fullscreen make the entire SWF big, not just the player display? A: Q: why am i getting a security error when i click on the control bar but not on the player display? specifically: SecurityError: Error #2070: Security sandbox violation: caller http://devweb-juniper.det.organic.com/shared/swf/player.swf?file=http://devweb-juniper.det.organic.com/shared/flv/prad005_320x240.flv&controlbar=bottom&image=http://devweb-juniper.det.organic.com/shared/img/promo/prad005_320x240.jpg&skin=http://devweb-juniper.det.organic.com/shared/swf/playerSkin.swf&resizing=false&width=288&height=163 cannot access Stage owned by file:///C:/workspace/JuniperMediaModuleOld/bin-debug/JuniperMediaModule.swf. at flash.display::Stage/requireOwnerPermissions() at flash.display::Stage/addEventListener() at com.jeroenwijering.plugins::Controlbar/downHandler() A: */