Flash External Interface issue with Firefox - javascript

I am having a hard time getting ExternalInterface to work on Firefox. I am trying to call a AS3 function from javascript. The SWF is setup with the right callbacks and it is working in IE.
I am using AC_RunActiveContent.js to embed the swf into my page. However, I have modified it to add an ID to the Object / Embed Tags. Below are object and embed tag that are generated for IE and for Firefox respectively.
<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="400" align="middle" id="jpeg_encoder2" name="jpeg_encoder3" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >
<param name="movie" value="/jpeg_encoder/jpeg_encoder3.swf" />
<param name="quality" value="high" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="scale" value="showall" />
<param name="wmode" value="window" />
<param name="devicefont" value="false" />
<param name="bgcolor" value="#ffffff" />
<param name="menu" value="false" />
<param name="allowFullScreen" value="false" />
<param name="allowScriptAccess" value="always" />
</object>
<embed
width="400"
height="400"
src="/jpeg_encoder/jpeg_encoder3.swf"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
align="middle"
play="true"
loop="true"
scale="showall"
wmode="window"
devicefont="false"
id="jpeg_encoder2"
bgcolor="#ffffff"
name="jpeg_encoder3"
menu="false"
allowFullScreen="false"
allowScriptAccess="always"
type="application/x-shockwave-flash" >
</embed>
I am calling the function like this...
<script>
try {
document.getElementById('jpeg_encoder2').processImage(z);
} catch (e) { alert(e.message); }
</script>
In Firefox, I get an error saying "document.getElementById("jpeg_encoder2").processImage is not a function"
Any Ideas?

Hmm, did you expose your actionscript function to Javascript with addCallback ?
Adobe documentation on addCallback

Below is an example of how a Flash movie is placed within a html page. This movie is very simple movie with a stop action at the beginning. The movie is shown below under Test Runs subject. This particular html code was auto generated by FlashMX's Publish command. Notice that the Flash movie file is simplemovie.swf; and an id and a name have been assigned automatically by Flash to match the movie filename (minus the .swf extension). In reality, the name and id could be anything (but do not use exoteric names, especially, do not start with a number), as long as it has not been used by any other element in the same page.
`codebase="http://download.macromedia.com/pub/shockwave/cabs/flash`/swflash.cab#version=6,0,0,0"
` WIDTH="150" HEIGHT="75" id="simplemovie" ALIGN="">
` quality=medium
` swliveconnect="true"
` bgcolor=#FFFFFF WIDTH="150" HEIGHT="75"
` name="simplemovie"
` ALIGN=""
`TYPE="application/x-shockwave-flash"
` PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
there is a play function in the flash file the following function will calls that function:
function testEval(stringToEval)
{
var movie=eval(stringToEval);
if (movie)
{
if (movie.PercentLoaded())
{
if (movie.PercentLoaded()==100)
{
movie.Play();
}
else
{
alert("movie is still loading, try again soon");
}
}
else
{
alert("movie object found-but unable to send command");
}
}
else
{
alert("movie object not found");
}
}

See this post.
You want a JS function more like this to retrieve the Flash object (rather than getElemById):
function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
};
And make sure not to call this function until the document is loaded.

Try having the same id in both object and embed tags. I remember one browser is using one tag and another browser the other...don't know which one is which. I had the same issue some time ago.
I'm got around by modifying the Example Code that comes with flash. Making sure it works, then stripping it down and adapting it for my use.
In the example notice that the object tag the id set to "ExternalInterfaceExample", then the embed tag has the name parameter set to "ExternalInterfaceExample" as well. I think that might be your clue.
Good luck!

Are your swf's visible (on the page) before you try calling them? If not, read this: swf-not-initializing-until-visible

Try these two things:
First, try calling the function from Javascript like this:
var swf;
if(navigator.appName.indexOf("Microsoft") != -1) {
swf = window["jpeg_encoder2"];
} else {
swf = document["jpeg_encoder2"];
}
if(typeof(swf) == "undefined") swf = document.getElementById("jpeg_encoder2");
swf.processImage(z);
Second, I've found that ExternalInterface calls in Firefox seem to only work with embed tags, not object tags. See if you can get it to work if you just use an embed tag. (Right now, I'm not clear whether the HTML/Javascript combo you've posted will access the object or the embed element.)

