Game Central Network
Left Navigation
 Graphic
Latest News
JW Player 4.5 4.6 4.7 AS3 Embed Inject into Flash Website
How to embed JW Player into a flash website | Posted by Brent on Sep 30th 10 11:26 PM
Hi All,

I just completed this after about 8 hours of work.

It seems JW Player 4 has lots of problems when trying to load it into an existing FLA file. They call this feature unsupported but amazingly it is very supported.

After 8 hours of research I present to you the possibility to own the FLA that can achieve this along with the step by step on how to embed the JW Player 4 into your own flash website.

Click buy to purchase the $10 PDF How-To and FLA file. You get your items immediately after checkout.


I can't redistribute the player code but I can give you precise instructions on which file and line number to modify in the 4.7 source to recompile the jw player. In addition you will get an FLA file that embeds the recompiled JW 4.7 player into the stage at a custom size and location, perfect for flash websites.

I was plighted by fruitless attempts to use all of the following sources before I designed my own source that worked for 4.5+ of JW Player.


Failed solution #1
import com.jeroenwijering.events.*;

Security.allowDomain("*");

var view:Object;
var loader:Loader = new Loader();
var urlRequest:URLRequest = new URLRequest("player.swf");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderHandler);
loader.load(urlRequest);

function loaderHandler(evt:Event){
addChild(loader);
var ply = evt.target.content;
var view = evt.target.content.view;
view.sendEvent(ViewEvent.FULLSCREEN);
view.sendEvent(ViewEvent.PLAY);
view.sendEvent(ViewEvent.LOAD,'stream.flv');

}

You may have also have read these other solutions solutions which also fail to work with 4.5+....
Failed solution #2
package com.rankedriders.display {
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.system.Security;

import com.jeroenwijering.events.*;
import com.jeroenwijering.player.*;
import com.jeroenwijering.plugins.*;
import com.jeroenwijering.utils.Configger;

public class Video extends Sprite {
private var playerObject:Object;
private var view:Object;

private var playerLoader:Loader = new Loader();
private var playerHolder:Sprite = new Sprite();

public function Video():void {
Security.allowDomain("*");
loadPlayer();
}

public function loadPlayer():void {
playerLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPlayerLoaded);
playerLoader.load(new URLRequest("player.swf"));
}

private function onPlayerLoaded(event:Event) : void {
playerObject = event.target.content as Object;

playerObject.addEventListener(PlayerEvent.READY, onPlayerReady);

playerObject.config.file = "video.flv";
playerObject.config.image = "still.flv.jpg";
playerObject.config.fullscreen = true;
playerObject.config.controlbar = 'over';
//playerObject.config.autostart = true;

addChild(playerLoader);
}

private function onPlayerReady(event:Event = null):void {
playerObject.config.resizing = false;
playerObject.config.width = 640;
playerObject.config.height = 360;

playerObject.view.sendEvent(ViewEvent.REDRAW);
playerObject.view.sendEvent(ViewEvent.PLAY);
}
}
}

Failed solution #3
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.display.Loader;
import flash.external.ExternalInterface;

import com.jeroenwijering.events.*;
import com.jeroenwijering.player.*;
import com.jeroenwijering.plugins.*;
import com.jeroenwijering.utils.Configger;



// variables
 var jwRequest:URLRequest = new URLRequest("http://us.example.com/player-licensed.swf"+"?file="+escape("http://content.longtailvideo.com/videos/flvplayer.flv"));
 var jwLoader:Loader = new Loader();
 var playerHolder:MovieClip = new MovieClip();
 var player:MovieClip = new MovieClip();
 var playerObject;

function testPlayer() {
//Load the JW Video Player
jwLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, loaderFinished);
jwLoader.load(jwRequest);
}

function loaderFinished(e:Event) : void {
area_label.text = 'finished loading';
addChild(playerHolder);
playerHolder.addChild(jwLoader);

player = jwLoader.content as MovieClip;
playerObject = e.target.content as Object;

//playerObject.view.sendEvent(ControllerEvent.RESIZE,'false');
playerHolder.width = 320;
playerHolder.height = 240;
playerHolder.x = 0;
playerHolder.y = 0;
playerHolder.scaleX = 1;//this is important! controlbar will squish without it
playerHolder.scaleY = 1;//this is important! controlbar will squish without it

if(playerObject.view == null) {
playerObject.addEventListener(PlayerEvent.READY, this.playerReady);
} else {
playerReady();
}
area_label.text=jwLoader.contentLoaderInfo.url;
}

function playerReady(e:Event=null) : void {
area_label.text = 'player ready';
// Wait for the view to load the file.
playerObject.view.addViewListener(ViewEvent.LOAD, loadedHandler);
// Set the player screen to the correct dimensions.
resizePlayer();
}

function loadedHandler(e:Event=null):void {
    area_label.text = 'player view ready';
playerObject.view.addModelListener(ModelEvent.TIME, timeHandler);
playerObject.view.sendEvent(ViewEvent.PLAY, true);
}

function resizePlayer() : void {

if(playerObject != null && playerObject.view != null) {
var config = playerObject.view.getPluginConfig(this);
playerObject.config['width'] = 320;
playerObject.config['height'] = 240;
playerObject.config['resizing'] = false;
playerObject.config['stretching'] = "uniform";
playerObject.view.sendEvent(ViewEvent.REDRAW);
}
}

function timeHandler(e:ModelEvent) {
        null;
       
    }


testPlayer();


Click buy to purchase the $10 PDF How-To and FLA file. You get your items immediately after checkout.

 
Game Central Network Home Game Central Network Reviews Game Central Network Articles Game Central Network Downloads Game Central Network Forum Game Central Network Home Game Central Network Home Game Central Network News Game Central Network Articles Game Central Network Downloads Game Central Network Resources Game Central Network Game Central Network Half-Life 2 Central Battlefield Central Game Technology Central Game Central Network Home Game Central Network Reviews Game Central Network Articles Game Central Network Cheats Game Central Network Downloads Game Central Network Forum