SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    embeded windows media player controls

    http://bpd.plantedtank.net/controls.htm

    I'm trying to create javascript buttons to control the embeded wmp player on this page. Whats really biting at me is the pause functionality, for some reason the player will rewind it and start from the beginning if I pause and then play it. I added some code to check to see if the controls are available and apparently pause() isn't available?!?!

    Using the right click menu on the player works just fine to play and pause it.

    Here's the js code:
    Code:
    function togglePlay () {
    	if (document.movie1.controls.isAvailable('Play')) {
    		document.movie1.controls.Play();
    		document.getElementById("playButton").style.display='none';
    		document.getElementById("pauseButton").style.display='block';
    	}
    	else alert("play not available");
    }
    function togglePause () {
    	if (document.movie1.controls.isAvailable('Pause')) {
    		document.movie1.controls.Pause();
    		document.getElementById("pauseButton").style.display='none';
    		document.getElementById("playButton").style.display='block';
    	}
    	else alert("pause not available");
    }
    I've checked many references online for embeding a wmp object and I haven't found anything to fix this problem. Could it just be my computer? can anyone confirm that the pause function is acting funny?

    And btw, I haven't bothered to make it work in FF yet, I want to get it working IE first.

    Thanks!

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course PAUSE is available.

    I wrote this quick sample, you can see how controls can be used.

    If you want to "toggle" the Play button to become Pause, you will have to check the status of the player, someting similar to what I did using the MUTE button (you can click the same button to MUTE and UNMUTE)

    Sorry if this code is very bare bones but I wrote it in a jiffy

    PHP Code:
    <HTML>
    <
    HEAD>
    </
    HEAD>
    <
    BODY>

    <
    OBJECT ID="Player" height="400" width="400" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">

            <
    PARAM name "Volume" value="50">

    </
    OBJECT>

    <
    BR><BR>

    <
    INPUT TYPE="BUTTON" NAME="BtnPlay"    VALUE="Play"    OnClick="Play()">
    <
    INPUT TYPE="BUTTON" NAME="BtnPause"   VALUE="Pause"   OnClick="Pause()">
    <
    INPUT TYPE="BUTTON" NAME="BtnStop"    VALUE="Stop"    OnClick="Stop()">
    <
    INPUT TYPE="BUTTON" NAME="BtnMute"    VALUE="Mute"    OnClick="MuteMe()">
    <
    INPUT TYPE="BUTTON" NAME="BtnUnMute"  VALUE="UnMute"  OnClick="UnMuteMe()">
    <
    INPUT TYPE="BUTTON" NAME="BtnVolUp"   VALUE="VolUp"   OnClick="VolumeUp()">
    <
    INPUT TYPE="BUTTON" NAME="BtnVolDown" VALUE="VolDown" OnClick="VolumeDown()">
    <
    INPUT TYPE="BUTTON" NAME="BtnStatus"  VALUE="Status"  OnClick="Status()">

    <
    SCRIPT>

    <!--

            var 
    WMState = new Array();

            
    WMState[0]  = "Undefined";
            
    WMState[1]  = "Stopped";
            
    WMState[2]  = "Paused";
            
    WMState[3]  = "Playing";
            
    WMState[4]  = "Scan Forward";
            
    WMState[5]  = "Scan Reverse";
            
    WMState[6]  = "Buffering";
            
    WMState[7]  = "Waiting";
            
    WMState[8]  = "Media Ended";
            
    WMState[9]  = "Transitioning";
            
    WMState[10] = "Ready";
            
    WMState[11] = "Reconnecting";


            function 
    Status () {

                     
    Player.playState;
              
                     
    alert("Windows Media Player is " WMState[x] + "\r\r" "Player Version:" Player.versionInfo);

            }


            function 
    Play () {

                     
    Player.playState;

                     if (
    == 2) {

                        
    Player.controls.play();

                     }else{

                        
    Player.URL "http://bpd.plantedtank.net/tf2_teaser01_720p.wmv";

                     }         
            }


            function 
    Pause () {

                     
    Player.controls.pause();
            
            }


            function 
    Stop () {

                     
    Player.controls.stop();

            }


            function 
    MuteMe () {


                     
    Player.settings.mute;

                     if (
    == 0) {

                        
    Player.settings.mute "1";

                     }else{
        
                        
    Player.settings.mute "0";

                     }
                     
            }


            function 
    UnMuteMe () {

                     
    Player.settings.mute "0";
                     
            }


            function 
    VolumeUp () {

                     
    Player.settings.volume;

                     
    Player.settings.volume 10;
                     
            }


            function 
    VolumeDown () {

                     
    Player.settings.volume;

                     
    Player.settings.volume 10;
                     
            }

    -->

    </SCRIPT>

    </BODY>
    </HTML> 

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that works for everything you've put in there, but I'm having trouble with hiding the controls... I was able to use <param name="ShowControls" value="false"> in the clsid for ver 6.4 but it doesnt work in this version. I haven't been able to find another way to hide controls on media embed reference sites. Any ideas? Thanks again.

  4. #4
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh nevermind, I found it, it's uiMOde value="none". Hope this thread helps anyone else with this issue.

    Thanks a bunch!

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem. Glad I could help you.

  6. #6
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The above code is not working in Opera and Firefox. I wrote document.getElementById('Player'') instead of Player. It did not work. Media player is not seeming.

    What can I do?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •