You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Embedding Flowplayer in Flash Created Mar 2, 2010

This thread is solved

Views: 5613     Replies: 16     Last reply Nov 30, 2011  
You must login first before you can use this feature

Anssi
Flowplayer Flash & video streaming developer

Posts: 1194

Registered:
Jul 24, 2007

Embedding Flowplayer in Flash

Posted: Mar 2, 2010

There's a way to embed Flowplayer into another swf file using pure AS3, but it's not that easy. Here's the steps to get it working. I have received this info from a friend and this is him speaking:

- I load FP using the Loader class
- I inject the config when it's first loaded
- I create a plugin that will hold a static reference to the player when the player is loaded
- I wait for the plugin to be loaded, and get the player's reference
- I handle the resize of the player

Here's a code chunk that I used to load FP


var context:LoaderContext = new LoaderContext();  
context.securityDomain = SecurityDomain.currentDomain;  
context.applicationDomain = ApplicationDomain.currentDomain; 
             
Security.allowDomain("*"); 
Security.allowInsecureDomain("*"); 
var resourceLoader:Loader = new Loader(); 
var resourceRequest:URLRequest = new URLRequest(playerURL); // player url is FP's url 
                 
resourceLoader.contentLoaderInfo.addEventListener(Event.INIT, function(event:Event):void {  
    log.debug("Player INIT event"); 
    var preloader:* = event.currentTarget.content; 
    preloader.injectedConfig = playerConfiguration; // playerConfiguration is a json string 
    _parent.addChild(preloader);  // _parent is my main Sprite 
}); 
 
resourceLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event:Event):void {  
    log.debug("Player COMPLETE event"); 
                         
    var progressEvent:ProgressEvent = new ProgressEvent(ProgressEvent.PROGRESS); 
    progressEvent.bytesTotal = 100; 
    progressEvent.bytesLoaded= 100; 
// fake event to tell FP that it's loaded         
    event.currentTarget.content.onLoadProgress(progressEvent); 
    waitForPlayer(); 
    // this function will wait for player 
}); 
                     
resourceLoader.load(resourceRequest, context); 

In order to use the Flowplayer object (play, pause, ..), you have to create a FP plugin that will only hold a static reference to the FP object, with a getter.

My waitForPlayer method looks like :


var player:* = null; 
try { 
    var getterClass:Class = flash.utils.getDefinitionByName('com.yourstuff.getter.Getter') as Class; 
    player = getterClass.getPlayer.apply(null, []); 
} catch(e:Error) { 
    // plugin not yet loaded. 
    log.debug("Plugin not yet loaded", e); 
} 
if ( player ) 
{ 
    // call a callback or whatever 
} 
else if ( _waitCount++ > MAX_WAIT_COUNT ) 
    throw new Error("Unable to load player"); 
else 
    setTimeout(waitForPlayer, 100); 

Moreover, you might want to handle the resize of the player. By default, it will take the whole Stage's space. If you want to change its size, you have to specify the size of the Launcher class and call the draw() method of the Panel class. I did a little recursive function that will look for the Launcher & Panel DisplayObjects in the main Sprite children.

inigong
http://www.bestmortgagerates4u.ca/index.php/ontario_mortgage_broker_ontario_mortgages/

Posts: 1

Registered:
Mar 4, 2010

» Embedding Flowplayer in Flash

Posted: Mar 4, 2010

Reply to: Embedding Flowplayer in Flash, from Anssi
Thanks for this tip. And from what I also understand that flash is one of plugin of flowplayer right?I use flash since I use it to embed video streams in my website.

smad

Posts: 1

Registered:
Mar 10, 2010

» Embedding Flowplayer in Flash

Posted: Mar 10, 2010

Reply to: Embedding Flowplayer in Flash, from Anssi
Anssi - would you be interested in working for us to embed 4 vids into a flash website?

Thomas Dubois
thomas_at_bigsool.com

Posts: 68

Registered:
Feb 1, 2010

» » Embedding Flowplayer in Flash

Posted: Mar 10, 2010

Reply to: » Embedding Flowplayer in Flash, from smad
Hi Smad,

I'm Anssi's friend who did the code he pasted. He told me you were looking for a flash developer able to integrate flowplayer in a flash website.

You can contact me at thomas 0at0 bigsool.com .
Cheers,

Thomas

zemen

Posts: 2

Registered:
Jun 18, 2010

» Embedding Flowplayer in Flash

Posted: Jun 22, 2010

Reply to: Embedding Flowplayer in Flash, from Anssi
im using dynamic play list of AS3, the code is copy from other site, is using package:

package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.listClasses.CellRenderer;
import fl.controls.ScrollBarDirection;
import flash.text.TextFormat;
import fl.controls.TextArea;