If instead of using AC_RunActiveContent.js to embed your flash movie you use swfobject there is a easy build-in way of doing that.
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
try {
swfobject.getObjectById('jpeg_encoder2').processImage(z);
} catch (e) { alert(e.message); }
</script>
</head>
If you are not using swfObject you could just copy and paste swfobject.getObjectById straight in to your code:
<script type="text/javascript">
function getObjectById(objectIdStr) {
var r = null;
var o = getElementById(objectIdStr);
if (o && o.nodeName == "OBJECT") {
if (typeof o.SetVariable != UNDEF) {
r = o;
}
else {
var n = o.getElementsByTagName(OBJECT)[0];
if (n) {
r = n;
}
}
}
return r;
getObjectById('jpeg_encoder2').processImage(z); //call your method
</script>

Related

Get attribute of embed element and changes values in flashvars Javascript?

How can I get the value of flashvars attribute?
<embed src="http://wl2static.lsl.com/common/flash/as3/MemberApplet026.swf"
id="opera_elb" width="100%"
height="100%"
allowscriptaccess="always"
allowfullscreen="true"
bgcolor="ffe8ef"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash"
flashvars="muteaudio=0&ishd=1&ishq=0&twoway=0&proxyip=">
I am using getElementsByTagName to get the element.
var Em = content.document.getElementsByTagName('embed');
And replace values in flashvars
<script>
function myFunction()
{
var Em = content.document.getElementsByTagName('embed');
var str = Em[0].getAttribute('flashvars').innerHTML;
var res = str.replace("muteaudio=0","muteaudio=1");
document.getElementsByTagName("embed").innerHTML=res;
}
</script>
But when I try error: Uncaught ReferenceError: content is not defined
please help me.
Okay so here is a solution (strictly to change the attribute of flashvars!). First I think you have a few syntax errors within your JS. So I modified it and here is the JS:
function myFunction()
{
var Em = document.getElementById('vid');
var str = Em.getAttribute('flashvars');
var contentSpot = document.getElementById("he");
contentSpot.innerHTML = Em.getAttribute('flashvars');
Em.setAttribute('flashvars', 'muteaudio=1')
// contentSpot.innerHTML = Em.getAttribute('flashvars');/* I used this to see if the change occurred.*/
}
window.onload = myFunction();
So contentSpot is a div element I created to observe the change.
the html is here:
<embed id="vid" src="http://wl2static.lsl.com/common/flash/as3/MemberApplet026.swf"
id="opera_elb" width="100%"
height="100%"
allowscriptaccess="always"
allowfullscreen="true"
bgcolor="ffe8ef"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash"
flashvars="muteaudio=0&ishd=1&ishq=0&twoway=0&proxyip=">
<div id="he"> Hello</div> <!-- The created div to observe -->
Okay so here is my suggestion:
1)pop in the cleaned up code into a jsfiddle, then observe the content.
2)Then remove the line: contentSpot.innerHTML = Em.getAttribute('flashvars'); above the code: Em.setAttribute('flashvars', 'muteaudio=1').
3) remove comments slashes and then hit ctrl + enter to observe the attribute change.
*really watch your "."/DOM syntax and case sensitivity.
Hope this helps you out!

Embedding VLC plugin on HTML page

I have a html file (getStream.html) that takes a stream from a certain url and show it. The code is the following:
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Vids</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body onload='player("http://mystreamaddress:8080");'>
<div id="player">
<object type="application/x-vlc-plugin"
id="vlcplayer"
width="864px"
height="540px"
classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921">
<param name="Volume" value="100" />
<param name="AutoPlay" value="true" />
<param name="AutoLoop" value="false" />
</object>
</div>
<div id="controls">
<input type="button" onclick="play();" value="Play" />
<input type="button" onclick="pause();" value="Pause" />
<input type="button" onclick="stop();" value="Stop" />
<input type="button" onclick="mute();" value="Mute" />
</div>
<script type="text/javascript" language="javascript">
var vlc = document.getElementById("vlcplayer");
function player(vid) {
try {
var options = new Array(":aspect-ratio=16:10", "--rtsp-tcp", ":no-video-title-show");
var id = vlc.playlist.add(vid,'Video',options);
vlc.playlist.playItem(id);
vlc.video.fullscreen = true;
//vlc.video.toggleFullscreen();
}
catch (ex) {
alert(ex);
}
}
function mute(){
vlc.audio.toggleMute();
}
function play(){
vlc.playlist.play();
}
function stop(){
vlc.playlist.stop();
}
function pause(){
vlc.playlist.togglePause();
}
function fullscreen(){
vlc.video.toggleFullscreen();
}
</script>
</body>
</html>
If I have this page on my pc and I try open it (using IE 7/8/9), all works good, but If put this page on my server, and then I access to it from a url like this: http://myserver/direcortyOfMyhtmlFile/getStream.html
the page is opened and the buttons are loaded, but I obtain the following error:
in IE8 and IE9:
That in english should be something like: "Impossible obtain the value of property 'add': object null or not defined"
In IE7:
These errors seems to refer to object in my html, but this is strange for me, because the same page works without problem locally.
test.html is will be helpful for how to use VLC WebAPI.
test.html is located in the directory where VLC was installed.
e.g. C:\Program Files (x86)\VideoLAN\VLC\sdk\activex\test.html
The following code is a quote from the test.html.
HTML:
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" width="640" height="360" id="vlc" events="True">
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
<param name="toolbar" value="true" />
<param name="StartTime" value="0" />
<EMBED pluginspage="http://www.videolan.org"
type="application/x-vlc-plugin"
version="VideoLAN.VLCPlugin.2"
width="640"
height="360"
toolbar="true"
loop="false"
text="Waiting for video"
name="vlc">
</EMBED>
</object>
JavaScript:
You can get vlc object from getVLC().
It works on IE 10 and Chrome.
function getVLC(name)
{
if (window.document[name])
{
return window.document[name];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[name])
return document.embeds[name];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(name);
}
}
var vlc = getVLC("vlc");
// do something.
// e.g. vlc.playlist.play();
I found this:
<embed type="application/x-vlc-plugin"
pluginspage="http://www.videolan.org"version="VideoLAN.VLCPlugin.2" width="100%"
height="100%" id="vlc" loop="yes"autoplay="yes" target="http://10.1.2.201:8000/"></embed>
I don't see that in your code anywhere.... I think that's all you need and the target would be the location of your video...
and here is more info on the vlc plugin:
http://wiki.videolan.org/Documentation%3aWebPlugin#Input_object
Another thing to check is that the address for the video file is correct....
Unfortunately, IE and VLC don't really work right now... I found this on the vlc forums:
VLC included activex support up until version 0.8.6, I believe. At that time, you could
access a cab on the videolan and therefore 'automatic' installation into IE and Firefox
family browsers was fine. Thereafter support for activex seemed to stop; no cab, no
activex component.
VLC 1.0.* once again contains activex support, and that's brilliant. A good decision in
my opinion. What's lacking is a cab installer for the latest version.
This basically means that even if you found a way to make it work, anyone trying to view the video on your site in IE would have to download and install the entire VLC player program to have it work in IE, and users probably don't want to do that. I can't get your code to work in firefox or IE8 on my boyfriends computer, although I might not have been putting the video address in properly... I get some message about no video output...
I'll take a guess and say it probably works for you locally because you have VLC installed, but your server doesn't. Unfortunately you'll probably have to use Windows media player or something similar (Microsoft is great at forcing people to use their stuff!)
And if you're wondering, it appears that the reason there is no cab file is because of the cost of having an active-x control signed.
It's rather simple to have your page use VLC for firefox and chrome users, and Windows Media Player for IE users, if that would work for you.
I found this piece of code somewhere in the web.
Maybe it helps you and I give you an update so far I accomodated it for the same purpose... Maybe I don't.... who the futt knows... with all the nogodders and dobedders in here :-/
function runVLC(target, stream)
{
var support=true
var addr='rtsp://' + window.location.hostname + stream
if ($.browser.msie){
$(target).html('<object type = "application/x-vlc-plugin"' + 'version =
"VideoLAN.VLCPlugin.2"' + 'classid = "clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"' +
'events = "true"' + 'id = "vlc"></object>')
}
else if ($.browser.mozilla || $.browser.webkit){
$(target).html('<embed type = "application/x-vlc-plugin"' + 'class="vlc_plugin"' +
'pluginspage="http://www.videolan.org"' + 'version="VideoLAN.VLCPlugin.2" ' +
'width="660" height="372"' +
'id="vlc"' + 'autoplay="true"' + 'allowfullscreen="false"' + 'windowless="true"' +
'mute="false"' + 'loop="true"' + '<toolbar="false"' + 'bgcolor="#111111"' +
'branding="false"' + 'controls="false"' + 'aspectRatio="16:9"' +
'target="whatever.mp4"></embed>')
}
else{
support=false
$(target).empty().html('<div id = "dialog_error">Error: browser not supported!</div>')
}
if (support){
var vlc = document.getElementById('vlc')
if (vlc){
var opt = new Array(':network-caching=300')
try{
var id = vlc.playlist.add(addr, '', opt)
vlc.playlist.playItem(id)
}
catch (e){
$(target).empty().html('<div id = "dialog_error">Error: ' + e + '<br>URL: ' + addr +
'</div>')
}
}
}
}
/* $(target + ' object').css({'width': '100%', 'height': '100%'}) */
Greets
Gee
I reduce the whole crap now to:
function runvlc(){
var target=$('body')
var error=$('#dialog_error')
var support=true
var addr='rtsp://../html/media/video/TESTCARD.MP4'
if (navigator.userAgent.toLowerCase().indexOf("msie")!=-1){
target.append('<object type = "application/x-vlc-plugin"' + 'version = "
VideoLAN.VLCPlugin.2"' + 'classid = "clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"' +
'events = "true"' + 'id = "vlc"></object>')
}
else if (navigator.userAgent.toLowerCase().indexOf("msie")==-1){
target.append('<embed type = "application/x-vlc-plugin"' + 'class="vlc_plugin"' +
'pluginspage="http://www.videolan.org"' + 'version="VideoLAN.VLCPlugin.2" ' +
'width="660" height="372"' +
'id="vlc"' + 'autoplay="true"' + 'allowfullscreen="false"' + 'windowless="true"' +
'mute="false"' + 'loop="true"' + '<toolbar="false"' + 'bgcolor="#111111"' +
'branding="false"' +
'controls="false"' + 'aspectRatio="16:9"' + 'target="whatever.mp4">
</embed>')
}
else{
support=false
error.empty().html('Error: browser not supported!')
error.show()
if (support){
var vlc=document.getElementById('vlc')
if (vlc){
var options=new Array(':network-caching=300') /* set additional vlc--options */
try{ /* error handling */
var id = vlc.playlist.add(addr,'',options)
vlc.playlist.playItem(id)
}
catch (e){
error.empty().html('Error: ' + e + '<br>URL: ' + addr + '')
error.show()
}
}
}
}
};
Didn't get it to work in ie as well...
2b continued...
Greets
Gee

Why won't this JS RegExp work?

I have a list of YouTube videos on a page and I want to use JS to grab a list of the src URLs from each <embed> tag and use them to append thumbnail images elsewhere on the page.
To do this, I need to grab the Video ID from the YouTube URL using a RegExp, but it refuses to work, even though the RegExp appears to work when I test it here: http://www.regular-expressions.info/javascriptexample.html
Here's the code I have:
**Here is the JSBin page to see it all in action: http://jsbin.com/uvoya3/23/edit
var addImages = function () {
var features = document.getElementById('features'),
embeds = features.getElementsByTagName('embed'),
ids = [], i, thumbNav, items, mysrc, pattern, ytid, newImg, matchArray;
for (i = 0; i < embeds.length; i += 1) {
mysrc = embeds[i].getAttribute('src');
pattern = /^(http:\/\/www.youtube.com\/v\/)([a-zA-Z0-9]*)(\?[^\?]*)$/;
ytid = mysrc.replace(pattern, '$2');
alert("src number " + i + " is " + ytid);
ids.push(ytid);
}
};
window.onload = addImages;
The alert is there to test what the RegExp is finding, and each time it pushes the whole mysrc string because it's not matching at all. The mysrc values are
http://www.youtube.com/v/jfiNQGFVjb4?fs=1&hl=en_US
http://www.youtube.com/v/qtzjzMsJiO8?fs=1&hl=en_US
http://www.youtube.com/v/baa-dGj2LhQ?fs=1&hl=en_US
which are being pulled from this HTML
<ul id="features">
<li><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jfiNQGFVjb4?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jfiNQGFVjb4?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></li>
<li><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/qtzjzMsJiO8?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/qtzjzMsJiO8?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></li>
<li><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/baa-dGj2LhQ?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/baa-dGj2LhQ?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></li>
</ul>
Does anyone see why my RegExp or my JS is off track here?
**PS Here is the JSBin URL http://jsbin.com/uvoya3/23/edit
It's working fine, except for the third one, because that one contains a -. And by the way, _ may be supported as well.
So, a better regular expression would be: /^(http:\/\/www.youtube.com\/v\/)([a-zA-Z0-9-_]*)(\?[^\?]*)$/.
On my Javascript console this works fine:
> "http://www.youtube.com/v/baa-dGj2LhQ?fs=1&hl=en_US".replace(/^(http:\/\/www.youtube.com\/v\/)([a-zA-Z0-9-_]*)(\?[^\?]*)$/, '$2');
< "baa-dGj2LhQ"
You could optimize your code by the way:
var addImages = function () {
// Part 1
var features = document.getElementById('features'),
embeds = features.getElementsByTagName('embed'),
pattern = /^(http:\/\/www.youtube.com\/v\/)([a-zA-Z0-9-_]*)(\?[^\?]*)$/,
ids = [], i, thumbNav, items, mysrc, ytid, newImg;
for (i = 0; i < embeds.length; i++) {
ids[i] = embeds[i].src.replace(pattern, '$2');
}
...

How to get the swf object from within a web page?

Suppose the swf file is embeded into the page with the following code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="myFlash" width="600" height="500">
<param name="movie" value="myMovie.swf">
<embed type="application/x-shockwave-flash" src="myMovie.swf" name="myFlash" width="600" height="500" >
</embed>
</object>
What are the ways to get a reference to the movie with the help of JavaScript?
function getMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
var flash = getMovie('myFlash')
Does...
var myReference = document.getElementById("myFlash");
... suit your needs? What do you aim to do with this reference once you are done?
This is the shortest answer I can write:
var swf = this["mySWF"];
It's easy, but you need to be weary of Internet Explorer
var myFlash = $.browser.msie ? window[ 'myFlash' ] : document[ 'myFlash' ];

Problem with NetStream.pause() in ActionScript called from Javascript

I am working on a very simple player written in MXML+ActionScript whose functions are exported to be called by a simple Javascript in an HTML page.
Both codes are provided below.
For the mp3 "path" all is working perfectly for playing, pausing, resuming and stopping...
For the m4a "path", starting is working well, stopping too but pausing is bugging
After having started an m4a, when I clicked on "pause" it rightly stops the stream.
But when I am clicking back on the button to resume, it does not start again at all
Does anybody know where is the problem?
Is the fact that I'm using just a simple Apache Web Server and not a real Flash Streaming server the reason why it does not work?
Thanks in advance for your help.
The MXML+ActionScript 3
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="callBacks()">
<mx:Script>
<![CDATA[
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.external.ExternalInterface;
public var playingChannel:SoundChannel;
public var playingSound:Sound;
public var pausePosition:int=0;
public var playingUrl:String="";
public var codec:String="";
public var playingStream:NetStream;
public function playSound(url:String):void {
if (playingUrl!=url) {
if (playingUrl!="") {
stopSound();
}
playingUrl=url;
codec=playingUrl.substring(playingUrl.length-3);
if (codec=="m4a") {
var mySound:SoundTransform;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
playingStream=new NetStream(connect_nc);
playingStream.play(url);
}
else if (codec=="mp3") {
playingSound=new Sound(new URLRequest(url));
playingChannel=playingSound.play();
}
}
else {
if (codec=="m4a")
playingStream.pause();
else
playingChannel=playingSound.play(pausePosition);
}
}
public function pauseSound():void {
if (codec=="m4a")
playingStream.pause();
else if (codec=="mp3") {
pausePosition=playingChannel.position;
playingChannel.stop();
}
}
public function stopSound():void {
if (codec=="m4a")
playingStream.close();
else if (codec=="mp3") {
pausePosition=0;
playingChannel.stop();
}
playingUrl="";
}
public function callBacks():void {
ExternalInterface.addCallback("play",playSound);
ExternalInterface.addCallback("pause",pauseSound);
ExternalInterface.addCallback("stop",stopSound);
}
]]>
</mx:Script>
</mx:Application>
and the basic HTML+Javascript
<html>
<head>
<script src='jquery.js'></script>
<script>
function play() {
//alert('clicked');
var url=$("#url").val();
var k=url.substring(url.length-3);
fromFlash('testFlash').play(url);
var b=document.getElementById('pp');
b.setAttribute('src','pauseButton.jpg');
b.setAttribute('onclick','pause()');
}
function pause() {
fromFlash('testFlash').pause();
var b=document.getElementById('pp');
b.setAttribute('src','playButton.jpg');
b.setAttribute('onclick','play()');
}
function stop() {
fromFlash('testFlash').stop();
var b=document.getElementById('pp');
b.setAttribute('src','playButton.jpg');
b.setAttribute('onclick','play()');
}
function fromFlash(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
</script>
</head>
<body>
<object id="testFlash" width="0" height="0">
<param name="movie" value="player.swf"></param>
<param name="allowFullScreen" value="true"></param>
<embed name="testFlash" src="player.swf" type="application/x-shockwave-flash" allowfullscreen="true" width="0" height="0">
</embed>
</object>
<input id="url"/>
<span><img id="pp" src="playButton.jpg" onclick="play()"/></span>
<span><img src="stopButton.jpg" onclick="stop()"/></span>
</body>
</html>
I believe you want to call pause() again to resume, not play().
According to the NetStream documentation, the pause() method is used for both pause and resume.

Categories

Resources