embedded WMP, button to play in full screen

C

craig

i want to make a button that will start an embedded windows media
player playing AND in full screen. i can do it with TWO buttons:

<input
onclick="MediaPlayer.controls.play();"
type="button"
size="22"
value="Play">

<INPUT type = "button"
value = "Full Screen"
name = BUTTON
onclick = "if (MediaPlayer.playState == 3)
MediaPlayer.fullScreen = 'true';">

but i would like to be able to combine this into ONE button. seems
simple enough but after a week of experimenting, i just can't figure
it out.

thanks,
craig
 
M

Michael Winter

craig wrote on 14 Dec 2003 at Sun, 14 Dec 2003 00:59:17 GMT:
i want to make a button that will start an embedded windows
media player playing AND in full screen. i can do it with TWO
buttons:

<input
onclick="MediaPlayer.controls.play();"
type="button"
size="22"
value="Play">

<INPUT type = "button"
value = "Full Screen"
name = BUTTON
onclick = "if (MediaPlayer.playState == 3)
MediaPlayer.fullScreen = 'true';">

but i would like to be able to combine this into ONE button.

In the document HEAD, add this:

<SCRIPT type="text/javascript">
function playFullscreen() {
if (3 == MediaPlayer.playState) {
MediaPlayer.fullscreen = 'true';
}
MediaPlayer.controls.play();
}
</SCRIPT>

...and this BUTTON to your document:

<BUTTON type="button" onclick="playFullscreen()"
Play fullscreen</BUTTON>

I can't test this, but there should be no reason why it won't work.

What is 3 as a value of MediaPlayer.playState? Does it impact whether
the video should be played, or only if it can or can't be changed to
fullscreen. Does the video need to be playing before it's changed to
fullscreen, or should the fullscreen happen first? You'll have to
decide, based on the answers to those questions, whether the play()
call should be inside the if statement, before it, or after it.

Hope that helps,

Mike
 
C

craig

thanks for the reply michael. i am contacting you directly via email.
your solution apparently only works if the button is pressed twice,
which does get me closer than before but it also makes me think the
real solution is simple and close. if anyone else has any ideas
please post them here. as soon as i get a solution i will post it
here and hopefully it will help someone else in the future.

craig
 
C

craig

thanks to mike, I GOT IT. the following code in the header:

<SCRIPT type="text/javascript">
var stateTimer = null;

function playFullscreen() {
// Check if the video is playing. If it is, change
// to fullscreen. If not, start checking to see when
// it is.
if (3 == MediaPlayer.playState) {
MediaPlayer.fullscreen = 'true';
} else {
MediaPlayer.controls.play();
if (!stateTimer) stateTimer =
window.setInterval( checkState, 500 );
}
}

function checkState() {
// Check periodically to see if the video has
// started. If so, destroy the timer and change to
// fullscreen
if (3 == MediaPlayer.playState) {
window.clearInterval( stateTimer );
stateTimer = null;
MediaPlayer.fullscreen = 'true';
}
}
</SCRIPT>

and the following in the body:

<BUTTON type="button" onclick="playFullscreen()"
Play fullscreen</BUTTON>

did the trick! thanks mike, you're a true guru.

craig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top