embedded WMP, button to play in full screen

  • Follow


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
0
Reply cskelly 12/14/2003 12:59:17 AM

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

-- 
Michael Winter
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk")
0
Reply Michael 12/14/2003 2:03:45 AM


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
0
Reply cskelly 12/15/2003 11:01:18 PM

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
0
Reply cskelly 12/16/2003 2:12:06 AM

3 Replies
609 Views

(page loaded in 0.043 seconds)

Similiar Articles:













7/20/2012 4:10:10 AM


Reply: