Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-08-2004, 12:59 PM   PM User | #1
sleep_z6
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sleep_z6 is an unknown quantity at this point
Question How to use javascript to detect if Flash is playing??

Hi, I am new here~
and is anyone here can tell me how to use “document.demo.IsPlaying()” to detect if Flash is playing???
I only know how to use javascript to control Flash play or stop...
but I don't know how to use that to detect it...
so please please please tell me how to do it...
thank you!!!
sleep_z6 is offline   Reply With Quote
Old 06-08-2004, 02:08 PM   PM User | #2
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
there is no Flash API for JS, tho there is one the other way round.

now, what you code do is to get the Flash movie to write out to a JS variable or a hidden field in the HTML. if it this var is set to true, then it's playing. so, you just use JS to check against the hidden field or var.

quite easy in theory really.

your best choice of action is to look up the Flash help as to how to interact with HTML and JS.

btw: my Flash is not that good, so the above is theoretical.
jbot is offline   Reply With Quote
Old 06-10-2004, 06:56 AM   PM User | #3
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
http://www.quirksmode.org/js/flash_call.html
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 06-10-2004, 11:26 AM   PM User | #4
sleep_z6
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sleep_z6 is an unknown quantity at this point
hi

OH~
Thank you for help me out~!!!
Thank you very much!!!
sleep_z6 is offline   Reply With Quote
Old 06-11-2004, 01:33 PM   PM User | #5
sleep_z6
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sleep_z6 is an unknown quantity at this point
Question oh oh...

oh oh...
there is still something wrong in my code...
but I tried and tried...
still don't know where the problem is....
so is here any one can help me out...??
thanks very much!!!!
my code:
function IsFlashPlaying()
{
if (document.demo)
{
if (document.demo.Play)
document.demo.Play();
else
alert('The Flash is not playing')
}
else
alert('Can\'t find the Flash movie')

}
sleep_z6 is offline   Reply With Quote
Old 06-14-2004, 04:41 AM   PM User | #6
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
What happened when you execute that function? Did the flash movie play? Or the "Flash is not playing" or "Can't find the flash movie" message was displayed? Please be specific.

But the idea I was thinking when I linked you to that site is this:
When the flash starts to play, you call this in flash:

getURL('javascript:setFlashPlaying(true)')

When flash stops, you call

getURL('javascript:setFlashPlaying(false)')


Then in javascript, you have this:

var flashIsPlaying=false;
function setFlashPlaying(flag){
flashIsPlaying=flag;
}

So to detect if flash is playing, you just check the value of the flashIsPlaying variable.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 06-15-2004, 12:39 PM   PM User | #7
sleep_z6
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sleep_z6 is an unknown quantity at this point
Question is anything wrong in my code???

How about this I wrote :
function checkPlay()
{
if (doucment.demo.IsPlaying)
alert("is Playing");
else
alert("is not Playing");
}

and
<input type="button" value="Check Playing" onClick="checkPlay()">

But I don't know what's wrong in my code...while I click the button...it shows the error message...but I couldn't find where the problem is....
is anybody can tell me what's the problem in??
thanks very much!!!!!!!!!
sleep_z6 is offline   Reply With Quote
Old 06-16-2004, 05:40 AM   PM User | #8
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Quote:
if (doucment.demo.IsPlaying)
You have a typo there but I don't think (not sure as I don't know Flash,) it has a built-in IsPlaying property or method? If it is a method, there should be () at the end.

If indeed it doesn't have that property/method, try using the code in the link I posted and modify it to add a flag
Code:
var isFlashPlaying=false;
function tryPlayFlash()
{
	if (document.themovie)
	{
		if (document.themovie.Play) {
			document.themovie.Play();
                        isFlashPlaying=true;
                }
		else
			alert('Cannot communicate with ActionScript');
	}
	else
		alert("Can't find the Flash movie");
}

function tryStopFlash()
{
	if (document.themovie)
	{
		if (document.themovie.Stop) {
			document.themovie.Stop();
                        isFlashPlaying=false;
                }
		else
			alert('Cannot communicate with ActionScript');
	}
	else
		alert("Can't find the Flash movie");
}
You will call those functions to play and stop the Flash and then monitor the isFlashPlaying variable. The only problem with that is if the user uses the menu in the flash to play/stop it. I don't know if it (through ActionScript) has event handler that detects if it's playing or stopping.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:43 AM.


Advertisement
Log in to turn off these ads.