HTML pass parameter from url to Embed flash object - html

I would like to get FilePath parameter from url example:
http://www.example.com/index.html?FilePath=LetsGo
browsing this will pass it to html flash player script ("LetsGo" will play instead of "autoload"):
<html>
<body><.......
<object classid="123456...." codebase="http://123457" id="test" height="300" align="middle" width="300">
<param name="allowFullScreen" value="true">
<param name="movie" value="123.swf">
<param name="FlashVars" value="MP3=autoload.mp3&JPG=autoload.jpg&repeats=200">
<embed src="123.swf" allowfullscreen="true" name="MP3JPG" flashvars="MP3=autoload.mp3&JPG=autoload.jpg&repeats=200" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="300" align="middle" width="300">
</object><......
</html>
How can i do that currectly?
Many thanks,
Bentzy.

An elegant way to get your URL parameters is to use jQuery URL Parser, here you can get this utility.
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/allmarkedup/jQuery-URL-Parser/master/purl.js"></script>
<script>
$(document).ready(function(){
var filePath = $.url().param('FilePath');
//cool!
alert(filePath);
var flashObjectHtml = "<object classid='clsid:d27...' codebase='http://...' id='test' height='300' align='middle' width='300'> \
<param name='allowFullScreen' value='true'> \
<param name='movie' value='123.swf'> \
<param name='FlashVars' value='MP3=" + filePath + "&JPG=autoload.jpg&repeats=200'> \
<embed src='123.swf' allowfullscreen='true' name='MP3JPG' flashvars='MP3=" + filePath + "&JPG=autoload.jpg&repeats=200' \
type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' height='300' \
align='middle' width='300'> \
</object>";
$('#flash_wrapper').html(flashObjectHtml);
});
</script>
</head>
<body>
<div id="flash_wrapper"></div>
</body>
</html>
EDIT
Copy the above script, save and call it this way in your browser:
[the_path_where_you_saved_this_file]/some_name.htm?FilePath=some_path
An important point: these URL parameters are case sensitive, so FilePath != filepath != filePath

Related

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)

FLV Player not works in IE Browser?

I have the following piece of code which play the flv file,
<embed align="middle" width="185" height="121"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="sameDomain"
name="vidplayer" bgcolor="#eae7db" quality="high" f
lashvars="file=<?= $vUrl; ?>" src="scripts/flvplayer.swf" />
Above code which works only in FF,chrome not in IE Browser.
Also i refered link How to embed a SWF file in an HTML page? changed the above code like below,
<object width="185" height="121">
<param name="movie" value="<?php echo BASE_URL; ?>scripts/flvplayer.swf">
<embed align="middle" width="185" height="121"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="sameDomain" name="vidplayer" bgcolor="#eae7db"
quality="high" flashvars="file=<?= $vUrl; ?>"
src="scripts/flvplayer.swf" >
</embed>
</object>
This above code works only in FF not in Chrome and IE.
How can i play my flv file in all browsers ?
Try this way.
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
flashvars.mp3="mast.mp3";
var so = new swfobject.embedSWF("player.swf", "myContent", "300", "120", "9.0.0",true, flashvars, params, attributes);
so.write("myContent");
</script>
and have a look at this Documentation.

Automatically open URL after my media player avi file finishes

I want to automatically open URL on the same page after my media player avi file finish
and here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WELCOME TO LOTUS TENDA WEBSITE</title>
</head>
<body bgcolor="#000000">
<br><br>
<table border="0" align=center>
<tr>
<td>
<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows® Media Player components..." type="application/x-oleobject" width="890" height="500">
<param name="fileName" value="intro.avi">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="false">
<param name="Volume" value="-450">
<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="intro.avi"
name="MediaPlayer1" width=890 height=500 autostart=1 showcontrols=0 volume=-450>
</object>
</td>
</tr>
</table>
</body>
</html>
This can be done with JavaScript by sampling the PlayState property of the object. From quick test that I conducted, it will be 2 before the video started playing, 3 while it's playing and 0 when the video finished playing.
Add this inside your <head> section:
<script type="text/javascript">
window.onload = function() {
var oVid = document.getElementById("MediaPlayer1");
window.setTimeout(function CheckVidState() {
if (oVid.PlayState == 0) {
document.location = "OtherPage.html";
return true;
}
window.setTimeout(CheckVidState, 10);
return false;
}, 10);
};
</script>
This will redirect the user to OtherPage.html when the video finished playing.
setInterval(function () {
if ($("MediaPlayer1")[0].playState == 1) {
$("MediaPlayer1")[0].URL = "nextVideo.wmv";
}
}, 100);

startimage for swf video

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.

How to go fullscreen in Flash?

I would like to create a button that makes my flash fullscreen.
But this line:
stage.displayState = StageDisplayState.FULL_SCREEN;
... does not work. Why?
(I'm opening my swf directly in Chrome.)
Edit:
There seem to be consensus that I should embed in HTML.
Can somebody provide a snippet?
I would go for SWFObject as it works fine for every browsers. Check this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Go Fullscreen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var fo = new Object();
function initFlash()
{
fo.flashvars = {};
fo.params = {
allowScriptAccess: "always",
allowFullScreen: "true"
};
fo.attributes = {};
swfobject.embedSWF("swf/FlashFile.swf", "flashcontent", "100%", "100%", "10", "swf/expressInstall.swf", fo.flashvars, fo.params, fo.attributes);
}
</script>
</head>
<body>
<div id="flashcontent"></div>
<script type="text/javascript">
initFlash();
</script>
</body>
</html>
You can download the swfobject javascript file and expressinstall swiff here:
http://code.google.com/p/swfobject/downloads/detail?name=swfobject_2_2.zip&can=2&q=
Good luck,
Rob
In the generated html there should be a variable/parameter "allowFullScreen". You need to set this to true.
From http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0"
width="600" height="400" id="fullscreen" align="middle">
<param name="allowFullScreen" value="true" />
<param name="movie" value="fullscreen.swf" />
<param name="bgcolor" value="#333333" />
<embed src="fullscreen.swf" allowFullScreen="true" bgcolor="#333333" width="600" height="400"
name="fullscreen" align="middle" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>