Web Analytics Made Easy -
StatCounter Use piece of URL as argument when calling Flash object - CodingForum

Announcement

Collapse
No announcement yet.

Use piece of URL as argument when calling Flash object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use piece of URL as argument when calling Flash object

    I'm trying to make a quick and dirty mp3 player that plays whatever mp3 is in the URL, for example http://www.mysite.com/music.html?song=vertigo.mp3 would open the SWF mp3 player (I chose this one for its simplicity http://ericzhang.com/mp3.php) and play that song. However, nothing I've tried works. Could someone take a look at my code and help me out? Thanks in advance. Please note that downloading the mp3 through newwindow() works perfectly.

    Code:
    <html>
    <head>
    <title>Simple MP3 Player</title>
    <script language="JavaScript">
    function newwindow() {window.open(grabsong(text),'jav','width=300,height=200,resizable=yes');}
    </script>
    </head>
    <body>
    
    <FORM NAME="site">
    <INPUT TYPE="hidden" NAME="url" SIZE="35">
    </FORM>
    
    <script language="JavaScript">
    var locate = window.location
    document.site.url.value = locate
    var text = document.site.url.value
    
    function grabsong(str){
    loc = str.lastIndexOf("="); 
    return(str.substring(loc+1,str.length));
    }
    
    document.write(grabsong(text));
    
    function musicurl(){
    var murl; 
    murl = "music.swf?url="; 
    murl = murl.concat(grabsong(text)); 
    murl = murl.concat("&mode=play"); 
    return (murl);
    }
    
    </script>
    <br>
    <script language="JavaScript">
    document.write(musicurl());
    </script>
    
    <center><embed wmode="transparent" src="javascript:musicurl()" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="50"></embed></center>-
    
    <a href="javascript:newwindow()" title="Click to download.">
    <img src="img/download-s.gif" title="Click to download." alt="">
    </body>
    </html>

  • #2
    bump for help

    Comment


    • #3
      b-b-b-b-b-bump

      Comment


      • #4
        src="javascript:musicurl()" this doesn't work.

        Use
        Code:
        <embed [B]id="player"[/B] wmode="transparent" [B]src=""[/B] quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="50"></embed>
        and after that

        Code:
        <script language="JavaScript">
        document.getElementById('player').src=musicurl();
        </script>
        .My new Javascript tutorial site: http://reallifejs.com/
        .Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
        .Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback

        Comment

        Working...
        X