Saturday, 26 June 2010
Compile FlowPlayer and add a simple button tutorial
First of you need to have the following:
ANT: http://ant.apache.org/bindownload.cgi
Flex SDK: http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3 (download the latest 3.+ build)
Java SDK: http://developers.sun.com/downloads/ (or google "java SDK")
now you need to place all of them in a folder and extract
Next step is to add those as environmental variables, at PATH(if it doesn't exist create it) add all the paths to the SDK bin folders separated by ;
to verify each installation go to command prompt and type:
ant -version
mxmlc -version
javac -version
if you see results to all 3 you're good to go.
COMPILING CONTROLS SOURCE CODE (without any changes for now)
You need the flowplayer.devkit, and the controls plugin, as well as the flowplayer source code witch contains an example to test your builds.
All of these are provided by the flowplayer website, it might take a while searching for them but its worth it.
once you download all, extract them, and place the plugins.controls folder inside the flowplayer.devkit/flowplayer.devkit folder
next you'll need to checkout some code from the svn, I use toirtoise svn: http://tortoisesvn.net/downloads once you install go to the above folder and check out:
http://flowplayer-plugins.googlecode.com/svn/flash/common/trunk/
http://flowplayer-plugins.googlecode.com/svn/flash/controls/trunk/ (if you don't have flowplayer.controls yet).
Now on to the configuration (we're getting there soon...)
go to the devkit folder which contains "plugin-build.properties"
# you need to adjust following to point to your Flex SDK
flex3dir=C:/SDK/flex_sdk_3.5.0.12683
# change this if you want the compiled plugin to be copied to some dir
deploy_dir=C:/SDK/TEST
# change following to point to .exe files when running on Windows
mxmlc_bin= ${flex3bindir}/mxmlc.exe
compc_bin= ${flex3bindir}/compc.exe
asdoc_bin= {flex3bindir}/asdoc.exe
# following can usually be left as they are
flex3bindir=${flex3dir}/bin
flex3libsdir=${flex3dir}/frameworks/libs
flashplayer_bin=
framerate=31
bgcolor=0xFFFFFF
width=500
height=350
next we go to the flowplayer.controls folder and edit the "build.xml" and change the following code block:
<!-- location of the skin swd, anc swc -->
<property name="library-path" value="src/flash/air" />
<property name="extra-sources" value="../common/src/actionscript" />
<property file="../plugin-build.properties" />
<import file="../plugin-build.xml"/>
<property name="flowplayer_lib" value="../flowplayer.swc" />
<property name="plugin-binary" value="${basename}.swf" />
<property name="plugin-binary-versioned" value="${basename}-${version}.swf" />
<property name="plugin-main-class" value="org/flowplayer/controls/Controls.as" />
<property name="compiler-define" value="CONFIG::skin,'true' -define=CONFIG::hasSlowMotion,'false'" />
on a side note if you want to compile the tube skin, it usually is missing the dragger component, so you'll need to recompile the tube.fla adding the dragger icon.
go to command prompt and navigate to the flowplayer.controls folder, and type "ant" you should see some text and finaly "BUILD SUCCESSFUL" if not go up and try to identify the error, usually it tells you which line to look and which file.
Adding a button to the flowPlayer with ActionScript:
First of you'll need to create the graphic for the button: go to Flash Professional and open one of the sample .fla in the flowplayer.controls/src/flash
add a new symbol and draw you graphic or simply add a picture (make sure the dimensions match the other graphics) name it and save it as a movieClip of the class fp.buttonName in the Skin Classes tree
now create the same graphic and save it as symbol with the name buttoNameIcon in the Symbols tree.
now export your build as a movie .swf and replace the old .swf
Now... some coding much occur...but fear not!
the files we are going to edit are:
Controls.as
SkinClasses.as
Tooltips.as
WidgetBooleanStates.as
and we will create the buttonName.as
first we create the class for our button, for showcase reasons I used a button named "gBtn" which when clicked opens a browser in the google home page (my idea of a Hello World)
package org.flowplayer.controls.button {
import flash.display.DisplayObjectContainer;
import org.flowplayer.controls.config.Config;
import org.flowplayer.controls.button.AbstractButton;
import org.flowplayer.view.AnimationEngine;
/**
* @author api
*/
public class gBtn extends AbstractButton {
public function gBtn(config:Config, animationEngine:AnimationEngine) {
super(config, animationEngine);
}
override public function get name():String {
return "google";
}
override protected function createFace():DisplayObjectContainer {
return SkinClasses.getgBtn();
}
override protected function get tooltipLabel():String {
return config.tooltips.gBtn;
}
}
}
now lets change some source code!
SkinClasses.as:
private var gbtn:fp.gBtn; //buttonName for you if you havent named your button "gBtn" too...
public static function getgBtn():DisplayObjectContainer{
return getDisplayObject("fp.gBtn") as DisplayObjectContainer;} //at the end of the file
Controls.as:
import org.flowplayer.controls.button.gBtn;
//at createChildren add:
_gBtn = addChildWidget(createWidget(_gBtn,"google",gBtn,_config,animationEngine),ButtonEvent.CLICK,goToUrl);
//launcher
//gbutton implementation
private function goToUrl(evt:ButtonEvent):void{
navigateToURL(new URLRequest ("http://www.google.com"),"_blank");
}
//at lastOnRight function add:
if (_gBtn) return _gBtn; //first, yes we are adding it at the right place of the controlBar
//finally at arrageRightEdgeControls(leftEdge:Number) edit:
rightControls = [_gBtn,_fullScreenButton, _volumeSlider, _muteVolumeButton, _timeView];
ToolTips.as
private var _gBtn:String = "google";
public function get gBtn():String{
return label(_gBtn);}
public function set gBtn(gBtn:String):void{
_gBtn = gBtn;}
WidgetBooleanStates.as
private var _properties:Array = ["play", "stop", "mute", "volume", "time", "scrubber", "playlist", "slowBackward", "fastBackward", "slowForward", "fastForward" , "fullscreen","google"];
public function set google(google:Boolean):void {
_values["google"] = google;
}
[Value]
public function get google():Boolean {
return value("google",true);
}
now you're good to go! Recompile the code as you did before and place the producted .swf flowplayer.controls-3.2.1-dev.swf (name it:flowplayer.controls-3.2.1.swf) and replace the existing on the example.
you might also want to enable all controls to see your new button, or simple enable it:
<script>
flowplayer("player", "../flowplayer-3.2.2.swf",
{
plugins:{
controls:
{
gBtn:true
}
}
});
I hope this will clear some things about the flowplayer which is an awesome player idd.
(if you notice any typos or general mistakes please let me know)
have fun!
Subscribe to:
Post Comments (Atom)
17 comments:
Hi
Was trying to follow this tutorial, did everything exactly the same.
Added on Controls.as
private var _gBtn:DisplayObject;// or _gBtn:gBtn;
everything compiled but when adding as a plugin, it wont load.
controls:{ url:"flowplayer.controls-3.2.1.swf",
gBtn:true
},
Did i miss something?
Great tutorial if it works.
Thanks
the way to add as a plugin is the following:
flowplayer("player", "../flowplayer-3.2.2.swf",{plugins:{controls:{gBtn:true}}});
it gets kinda complicated with the multiple {} i know. give it a try like this. Let me know if you need any more help.
I got this working.
First of all the class name should be in capital.
GBtn.as
package org.flowplayer.controls.button {
import flash.display.DisplayObjectContainer;
import org.flowplayer.controls.config.Config;
import org.flowplayer.controls.button.AbstractButton;
import org.flowplayer.view.AnimationEngine;
public class GBtn extends AbstractButton {
public function GBtn(config:Config, animationEngine:AnimationEngine) {
super(config, animationEngine);
}
override public function get name():String {
return "bitrates";
}
override protected function createFace():DisplayObjectContainer {
return SkinClasses.getGBtn();
}
override protected function get tooltipLabel():String {
return config.tooltips.gBtn;
}
}
}
Thank you so much...
This is the only tutorial that i found and works..
Now i just need to make figure out how to play different bitrates upon clicking this button. :-)
Can you may be upload a zip-file with the complete source you are using?
That would help a lot. Thanks and cheers,
elbjoern
Ok then here it is, you can find a working example here: http://www.netgfx.com/testing/player/
(with viral controls and custom skin)
and the source files here:
http://www.netgfx.com/testing/player/flowplayer.devkit-3.2.0-FINAL.rar
and Release Files here:
http://www.netgfx.com/testing/player/releaseFiles.rar
Thanks, that was pretty fast.
Unfortunately I thought that it would compile the flowplayer.swf as well. But it is not right? Do you know how I can do that?
Cheers,
elbjoern
If you unzip the source files in a folder and then open command prompt or terminal, navigate to that folder into the flowplayer.controls folder and run "ant" command it will compile.
Unzip the source and follow the tutorial ;)
I did that and as you can see it is compiling the flowplayer.controls.swf but not the flowplayer.swf / the player itself.
C:\flowplayer.devkit\flowplayer.controls>ant
Buildfile: C:\flowplayer.devkit\flowplayer.controls\build.xml
build:
[echo] ++ flowplayer.controls.swf +++
[echo]
prepare:
[unzip] Expanding: C:\flowplayer.devkit\flowplayer.swc into C:\flowplayer.de
vkit\flowplayer.controls\build
compile:
[echo] compiling with src/flash/air
[echo] compiling with -define=CONFIG::skin,'true' -define=CONFIG::hasSlowM
otion,'false'
[exec] Loading configuration file C:\flex_sdk\frameworks\flex-config.xml
[exec] Failed to match the compile target with C:\flowplayer.devkit\flowpla
yer.controls\build\flowplayer.controls.swf.cache. The cache file will not be reu
sed.
[exec] C:\flowplayer.devkit\flowplayer.controls\build\flowplayer.controls.s
wf (37871 bytes)
[copy] Copying 1 file to C:\flowplayer.devkit\flowplayer.controls\build
deploy:
_deploy:
[echo] deploying plugin to C:/flex_sdk/DEPLOY
[copy] Copying 1 file to C:\flex_sdk\DEPLOY\build
[copy] Copying 1 file to C:\flex_sdk\DEPLOY\build
[copy] Copying 1 file to C:\flex_sdk\DEPLOY\dist
BUILD SUCCESSFUL
Total time: 4 seconds
Is that possible?
oh so you want to compile the core .swf...
well i think it is possible ofc but you might wanna take a look at flowplayer.devkit i think it is there or at the core .zip file. I just played with the default for my examples, and only did modifications to the plugins.
Hi,
I don't know if you'd be able to help me, but I've been following your tutorial and I've been trying to extend the functionality by calling a javascript function with your button. Using your code, I changed the goToURL function to the following
private function goToUrl(evt:ButtonEvent):void{
navigateToURL(new URLRequest ("http://www.twitter.com"),"_blank");
navigateToURL(new URLRequest ("javascript:makeBookmark();"),"_self");
navigateToURL(new URLRequest ("http://www.facebook.com"),"_blank");
}
The result is that I open twitter in a new window, and nothing else happens. I'm not sure what I'm doing wrong but the command to open facebook never executes, so is there something wrong with my call to javascript?
Well I suppose that the Javascript function never executes and thus the code halts at that point, probably if you have the flash debug version you'll also see an error pop-up.
What you could do is execute the javascript through the ExtenalInterface class as follows:
ExternalInterface.call("makeBookmark");
You must import the ExternalInterface in the class that you are working on though.
Hope it helps :)
You are my hero
Hi,
i was trying to compile flowplayer.swf and the menu plugin as well. But i couldn't make the build successfully as im getting the following error,
BUILD FAILED
C:\Users\arun\Desktop\Eram\flow-player\flash-master\core\build.xml:235: The foll
owing error occurred while executing this line:
C:\Users\arun\Desktop\Eram\flow-player\flash-master\core\build.xml:242: Execute
failed: java.io.IOException: Cannot run program "C:\Program Files (x86)\Adobe\Ad
obe Flash Builder 4.5\sdks\4.5.0 \bin\compc": CreateProcess error=2, The system
cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:862)
.............
.......
Can anyone help me on this ?
And would be appreciated if guide me how to build the menu plugin with its source code.
Thanks in Advance
Arun
Have you tried to check if those files are where they were supposed to be?
ProcessBuilder.java for example, or if all the needed files are placed correctly.
Hi
thanks for the reply.
Now i am able to run the build.xml for menu.swf. But still i am getting following error,
uild:
[echo] ++ flowplayer.menu.swf +++
[echo]
repare:
[unzip] Expanding: C:\Users\arun\Desktop\Eram\flow-player\flash-master\core\
uild\flowplayer.swc into C:\Users\arun\Desktop\Eram\flow-player\flash-master\pl
gins\menu\build
ompile:
[echo] compiling with src/flash ../../lib/common/src/flash ../content/src/
ctionscript
[echo] compiling with
UILD FAILED
:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
18: The following error occurred while executing this line:
:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
2: The following error occurred while executing this line:
:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
09: The following error occurred while executing this line:
:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
4: Execute failed: java.io.IOException: Cannot run program "C:Program Files (x8
)AdobeAdobe Flash Builder 4.5sdks4.5.0\bin\mxmlc.exe": CreateProcess error=2, T
e system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
te.java:862)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
.........
.........
could you please help
Thanks,
Arun
Hi,
Can anyone help me on building menu plugin swf form the source code available on flow player site? I was getting an error as follows,
compile:
[echo] compiling with src/flash ../../lib/common/src/flash ../content/src/
actionscript
[echo] compiling with
BUILD FAILED
C:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
220: The following error occurred while executing this line:
C:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
32: The following error occurred while executing this line:
C:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
210: The following error occurred while executing this line:
C:\Users\arun\Desktop\Eram\flow-player\flash-master\lib\devkit\plugin-build.xml:
85: Execute failed: java.io.IOException: Cannot run program ""C:\Usersarun\Downl
oads\flex_sdk_4.5.1.21328A_mpl"\bin\mxmlc.exe": CreateProcess error=2, The syste
m cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:862)
........
......
And can anyone help me on the lib path configuring in the build.xml which is located in side menu (plugin ) folder ?
here is the line :
is this correct? because i couldn't find any such folders there inside.
Please guid me on this if anyone had compiled the same before.
thanks,
Arun
Guys,
Do we have a head start like this for the latest version of the player? i see loads of the code has been changed and some of the methods mentioned in this blog are not there anymore in those respective classes
Post a Comment