www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Thread: Embed random Audio/Video

  1. #1
    Join Date
    Oct 2005
    Posts
    1

    Embed random Audio/Video

    I'm new, sorry if I sound retarded or I stuck this on the wrong area...


    To embed a video or audio file I understand, that's not a problem. I was wondering if it were possible to have a random mpeg or mp3 open everytime the page was loaded.

    Something like, I stick 4 or 5 files in a directory, one of them is randomly used as the source in the embed code. much in the same way you can have a code to have random image (jpeg) come up and be linked to it.

    I could be explaining this the wrong way but as for the image thing, I already use that for the top banner, and the top right "featured link" on this page:
    http://www.lotpatrol.com/news/index.html

    any help would be appreciated. Also, with the images you can specify a link, with the audio or video, instead of the title in the windows media controls could there be an image or text below the controls??

    Thanks

    Demonllama
    Share on Google+

  2. #2
    Join Date
    Apr 2005
    Location
    Philippines
    Posts
    92
    i only know how to build more than one video or mp3, or sound file.. but its not randomly selected..

    by creating a playlist... the one at the top of the playlist will be the one played first.. then next.. then next.. then next... after playing all files in the playlist.. in your embed put loop=true.. so it will restart the playlist...

    put this in a notepad and save it as PLAYLIST.WAX exactly wat i coded.. just enter the specified file name or URL in the <REF href=""/> (note: dont remove the slash "/" sign)

    <ASX version ="3.0">
    <Entry>
    <Ref href="http://domain.com/yoursoundorvideofilehere1.mp3" />
    </Entry>
    <Entry>
    <Ref href="http://domain.com/yoursoundorvideofilehere2.mp3" />
    </Entry>
    <Entry>
    <Ref href="http://domain.com/yoursoundorvideofilehere3.mp3" />
    </Entry>
    <Entry>
    <Ref href="http://domain.com/yoursoundorvideofilehere4.mp3" />
    </Entry>
    <Entry>
    <Ref href="http://domain.com/yoursoundorvideofilehere5.mp3" />
    </Entry>
    </ASX>


    after youve done with the playlist.wax.. in your <embed> tag.. locate your playlist.wax in the SRC="http://domain.com/playlist.wax"

    thats it.. and by the way.. can you share the random displaying of the images?? pls...
    if theres someone to ask for, dont hesitate...
    Share on Google+

  3. #3
    Join Date
    Apr 2006
    Location
    South Carolina
    Posts
    168

    Cool

    i think this is what you're looking for...

    <script type="text/javascript">

    var embed=Math.floor(Math.random()*5);

    document.write('<embed src="'+embed+'.mp3">')

    </script>


    and then have your mp3's named 0.mp3, 1.mp3, 2.mp3, and so on.
    change the (Math.random()*5) 5 to the number of files you have minus 1.
    (because it starts with zero)
    Share on Google+

  4. #4
    Join Date
    Feb 2006
    Location
    Atlanta
    Posts
    218

    Well...

    Close

    HTML Code:
    <script language="javascript">
    var list  = new Array;
    list[0] = "<embed='yahyahyah.mp3'>";
    list[1] = "<embed='yahyahyah.mp3'>";
    list[2] = "<embed='yahyahyah.mp3'>";
    list[3] = "<embed='yahyahyah.mp3'>";
    list[4] = "<embed='yahyahyah.mp3'>";
    list[5] = "<embed='yahyahyah.mp3'>";
    var choice = Math.floor(Math.random() *  list.length);
    document.write(choice);
    </script>
    Fill in the embed tags though
    David (AltF4)
    Share on Google+

  5. #5
    Join Date
    Apr 2006
    Posts
    6

    I don't think I quite understand...

    Here is what I have.

    <script language="javascript">
    var list = new Array;
    list[0] = "<embed='http://xxxxxxxx.com/storage/audio/bigdumbface-burgalveist.mp3'>";
    list[1] = "<embed='http://xxxxxxxxx.com/storage/audio/cannibalcorpse-stripped.mp3'>";
    list[2] = "<embed='http://xxxxxxxxxxxx.com/storage/audio/cob-chokehold.mp3'>";
    list[3] = "<embed='http://xxxxxxxxx.com/storage/audio/deicide-children.mp3'>";
    list[4] = "<embed='http://xxxxxxxxx.com/storage/audio/dying-rapedonthealtar.mp3'>";
    list[5] = "<embed='http://xxxxxxxxxx.com/storage/audio/fallguy-phoenix.mp3'>";
    list[6] = "<embed='http://xxxxxxxxx.com/storage/audio/marvin-getiton.mp3'>";
    list[7] = "<embed='http://xxxxxxxx.com/storage/audio/slayer-angelofdeath.wma'>";
    list[8] = "<embed='http://xxxxxxxxxx.com/storage/audio/snoop-whoami.mp3'>";
    list[9] = "<embed='http://xxxxxxxxxxx.com/storage/audio/walk.mp3'>";
    var choice = Math.floor(Math.random() * 9 list.length);
    document.write(choice);
    </script>



    What am I missing?
    Share on Google+

  6. #6
    Join Date
    Apr 2006
    Location
    South Carolina
    Posts
    168
    on the line

    var choice = Math.floor(Math.random() * 9 list.length);

    delete the 9
    Share on Google+

  7. #7
    Join Date
    Apr 2006
    Posts
    6
    Still doesn't seem to be working...


    I take that back, it works... it chooses a random one but it doesn't play the file...


    This is what I have now...

    <script language="javascript">
    var list = new Array;
    list[0] = "<embed='http://x.com/storage/audio/0.mp3'>";
    list[1] = "<embed='http://x.com/storage/audio/1.mp3'>";
    list[2] = "<embed='http://x.com/storage/audio/2.mp3'>";
    list[3] = "<embed='http://x.com/storage/audio/3.mp3'>";
    list[4] = "<embed='http://x.com/storage/audio/4.mp3'>";
    list[5] = "<embed='http://x.com/storage/audio/5.mp3'>";
    list[6] = "<embed='http://x.com/storage/audio/6.mp3'>";
    list[7] = "<embed='http://x.com/storage/audio/7.wma'>";
    list[8] = "<embed='http://x.com/storage/audio/8.mp3'>";
    list[9] = "<embed='http://x.com/storage/audio/9.mp3'>";
    var choice = Math.floor(Math.random() * list.length);
    document.write(choice);
    </script>
    Last edited by Maynard123; 04-07-2006 at 09:28 PM.
    Share on Google+

  8. #8
    Join Date
    Apr 2006
    Location
    South Carolina
    Posts
    168

    Cool

    instead of just saying

    list[0] = "<embed='http://x.com/storage/audio/0.mp3'>";

    try

    list[0] = "<embed src='http://x.com/storage/audio/0.mp3'>";

    for all of the list[] elements.
    Share on Google+

  9. #9
    Join Date
    Apr 2006
    Posts
    6
    No go...
    Share on Google+

  10. #10
    Join Date
    Feb 2006
    Location
    Atlanta
    Posts
    218

    Well...

    <embed src="yah.mp3" autostart="yes">
    David (AltF4)
    Share on Google+

  11. #11
    Join Date
    Apr 2006
    Posts
    6
    Quote Originally Posted by AltF4
    <embed src="yah.mp3" autostart="yes">
    This works but not for the random list stuff...
    Last edited by Maynard123; 04-07-2006 at 11:27 PM.
    Share on Google+

  12. #12
    Join Date
    Jan 2005
    Location
    Illinois
    Posts
    815
    HTML Code:
    <script language="javascript">
    var list = new Array;
    list[0] = "0.mp3";
    list[1] = "1.mp3";
    list[2] = "2.mp3";
    list[3] = "3.mp3";
    list[4] = "4.mp3";
    list[5] = "5.mp3";
    list[6] = "6.mp3";
    list[7] = "7.wma";
    list[8] = "8.mp3";
    list[9] = "9.mp3";
    var choice = Math.floor(Math.random() * list.length);
    document.write("<embed src='http://x.com/storage/audio/"+list[choice]+"' autostart='yes'>");
    </script>
    --Steve
    Save The Shirts!
    Don't overuse exclamation marks!!!!!!
    Share on Google+

  13. #13
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    You are still missing the </embed> tag. Also the embed tag is deprecated and wont work on modern browsers where you should be using the <object> tag instead.

    Fortunately I have just installed some Javascript into my web browser to delete all of the <object> and <embed> tags in other people's web pages so that I don't have to put up with sounds that I don't want to hear and video that takes forever just to start to download.
    Stephen
    Share on Google+

  14. #14
    Join Date
    Apr 2006
    Posts
    6
    Thanks Balloon... Works beautifully.
    Share on Google+

  15. #15
    Join Date
    Apr 2006
    Posts
    6
    Quote Originally Posted by felgall
    You are still missing the </embed> tag. Also the embed tag is deprecated and wont work on modern browsers where you should be using the <object> tag instead.

    Fortunately I have just installed some Javascript into my web browser to delete all of the <object> and <embed> tags in other people's web pages so that I don't have to put up with sounds that I don't want to hear and video that takes forever just to start to download.

    Actually it worked and I'm putting it on my website but I'm not linking to it, I just thought it would be nice to listen to music while doing work at school without jeopardizing my 400 dollar mp3 player.
    Share on Google+

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles