Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prob when trying to add music to my site...

    I am trying to add a button, (just a link now, but will change to a graghic image later), so that visitors to my page can click it and listen to music while they visit my page.

    So, I added this line to my code...

    <a href="Music_1.mp3">Play music</a>

    However, when the 'Play Music' link is hit, it asks me to download the Music before playing it everytime. It will download the music (from my server, I believe, then it plays it OK).

    It should not do that, ... and, I have double checked that the file 'Music_1.mp3' is indeed, listed on my FTP server.

    I did notice that because of space, only about 90% of the file got uploaded to my server. So, is that the problem? Or do I need more code?

    Or, is it not posible to have it play automatically by just hitting the link?

    Any help or links to info on this would be greatly appreciated.

    Thanks,
    Gaspari

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Its behaving correctly. To get it to play without the user having to download it, you need a bit more code
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    text-align:center;
    }
    #music {
    width:1px;
    height:1px;
    position:absolute;
    top:0;
    left:0;
    }
    </style>
    <script type="text/javascript">
    function PlayIt(what){
    document.getElementById('music').innerHTML='<object width="1" height="1" '
          +'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
          +'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
          +'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
          +'<param name="url" value="'+what+'">'
          +'<param name="uiMode" value="full">'
          +'<param name="autoStart" value="true">'
          +'<param name="loop" value="true">'
          +'<embed type="application/x-mplayer2" '
          +'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
          +'showcontrols="true" uimode="full" width="1" height="1" '
          +'src="'+what+'" autostart="true" loop="true">'
    +'</object>';
    }
    function StopIt(){
    document.getElementById('music').innerHTML='';
    }
    </script>
    </head>
    
    <body>
    <a href="http://absolutepathtosong.mp3" onclick="PlayIt(this.href);return false">Song 1</a><br>
    <a href="#" onclick="StopIt();return false;">Stop</a>
    <div id="music">
    <object width="1" height="1" 
          classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
          codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
          standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
          <param name="url" value="null.mp3">
          <param name="uiMode" value="full">
          <param name="autoStart" value="true">
          <param name="loop" value="true">
          <embed type="application/x-mplayer2" 
          pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" 
          showcontrols="true" uimode="full" width="1" height="1" 
          src="null.mp3" autostart="true" loop="true">
    </object>
    </div>
    </html>

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sweet code there i use a code that is similar. I would suggest also some flash mp3 players

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks...

    Thanks for the quick and complete reply. I had seen some examples of code that used a function before, but I thought I only needed all of that if 'I' controlled the music, and thought I only needed 1 line if the 'visitor' clicked it.

    Thanks for the info, and for your detailed example and function coding.

    Gaspari...


  •  

    Posting Permissions

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