action when media ends
WMPTalk.com Forum Index WMPTalk.com
Discuss Windows Media Player
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web wmptalk.com
action when media ends

 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> Windows Media on Web
Author Message
urug haiml
Guest





Posted: Fri Jul 16, 2004 3:25 pm    Post subject: action when media ends Reply with quote

Hello,

I would like to write javascript that executes when my media clip ends in
the media player object. In more detail, I have a button that changes from
play to pause depending on the playstate of the player. When the clip is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends, the
pause image stays on the button and it should ofcourse change to the play
image.
Is there some way to catch the ending of the clip with javascript or some
other way to detect it?

Back to top
Neil Smith [MVP Digital M
Guest





Posted: Sat Jul 17, 2004 12:46 am    Post subject: Re: action when media ends Reply with quote

Sure, you can watch the player.playState property for it changin to a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
<taisto69@hotmail.com> wrote:

Quote:
Hello,

I would like to write javascript that executes when my media clip ends in
the media player object. In more detail, I have a button that changes from
play to pause depending on the playstate of the player. When the clip is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends, the
pause image stays on the button and it should ofcourse change to the play
image.
Is there some way to catch the ending of the clip with javascript or some
other way to detect it?
Back to top
urug haiml
Guest





Posted: Mon Jul 19, 2004 11:31 am    Post subject: Re: action when media ends Reply with quote

Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add it as a
parameter for the player object and then give it a value for a javascript
function? Or can i use it straight as a funtion like onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and give it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Quote:
Sure, you can watch the player.playState property for it changin to a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip ends in
the media player object. In more detail, I have a button that changes
from
play to pause depending on the playstate of the player. When the clip is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends, the
pause image stays on the button and it should ofcourse change to the play
image.
Is there some way to catch the ending of the clip with javascript or some
other way to detect it?



Back to top
Neil Smith [MVP Digital M
Guest





Posted: Mon Jul 19, 2004 4:58 pm    Post subject: Re: action when media ends Reply with quote

OK try starting with (assuming your embedded player ID is
'mediaplayer' without the quotes)

<script for="mediaplayer" language="javascript1.2"
event="playstatechange(newstate)">
document.getElementById("statuschanges").innerHTML+="Play
state changed to "+newstate+"<br />";
</script>

<div id="statuschanges"></div>

See where that gets you and we can go from there.

On Mon, 19 Jul 2004 10:31:14 +0300, "urug haiml"
<taisto69@hotmail.com> wrote:

Quote:
Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add it as a
parameter for the player object and then give it a value for a javascript
function? Or can i use it straight as a funtion like onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and give it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Sure, you can watch the player.playState property for it changin to a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip ends in
the media player object. In more detail, I have a button that changes
from
play to pause depending on the playstate of the player. When the clip is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends, the
pause image stays on the button and it should ofcourse change to the play
image.
Is there some way to catch the ending of the clip with javascript or some
other way to detect it?


Back to top
urug haiml
Guest





Posted: Thu Jul 22, 2004 11:14 am    Post subject: Re: action when media ends Reply with quote

Thanks for the script, its really helpful..

But I have a problem, the playstate values that are returned seem to be all
wrong. When a clip ends, it gives the playstate values.
Playstate changed to 2
Playstate changed to 0
Playstate changed to 3

I dont really understand this.. Why doesnt it give a value 8 when the clip
ends. Why 3, it means its playing, doesnt it?

"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:dvhnf0dgdc6bbe4e1j8mng9fve8oofaa7s@4ax.com...
Quote:
OK try starting with (assuming your embedded player ID is
'mediaplayer' without the quotes)

script for="mediaplayer" language="javascript1.2"
event="playstatechange(newstate)"
document.getElementById("statuschanges").innerHTML+="Play
state changed to "+newstate+"<br />";
/script

div id="statuschanges"></div

See where that gets you and we can go from there.

On Mon, 19 Jul 2004 10:31:14 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add it
as a
parameter for the player object and then give it a value for a javascript
function? Or can i use it straight as a funtion like onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and give
it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Sure, you can watch the player.playState property for it changin to a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip ends
in
the media player object. In more detail, I have a button that changes
from
play to pause depending on the playstate of the player. When the clip
is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends,
the
pause image stays on the button and it should ofcourse change to the
play
image.
Is there some way to catch the ending of the clip with javascript or
some
other way to detect it?



Back to top
Neil Smith [MVP Digital M
Guest





Posted: Fri Jul 23, 2004 2:09 am    Post subject: Re: action when media ends Reply with quote

The playstate moves through various stages, not necessarily in any
order you might expect.

You need to monitor the playstate for a 'stopped' state (which can be
8 or sometimes 1, or 10, but generally is 8). Its important to know
that the play state may not change in any predicatable order. I should
add, it works reliable for me. An example I tried went :

9 - 9 - 3 - 6 - 3 - 8 - 9 - 10

The full list of playstates is in the SDK documentation for the
player, but I've pasted it here so you can compare the values :

0 Undefined Windows Media Player is in an undefined state.
1 Stopped Playback of the current media clip is stopped.
2 Paused Playback of the current media clip is paused. When media is
paused, resuming playback begins from the same location.
3 Playing The current media clip is playing.
4 ScanForward The current media clip is fast forwarding.
5 ScanReverse The current media clip is fast rewinding.
6 Buffering The current media clip is getting additional data from
the server.
7 Waiting Connection is established, however the server is not
sending bits. Waiting for session to begin.
8 MediaEnded Media has completed playback and is at its end.
9 Transitioning Preparing new media.
10 Ready Ready to begin playing.
11 Reconnecting Reconnecting to stream.


However if you're ending on a playstate of 3, it suggests that events
are not being captured completely, or that your media is doing
something else at the end eg displaying a banner ad or other content.

This is where I ask if you can provide a URL of the code you have so
far, which is the only real way to investigat your problem further.
Can you put it online for use to test ?

Cheers - Neil


n Thu, 22 Jul 2004 10:14:52 +0300, "urug haiml" <taisto69@hotmail.com>
wrote:

Quote:
Thanks for the script, its really helpful..

But I have a problem, the playstate values that are returned seem to be all
wrong. When a clip ends, it gives the playstate values.
Playstate changed to 2
Playstate changed to 0
Playstate changed to 3

I dont really understand this.. Why doesnt it give a value 8 when the clip
ends. Why 3, it means its playing, doesnt it?

"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:dvhnf0dgdc6bbe4e1j8mng9fve8oofaa7s@4ax.com...
OK try starting with (assuming your embedded player ID is
'mediaplayer' without the quotes)

script for="mediaplayer" language="javascript1.2"
event="playstatechange(newstate)"
document.getElementById("statuschanges").innerHTML+="Play
state changed to "+newstate+"<br />";
/script

div id="statuschanges"></div

See where that gets you and we can go from there.

On Mon, 19 Jul 2004 10:31:14 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add it
as a
parameter for the player object and then give it a value for a javascript
function? Or can i use it straight as a funtion like onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and give
it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Sure, you can watch the player.playState property for it changin to a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip ends
in
the media player object. In more detail, I have a button that changes
from
play to pause depending on the playstate of the player. When the clip
is
playing the button shows a pause image and when paused it shows a play
image. This all works great. The problem is that when the clip ends,
the
pause image stays on the button and it should ofcourse change to the
play
image.
Is there some way to catch the ending of the clip with javascript or
some
other way to detect it?




Back to top
urug haiml
Guest





Posted: Mon Jul 26, 2004 11:26 am    Post subject: Re: action when media ends Reply with quote

Heres the code im using for this.. The media clip is just some clip i found
from the web.

<OBJECT ID="mediaPlayer"
CLASSID="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="384"
height="292"
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">
<PARAM NAME="fileName"
VALUE="http://devedge.netscape.com/viewsource/2003/windows-media-in-netscape
/media/explain-windows-media.wmv">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="false">
<PARAM NAME="autoStart" VALUE="true">
<PARAM NAME="showControls" VALUE="true">
<PARAM NAME="ShowDisplay" VALUE="false">
<PARAM NAME="loop" VALUE="false">
<PARAM NAME="DisplaySize" VALUE="2">
<PARAM NAME="Autorewind" VALUE="true">
</OBJECT>


</script>
<script for="mediaPlayer" language="javascript"
event="playstatechange(newstate)">
if (newstate == 8){
document.getElementById("statuschanges").innerHTML+="Playstate changed to
"+newstate+"<br />";
}else{
document.getElementById("statuschanges").innerHTML+="blaablaa changed to
"+newstate+"<br />";
}
</script><br/>

as
<div id="statuschanges"></div>
as
</SCRIPT>






"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:sfe0g05c8plh8spev2cjb0d490eq6pfqf5@4ax.com...
Quote:
The playstate moves through various stages, not necessarily in any
order you might expect.

You need to monitor the playstate for a 'stopped' state (which can be
8 or sometimes 1, or 10, but generally is 8). Its important to know
that the play state may not change in any predicatable order. I should
add, it works reliable for me. An example I tried went :

9 - 9 - 3 - 6 - 3 - 8 - 9 - 10

The full list of playstates is in the SDK documentation for the
player, but I've pasted it here so you can compare the values :

0 Undefined Windows Media Player is in an undefined state.
1 Stopped Playback of the current media clip is stopped.
2 Paused Playback of the current media clip is paused. When media is
paused, resuming playback begins from the same location.
3 Playing The current media clip is playing.
4 ScanForward The current media clip is fast forwarding.
5 ScanReverse The current media clip is fast rewinding.
6 Buffering The current media clip is getting additional data from
the server.
7 Waiting Connection is established, however the server is not
sending bits. Waiting for session to begin.
8 MediaEnded Media has completed playback and is at its end.
9 Transitioning Preparing new media.
10 Ready Ready to begin playing.
11 Reconnecting Reconnecting to stream.


However if you're ending on a playstate of 3, it suggests that events
are not being captured completely, or that your media is doing
something else at the end eg displaying a banner ad or other content.

This is where I ask if you can provide a URL of the code you have so
far, which is the only real way to investigat your problem further.
Can you put it online for use to test ?

Cheers - Neil


n Thu, 22 Jul 2004 10:14:52 +0300, "urug haiml" <taisto69@hotmail.com
wrote:

Thanks for the script, its really helpful..

But I have a problem, the playstate values that are returned seem to be
all
wrong. When a clip ends, it gives the playstate values.
Playstate changed to 2
Playstate changed to 0
Playstate changed to 3

I dont really understand this.. Why doesnt it give a value 8 when the
clip
ends. Why 3, it means its playing, doesnt it?

"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:dvhnf0dgdc6bbe4e1j8mng9fve8oofaa7s@4ax.com...
OK try starting with (assuming your embedded player ID is
'mediaplayer' without the quotes)

script for="mediaplayer" language="javascript1.2"
event="playstatechange(newstate)"
document.getElementById("statuschanges").innerHTML+="Play
state changed to "+newstate+"<br />";
/script

div id="statuschanges"></div

See where that gets you and we can go from there.

On Mon, 19 Jul 2004 10:31:14 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add
it
as a
parameter for the player object and then give it a value for a
javascript
function? Or can i use it straight as a funtion like
onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and
give
it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Sure, you can watch the player.playState property for it changin to
a
value of 8 (MediaEnded : Media has completed playback and is at its
end)

Just fire events onPlayStateChange for the player, and check the
event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip
ends
in
the media player object. In more detail, I have a button that
changes
from
play to pause depending on the playstate of the player. When the
clip
is
playing the button shows a pause image and when paused it shows a
play
image. This all works great. The problem is that when the clip
ends,
the
pause image stays on the button and it should ofcourse change to
the
play
image.
Is there some way to catch the ending of the clip with javascript
or
some
other way to detect it?





Back to top
urug haiml
Guest





Posted: Mon Jul 26, 2004 11:43 am    Post subject: Re: action when media ends Reply with quote

Sorry about the extra end script tags.. Quickly arrenged my scripts..

<OBJECT ID="mediaPlayer"
CLASSID="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="384"
height="292"
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">
<PARAM NAME="fileName"
VALUE="http://devedge.netscape.com/viewsource/2003/windows-media-in-netscape
/media/explain-windows-media.wmv">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="false">
<PARAM NAME="autoStart" VALUE="true">
<PARAM NAME="showControls" VALUE="true">
<PARAM NAME="ShowDisplay" VALUE="false">
<PARAM NAME="loop" VALUE="false">
<PARAM NAME="DisplaySize" VALUE="2">
<PARAM NAME="Autorewind" VALUE="true">
</OBJECT>

<script for="mediaPlayer" language="javascript"
event="playstatechange(newstate)">
if (newstate == 8){
document.getElementById("statuschanges").innerHTML+="Playstate changed to
"+newstate+"<br />";
}else{
document.getElementById("statuschanges").innerHTML+="blaablaa changed to
"+newstate+"<br />";
}
</script><br/>

as
<div id="statuschanges"></div>
as


"urug haiml" <taisto69@hotmail.com> wrote in message
news:uRvmcHucEHA.3632@TK2MSFTNGP09.phx.gbl...
Quote:
Heres the code im using for this.. The media clip is just some clip i
found
from the web.

OBJECT ID="mediaPlayer"
CLASSID="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="384"
height="292"
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"
PARAM NAME="fileName"

VALUE="http://devedge.netscape.com/viewsource/2003/windows-media-in-netscape
/media/explain-windows-media.wmv"
PARAM NAME="animationatStart" VALUE="true"
PARAM NAME="transparentatStart" VALUE="false"
PARAM NAME="autoStart" VALUE="true"
PARAM NAME="showControls" VALUE="true"
PARAM NAME="ShowDisplay" VALUE="false"
PARAM NAME="loop" VALUE="false"
PARAM NAME="DisplaySize" VALUE="2"
PARAM NAME="Autorewind" VALUE="true"
/OBJECT


/script
script for="mediaPlayer" language="javascript"
event="playstatechange(newstate)"
if (newstate == 8){
document.getElementById("statuschanges").innerHTML+="Playstate changed to
"+newstate+"<br />";
}else{
document.getElementById("statuschanges").innerHTML+="blaablaa changed to
"+newstate+"<br />";
}
/script><br/

as
div id="statuschanges"></div
as
/SCRIPT






"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:sfe0g05c8plh8spev2cjb0d490eq6pfqf5@4ax.com...
The playstate moves through various stages, not necessarily in any
order you might expect.

You need to monitor the playstate for a 'stopped' state (which can be
8 or sometimes 1, or 10, but generally is 8). Its important to know
that the play state may not change in any predicatable order. I should
add, it works reliable for me. An example I tried went :

9 - 9 - 3 - 6 - 3 - 8 - 9 - 10

The full list of playstates is in the SDK documentation for the
player, but I've pasted it here so you can compare the values :

0 Undefined Windows Media Player is in an undefined state.
1 Stopped Playback of the current media clip is stopped.
2 Paused Playback of the current media clip is paused. When media is
paused, resuming playback begins from the same location.
3 Playing The current media clip is playing.
4 ScanForward The current media clip is fast forwarding.
5 ScanReverse The current media clip is fast rewinding.
6 Buffering The current media clip is getting additional data from
the server.
7 Waiting Connection is established, however the server is not
sending bits. Waiting for session to begin.
8 MediaEnded Media has completed playback and is at its end.
9 Transitioning Preparing new media.
10 Ready Ready to begin playing.
11 Reconnecting Reconnecting to stream.


However if you're ending on a playstate of 3, it suggests that events
are not being captured completely, or that your media is doing
something else at the end eg displaying a banner ad or other content.

This is where I ask if you can provide a URL of the code you have so
far, which is the only real way to investigat your problem further.
Can you put it online for use to test ?

Cheers - Neil


n Thu, 22 Jul 2004 10:14:52 +0300, "urug haiml" <taisto69@hotmail.com
wrote:

Thanks for the script, its really helpful..

But I have a problem, the playstate values that are returned seem to be
all
wrong. When a clip ends, it gives the playstate values.
Playstate changed to 2
Playstate changed to 0
Playstate changed to 3

I dont really understand this.. Why doesnt it give a value 8 when the
clip
ends. Why 3, it means its playing, doesnt it?

"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:dvhnf0dgdc6bbe4e1j8mng9fve8oofaa7s@4ax.com...
OK try starting with (assuming your embedded player ID is
'mediaplayer' without the quotes)

script for="mediaplayer" language="javascript1.2"
event="playstatechange(newstate)"
document.getElementById("statuschanges").innerHTML+="Play
state changed to "+newstate+"<br />";
/script

div id="statuschanges"></div

See where that gets you and we can go from there.

On Mon, 19 Jul 2004 10:31:14 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Sorry, I am new with this, so a few more questions.

Im not sure where to add the onPlayStateChange command. Should i add
it
as a
parameter for the player object and then give it a value for a
javascript
function? Or can i use it straight as a funtion like
onPlayStateChange(){
} And do i need to add the parameter SendPlayStateChangeEvents and
give
it a
true value?


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:uaggf0phd856g1da830g6hahluubh28fqf@4ax.com...
Sure, you can watch the player.playState property for it changin
to
a
value of 8 (MediaEnded : Media has completed playback and is at
its
end)

Just fire events onPlayStateChange for the player, and check the
event
return value for it being 8 - when it is, use your usual image
flipping script

Cheers - Neil

On Fri, 16 Jul 2004 14:25:03 +0300, "urug haiml"
taisto69@hotmail.com> wrote:

Hello,

I would like to write javascript that executes when my media clip
ends
in
the media player object. In more detail, I have a button that
changes
from
play to pause depending on the playstate of the player. When the
clip
is
playing the button shows a pause image and when paused it shows a
play
image. This all works great. The problem is that when the clip
ends,
the
pause image stays on the button and it should ofcourse change to
the
play
image.
Is there some way to catch the ending of the clip with javascript
or
some
other way to detect it?







Back to top
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> Windows Media on Web All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Microsoft Office Forum New Topics
Powered by phpBB