SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with embeded media player and dropdown

    I found this on a site, and want to use for my own uses, but I would like to get the player when you select something in the dropdown to play the file. How do I do that.?
    http://welcometomessiah.org/soundddown.html
    Code:
    <html><head><title></title><script language="JavaScript">
    function playMusic() {
    musicURL=document.music.musicmenu.options[document.music.musicmenu.selectedIndex].value
    if (musicURL) {
    window.location.href=""musicURL
    }
    }
    </script>
    </head><body>
    <p align=center><EMBED  type="audio/x-pn-realaudio- plugin" console="clip1" 
    controls="controlpanel,statusbar" height="50" width="200" autostart="false"><br>
    <form name="music">
    <select name="musicmenu" size=1 onChange="playMusic()">
    <option value="">Music Menu
    <option value="http://cudinh.net/music/999doahong.rm">ST: First Contact
    <option value="http://cudinh.net/music/2jamunnback.rm">St. Dumas Theme
    </select>
    </table>
    </body></html>

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    for Real player the syntax is
    Code:
    function Sound(sndAction,sndObj) {
    if(sndAction=="play") eval(sndObj).DoPlay()
    if(sndAction=="stop") eval(sndObj).DoStop() }
    but you should make it available for all media players.

    to find out which they are using you can use this
    Code:
    var DocLoad=false;
    var agt=navigator.userAgent.toLowerCase();
    var ns  = (navigator.appName.indexOf("Netscape") != -1);
    var op = (agt.indexOf("opera") != -1);
    if(!op) var ie  = (agt.indexOf("msie") != -1);
    var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
    var mac = (agt.indexOf("mac")!=-1);
     
    if (ie && win) { pluginlist = detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player"); }
    if (ns || !win) {
      nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
      pluginlist = detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player");}
    if((op)&&(!ie)) { pluginlist = "" }
    function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
    function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }
    var rp=wmp=false
    if (pluginlist.indexOf("Windows Media Player")!=-1) { wmp=true } else { if (pluginlist.indexOf("RealPlayer")!=-1) rp=true}
    for (var i=0;i<navigator.mimeTypes.length;i++) { if(navigator.mimeTypes[i].type=="application/x-mplayer2") wmp=true }
    then tou can use this
    Code:
    function Sound(sndAction,sndObj) {
    if(wmp) {
    if(sndAction=="play") {document.getElementById(sndObj).controls.play();}
    if(sndAction=="stop") {document.getElementById(sndObj).controls.stop();}} else {
    if(rp) {
    if(sndAction=="play") eval(sndObj).DoPlay()
    if(sndAction=="stop") {eval(sndObj).DoStop();eval(sndObj).SetPosition(0)}}}}
    to start and stop the sound
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sorry, the script above gives preferance to Windows Media Player, you'll need to swap the if/else at the bottom to give preferance to Real
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sorry, you'll also need this
    Code:
    function Change_Song() { NextSong=document.myform.SongMenu.value;
    document.getElementById("soundplayerID" ).url=NextSong+".wav"; }
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  5. #5
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought all i had to do to get it to play in the player was to change this
    Code:
    window.location.href=""musicURL 
    now I'm even more confused

  6. #6
    SitePoint Wizard silver trophy Crazybanana's Avatar
    Join Date
    Mar 2003
    Location
    In tha fruit cellar
    Posts
    1,379
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    I would have used the object and embed tags for RealPlayer and a playlist file, then I dident need the javascript part...
    Who's to doom when the judge himself is dragged before the bar


  7. #7
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you'll need to use the object and embed method to change the music dynamically. If you want the player to show on the screen you can use CrazyB's method, but my method will work with or without the player showing.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •