Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embed OnFinish event?

Status
Not open for further replies.

OmniCog

Programmer
Jan 23, 2004
27
0
0
CA
Can I play a sequence of media files with the embed tag?

I have an Open Source PHP script ( that uses javascript to display a playlist play a list of media files. Someone has requested the ability to play a sequence of files consecutively.

I need something to be able to trigger a custom javascript function when the media file has completed playing.
 
Code:
<script>
function chkstate(){
if(document.form[0].song1.currentState==1) //1=playing - 2=paused - 0=stopped
alert('still playing');
else
{
nextFunction();
}}
function nextFunction(){
alert('It worked!')
}
</script>
<body>
<embed src="song.mp3" name="song1"></embed>

not tested should work, IE only! Not the answer but this should give you an idea of what to do. Just check the currentstate with a settimeout or some other method, Im sure there is a better way to do it, check msdn.

good luck

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Thanks, I'll test this code out tonight.

I'm not much of a JavaScript person so I had no idea where to start, and I'm not to fond of msdn for javascript because I prefer to be create cross-platform code.
 

>> I'm not to fond of msdn for javascript because I prefer to be create cross-platform code.

What a strange thing to say.

MSDN is a fantastic JavaScript resource - one of the best, I believe. They normally always tell you whether a method/property, etc is IE specific or part of a public standard.

I'm not saying you MUST use it, but do give it a chance.

Dan
 
I use it for Visual Basic. I need js code that netscape users will be able to experience.
 

>> I need js code that netscape users will be able to experience.

Then write your code to be cross-browser compatible. MSDN will help you rather than hinder you, I believe, as it does tell you which things are "public standard" and which are not - unlike a lot of Javascript resources I've seen.

Hope this helps,
Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top