startimage for swf video - html

Hi I am trying to show startimage before my swf video starts playing, I am using flashVars to do this but for some reasons its not working, below is my code:
<object id="M97012085" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1440" height="900" style="overflow: auto; align:middle;" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">
<param name="movie" value="path_to_swf" />
<param name="loop" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<param name="play" value="true" />
<param name="flashVars" value="image=path_to_png" />
<embed bgcolor="#ffffff" align="middle" name="M97012085" loop="false" src="path_to_swf" width="1440" height="900" flashVars="image=path_to_png" style="overflow: auto; align:middle;" play="true" wmode="transparent" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Could you please point out what I am doing wrong ? Is it possible to have a image which user can click to start the video ? Thanks

Ravi, please use a swfobject to embed your flash files:
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = { 'image' : 'path-to.png' };
var params = { 'allowFullScreen' : 'true', 'wmode' : 'window' };
var attributes = { };
swfobject.embedSWF( 'index.swf, 'flashIndex', '100%', '100%', '10.1.0', 'swf/expressInstall.swf', flashvars, params, attributes );
</script>
More info: http://code.google.com/p/swfobject/
Then if you are using AS3.
before you initialize the video player, load image which was parsed to you by flashvars:
imageLoader = new Loader ();
imageLoader.contentLoaderInfo.addEventListener ( Event.COMPLETE, placeImageOnStage )
imageLoader.load ( new URLRequest ( loaderinfo.parameters.image ) ); // the flashvar parameter
after it is beeing loaded initialize your video.
function placeImageOnStage ( e : Event ) : void
{
addChild ( imageLoader.content ) // add your image to stage
enableVideoControls ();
prepearVideo ();
// or something else
}

What is the flash player you are using? Are you certain that startimage is a parameter that your specific player uses?

if your video is or can be an FLV file have a look at flowplayer. Specifically this page with a splash image example.

Related

How to load external variable into swf to play a different movie file using AS3

I'm an AS3 noobie and need some help.
I want to load a movie dependant on a variable. For example i want to load from
'http://example.com/test/'+variable+'.mp4'
So i decide this time i want to play x.mp4 - how do i do this in AS3?
This is what i have so far:
// ActionScript 3.0
var video:Video = new Video();
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = {onMetaData:ns_onMetaData, onCuePoint:ns_onCuePoint};
video.attachNetStream(ns);
ns.play("http://example.com/test/"+variable+".mp4");
function ns_onMetaData(item:Object):void {
trace("metaData");
// Resize video instance.
video.width = item.width;
video.height = item.height;
// Center video instance on Stage.
video.x = (stage.stageWidth - video.width) / 2;
video.y = (stage.stageHeight - video.height) / 2;
}
function ns_onCuePoint(item:Object):void {
trace("cuePoint");
trace(item.name + "\t" + item.time);
}
thanks for your help
You use FlashVars for that:
http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
Here's the code from the example. Notice that there are two different Flashvars entries:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
width="550"
height="400"
align="middle"
id="main">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="main.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="FlashVars" value="one=1&two=2" />
<embed src="main.swf"
width="550"
height="400"
autostart="false"
quality="high"
bgcolor="#ffffff"
FlashVars="one=1&two=2"
name="main"
align="middle"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
If you use swfobject (https://code.google.com/p/swfobject/) it has built in support for it.
EDIT:
A more simple example would be:
http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html
It contains an example for just 1 variable named "myVariable":
LoaderInfo(this.root.loaderInfo).parameters.myVariable;
The page also has a test project online.

as3 get FlashVars in flex 4

I want to get FlashVars in my html using action script,
the < OBJECT > tag in html like:
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="test.swf" width="550" height="400">
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="FlashVars" value="acc=3001&pwd=test">
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
and my action script is use as a model in flex that used by mxml, so I don't have movieclip or I cannot use this.loaderInfo.parameters;
or root since there isn't a displayObject.
Is there other method to grab the FlashVars value in as3,
or can I get FlashVars in mxml then let as3 get the variable such as:
var paramObj:Object = Application(FlexGlobals.topLevelApplication).parameters;
var test:String;
test = paramObj['acc'];
and in as3:
var getText:String = test;
Thanks in advance.
You will have access to the FlexGlobals anywhere in the application since the topLevelApplication is static type, it could be even in the AS file. So, instead of doing that in the MXML file, you could do that in the AS file itself
I use Application.application.parameters finally!
It is strange I use Flex 4.6 SDK but my Flex version is 2, so I cannot use FlexGlobals.
The result is similar to using FlexGlobals:
In your html:
<script type="text/javascript">
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
var swfVersionStr = "11.1.0";
// To use express install, set to playerProductInstall.swf, otherwise the empty string.
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
params.FlashVars = "acc=3001&pwd=test";
and import mx.core.Application;
then use the code in actionscript or mxml:
Application.application.parameters.acc;
and above result will be 3001.
I also try to add <param name="acc=3001&pwd=test"> but the actionscript cannot understand it( the result is undefined), I not sure why though.

actionscript full screen not allowed

This is my code to add the button onto stage
private function add_fullScreenBtn(height:Number):void
{
button_fullScr = new Sprite();
button_fullScr.useHandCursor = true;
button_fullScr.buttonMode = true;
button_fullScr.mouseChildren = false;
button_fullScr.x = height;
button_fullScr.y = btn_y;
var fullScr_Btn:Bitmap = new fullScreenImage();
button_fullScr.addChild(fullScr_Btn);
button_fullScr.addEventListener(MouseEvent.CLICK, fullScreenHandler);
addChild(button_fullScr);
}
This is the code for handling the event when the user clicks on fullscreen button
private function fullScreenHandler(event:MouseEvent):void
{
trace("Here");
// stage.displayState = StageDisplayState.FULL_SCREEN
if (this.stage.displayState== StageDisplayState.NORMAL) {
//stage.displayState="fullScreen";
this.stage.displayState=StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.NO_SCALE;
} else {
//stage.displayState="normal";
this.stage.displayState=StageDisplayState.NORMAL;
}
}
This is the code of html page
<html>
<head>This is the Test Page
</head>
<body>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://.../swflash.cab#version=9,0,0,0"
width="550" height="400" id="sample" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="sample.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#333333" />
<embed src="sample.swf" quality="high" bgcolor="#333333"
width="550" height="400"
name="sample" align="middle"
allowscriptaccess="sameDomain"
type="application/x-shockwave-flash"
allowFullScreen="true"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</embed>
</object>
</body>
</html>
When I am running this page I am getting error that full screen mode is not allowed. security exception. When I am tracing it on console its printing "here"
can anyone suggest how can i solve the error
I had to add the line to scale the image i.e i added the following line
stage.scaleMode = StageScaleMode.NO_SCALE;
before
stage.displayState = StageDisplayState.FULL_SCREEN;
and it worked

flash as3 player in IE

I am trying to create a simple audio flash player, that calls a js function on click, it works perfectly in all browsers, except IE. i cant figure out what seems to be the problem!
here is html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>player</title>
</head>
<body >
<![if !IE]>
<object type="application/x-shockwave-flash" classid="bla" width="18" height="30" id="myFlashMovie">
<param name="wmode" value="opaque" />
<param name="FlashVars" value="mp3.mp3" />
<embed type="application/x-shockwave-flash" width="18" height="30" src="player%2Eswf" id="flashObj" FlashVars="audioTrackPath=mp3%2Emp3" />
</object>
<![endif]>
<!--[if IE]>
<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf- 96b8-444553540000" width="18" height="30" id="movie" allowScriptAccess="sameDomain" >
<PARAM NAME="movie" id="movie" value="player%2Eswf?audioTrackPath=mp3%2Emp3"/>
<PARAM NAME="FlashVars" value="mp3%2Emp3" />
<PARAM NAME="allowScriptAccess" value="always" />
<![endif]-->
<script type="text/javascript">
alert("Hello World");
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
<script type="text/javascript">
function countdown() {
alert("countdown");
}
</script>
</body>
</html>
and here is as:
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
flash.system.Security.allowDomain("http://localhost");
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var audioTrackPath:String = String(paramObj['audioTrackPath']);
stop();
play_btn.addEventListener(MouseEvent.CLICK, playSound);
function playSound (e:MouseEvent):void{
try {
ExternalInterface.call("countdown");
} catch(e:Error) {
trace(e)
}
//ExternalInterface.call("countdown");
gotoAndStop(2);
var soundClip:Sound;
var soundChannel:SoundChannel = new SoundChannel();
function init() {
soundClip = new Sound();
soundClip.addEventListener(ProgressEvent.PROGRESS, soundLoading);
soundClip.addEventListener(Event.COMPLETE, soundLoaded);
var req:URLRequest = new URLRequest(audioTrackPath);
var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
soundClip.load(req,context);
//soundChannel = soundClip.play();
}
init();
function soundLoaded(e:Event) {
soundChannel = soundClip.play();
}
function soundLoading(e:ProgressEvent) {
// preloader information goes here
trace(String(int(100*e.bytesLoaded / e.bytesTotal))+"%");
}
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound (e:MouseEvent):void{
gotoAndStop(1);
soundChannel.stop();
}
}
I have been Googling for 3 days now, but I can't seem to find an answer...
You should have stated that the issue is ExternalInterface.call() not working in the first place.
Build a simple project with just external interface call like
if(ExterlInterface.available){
ExternalInterface.call('alert','ExterlInterface.available');
}
on the first frame (if you are using flash) and publish it
it will give you following html
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ei</title>
</head>
<body bgcolor="#ffffff">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="550" height="400" id="ei" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="ei.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="ei.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="ei" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
</object>
</body>
</html>
If that fails, then it's your browser causing trouble, works fine for me.
If it is working then your html is bad.
Seems like you are missing movie parameter in object definition. Different browsers use different tags from which they pick up flash information - some use embed, some use object.
try this html
<object type="application/x-shockwave-flash" classid="bla" width="18" height="30" id="myFlashMovie">
<param name="movie" value="player.swf">
<param name="wmode" value="opaque" />
<param name="FlashVars" value="mp3.mp3" />
<embed type="application/x-shockwave-flash" width="18" height="30" src="player.swf" id="flashObj" FlashVars="audioTrackPath=mp3.mp3" />
</object>
i would also put the file reference directly in to the url
<param name="movie" value="player.swf?audioTrackPath=mp3.mp3">
Replace this:
<param name="FlashVars" value="mp3.mp3" />
With this:
<param name="FlashVars" value="audioTrackPath=mp3.mp3" />
FlashVars are name-value pairs.
Ognjen, don't take this the wrong way, but as an advice, instead of "googleing for 3 days", next time you could put some of that effort into proofreading the code.
looks like you should change your classid from bla to clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
also check my similar opensource project (which, however doesn't work in IE 6, but fine in newer versions)

jwPlayer in IE does not auto start video on display of rolling banner

I got a probleme with the famous jwPlayer. In fact the probleme is with the way IE (8 or 7) handle the flash player.
Their's the probleme: I got a rolling banner (using jquery cycle), in this banner i got 2 images an a video. The video is drive using jwPlayer. The way I expect the banner work is this:
roll on each banner
if the banner is the video start it.
This is the javascript:
$('#slideshow')
.before('<div id="nav">')
.cycle({
fx: 'fade',
timeoutFn: calculateTimeout,
timeout: 20000,
pause: 1,
pager: '#nav'
});
function calculateTimeout(currElement, nextElement, opts, isForward) {
if ($(nextElement).attr("class") == "video-banner") {
return 20000;
} else {
return 8000;
}
I have set the loop variable at true and the autostart at true either as you can see:
<div runat="server" id="video" class="video-banner">
<!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
<object id="Object1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" height="384" type="video/mp4">
<param name="movie" value="/uploads/Banner/Rainmaker.mp4" />
<param name="wmode" value="window" />
<param name="allowfullscreen" value="false" />
<param name="allowscriptaccess" value="always" />
<param name="loop" value="true" />
<param name="flashvars" value="file=/uploads/Banner/Durp.mp4&autostart=true" />
<embed
type="application/x-shockwave-flash"
id="player2"
name="player2"
src="/jwplayer/player.swf"
width="612"
height="384"
allowscriptaccess="always"
allowfullscreen="false"
autostart="true"
wmode="window"
loop="true"
flashvars="file=/uploads/Banner/Durp.mp4&autostart=true&amp"
/>
</object>
<!-- END OF THE PLAYER EMBEDDING -->
<img style="border-width: 0px;" src="/Uploads/Banner/banner.jpg">
</div>
In all normal browser, when the video come in the banner he start by himself.
Can someone help me to me make me doing the same behavior in IE (7 and 8) as in normal browser?
You should try FlowPlayer
Here is the website: http://flowplayer.org/