public class VideoPlaylist extends MovieClip {
private var xmlLoader:URLLoader;
private var textStyle:TextFormat;
private var description:TextArea;
public var str:String;
public function VideoPlaylist():void {
// Load the playlist file, then initialize the media player.
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
xmlLoader.load(new URLRequest("playlist.xml"));
// Format the tileList, specify its cellRenderer class.
tileList.setSize(200, 240);
tileList.columnWidth=180;
tileList.rowHeight=60;
tileList.direction=ScrollBarDirection.VERTICAL;
tileList.setStyle("cellRenderer", Thumb);
textStyle = new TextFormat();
textStyle.font="Tahoma";
textStyle.color=0xFF0000;
textStyle.size=11;
tileList.setRendererStyle("textFormat", textStyle);
///////////////

}

public function initMediaPlayer(event:Event):void {
var myXML:XML=new XML(xmlLoader.data);
var item:XML;
for each (item in myXML.vid) {// populate playlist.
// Get thumbnail value and assign to cellrenderer.
var thumb:String;
if (item.hasOwnProperty("@thumb")>0) {
thumb=item.@thumb;
}// Send data to tileList.
tileList.addItem({label:item.attribute("desc").toXMLString(),str:item.attribute("contenu").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});

}
// Select the first video.
tileList.selectedIndex=0;
// Listen for item selection.
tileList.addEventListener(Event.CHANGE, listListener);
// And automatically load it into myVid.
myVid.source=tileList.selectedItem.data;
// Pause video until selected or played.
myVid.pause();

}

// Detect when new video is selected, and play it
function listListener(event:Event):void {
myVid.play(event.target.selectedItem.data);
////////////////////////////////////////////
var description:TextArea = new TextArea();
description.setSize(202,46);
description.move(365, 315);
description.text=tileList.selectedItem.str;
addChild(description);

}

}
}

how can i embed Flowplayer in this code?
Im really new with AS3 and Flowplayer,
help, please

zemen

Posts: 2

Registered:
Jun 18, 2010

» » Embedding Flowplayer in Flash

Posted: Jun 22, 2010

Reply to: » Embedding Flowplayer in Flash, from zemen
i know some website has the tutorial like:
http://flowplayer.org/documentation/developer/writing-flash-plugins.html
but it never tell me step by step, where to put the file, how to link to flash file, all not clear.

thank you for help

sgenevay

Posts: 3

Registered:
Jun 25, 2010

» » » Embedding Flowplayer in Flash

Posted: Jun 25, 2010

Reply to: » » Embedding Flowplayer in Flash, from zemen
Yes !!! same case here..... could anybody make a clear tuto to integrate the FP in flash ?
thx a lot

Danno

Posts: 19

Registered:
Jun 24, 2010

» » » » Embedding Flowplayer in Flash

Posted: Jun 26, 2010

Reply to: » » » Embedding Flowplayer in Flash, from sgenevay
Thomas has been helping me out starting on this very thing. There is some discussion on this forum link:
http://flowplayer.org/forum/1/10890#post-44115

I'm struggling through my attempt with a littany of really annoying things. The latest is a couple of references from Config.as and Controls.as to AutoHideConfig which is in a mystery org.flowplayer.ui package. Nothing in svn that I can find, at least in the flowplayer-core, flowplayer-plugins, flowplayer devkit. Many other unresolved issues about this on the forum already - possibly this stuff is inside a swc file somewhere but impossible to figure that out given the documentation.

The feeling is though, that if you can pull together the bits and pieces from the various packages into a flex (library) project, that you can then expose the necessary methods and properties to load, size, configure the player inside a flex/flash application. My feeling at this point is that I can probably do it, however because of the packaging flowplayer has based on html deployment, it would be painful to keep it aligned with future updates/releases. Probably a creative build script could accomplish it but that's not one of my strengths.

I'm gonna give it another day or so to see if I can get it building within FlashBuilder. I will respond on the other thread as to my status.

Anssi
Flowplayer Flash & video streaming developer

Posts: 1194

Registered:
Jul 24, 2007

» » » » » Embedding Flowplayer in Flash

Posted: Jul 28, 2011

Reply to: » » » » Embedding Flowplayer in Flash, from dannyv
The org.flowplayer.ui package stuff is here:

http://code.google.com/p/flowplayer-plugins/source/browse/#svn%2Fflash%2Fcommon%2Ftrunk

selwinpark
stationary design london

Posts: 1

Registered:
Nov 30, 2011

» » » » » » Embedding Flowplayer in Flash

Posted: Nov 30, 2011

Reply to: » » » » » Embedding Flowplayer in Flash, from Anssi
Hi Anssi,
It contains really awesome information and very nice stuff over here.. Thanks for sharing.

stationary design london