Jump to content

YouTube


pcman

Recommended Posts

There's really no reason for you to make your own MP3 player.

Most browsers nowadays either have functionality for playing MP3s built in, or have plugins that can play them (such as Quicktime, Java, or Flash).

No need to reinvent the wheel.

Link to comment
Share on other sites

  • 2 weeks later...

Fine Ill walk ya throught it. You should use XML/SWF/And Html. Most people think its a PHP thing. Ayways here ya go.

 

Radio.xml source

<?xml version="1.0" encoding="UTF-8"?>
<radio>
  <station name="Rock">
    <song>
      <title>Ol' 55</title>
      <composer>Tom Waits</composer>
      <file>tomwaits_ol55.mp3</file>
    </song>
    <song>
      <title>King Contrary Man</title>
      <composer>The Cult</composer>
      <file>thecult_kingcontraryman.mp3</file>
    </song>
    <song>
      <title>Drunken Chorus</title>
      <composer>The Trashcan Sinatras</composer>
      <file>trashcansinatras_drunkenchorus.mp3</file>
    </song>
  </station>
  <station name="Rap">
    <song>
      <title>Follow the Leader</title>
      <composer>Eric B. & Rakim</composer>
      <file>ericbrakim_followtheleader.mp3</file>
    </song>
    <song>
      <title>My Philosophy</title>
      <composer>Boogie Down Productions</composer>
      <file>bdp_myphilosophy.mp3</file>
    </song>
    <song>
      <title>I Pioneered This</title>
      <composer>M.C. Shan</composer>
      <file>mcshan_ipioneeredthis.mp3</file>
    </song>
  </station>
  <station name="Country">
    <song>
      <title>Mama Tried</title>
      <composer>Merle Haggard</composer>
      <file>merlehaggard_mamatried.mp3</file>
    </song>
    <song>
      <title>A Boy Named Sue</title>
      <composer>Johnny Cash</composer>
      <file>johnnycash_aboynamedsue.mp3</file>
    </song>
    <song>
      <title>Big Iron</title>
      <composer>Marty Robbins</composer>
      <file>martyrobbins_bigiron.mp3</file>
    </song>
  </station>
</radio>

 

Radio.html Source

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>XML Radio Example</title>
  </head>

  <body>
    <h2>XML Radio Example</h2>
    <p>
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
      width="750" height="375" id="GH_radiov2">
        <param name="movie" value="GH_radiov2.swf"> <param name="quality" value="high" />
        <param name="bgcolor" value="#666666" />
        <embed src="GH_radiov2.swf" quality="high" bgcolor="#666666" width="750" height="375" name="GH_radiov2"
        type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
      </object>
    </p>
  </body>
</html>

 

GH_radiov2.swf Actionscript Source Frame 1

function Song(title, composer, file)
{
    this.title = title;
    this.composer = composer;
    this.file = file;
} // End of the function
function Station(name, arrSongs)
{
    this.name = name;
    this.arrSongs = arrSongs;
} // End of the function
function Radio(arrStations)
{
    this.arrStations = arrStations;
} // End of the function
function traceRadio(objRadio)
{
    for (j = 0; j < objRadio.arrStations.length; j++)
    {
        traceStation(objRadio.arrStations[j]);
    } // end of for
} // End of the function
function traceStation(objStation)
{
    trace ("-----------------");
    trace ("Station Name: " + objStation.name);
    for (i = 0; i < objStation.arrSongs.length; i++)
    {
        traceSong(objStation.arrSongs[i]);
    } // end of for
} // End of the function
function traceSong(objSong)
{
    trace ("title: " + objSong.title);
    trace ("composer: " + objSong.composer);
    trace ("file: " + objSong.file);
    trace ("**");
} // End of the function
function loadStations()
{
    mcStations.removeAll();
    var i = 0;
    while (i < objRadio.arrStations.length)
    {
        mcStations.addItem(objRadio.arrStations[i].name, i);
        ++i;
    } // end while
} // End of the function
function radioPlay()
{
    trace (">>start");
    traceSong(objRadio.arrStations[intStation].arrSongs[intSong]);
    txtTitle = objRadio.arrStations[intStation].arrSongs[intSong].title;
    txtStation = objRadio.arrStations[intStation].name;
    txtComposer = objRadio.arrStations[intStation].arrSongs[intSong].composer;
    if (!s)
    {
        s = new Sound();
        s.onSoundComplete = function ()
        {
            _root.radioNext();
        };
    } // end if
    var filename = objRadio.arrStations[intStation].arrSongs[intSong].file;
    s.loadSound(filename, true);
    s.start();
    instStatus.posReset();
    instStatus.gotoAndPlay(1);
    mLoaded.paramTarget = "s";
    mLoaded._visible = true;
    mLoaded.gotoAndPlay(1);
} // End of the function
function radioStop()
{
    trace (">>stop");
    s.stop();
} // End of the function
function radioNext()
{
    ++intSong;
    if (intSong >= objRadio.arrStations[intStation].arrSongs.length)
    {
        intSong = 0;
    } // end if
    radioPlay();
} // End of the function
function radioPrevious()
{
    --intSong;
    if (intSong < 0)
    {
        intSong = objRadio.arrStations[intStation].arrSongs.length - 1;
    } // end if
    radioPlay();
} // End of the function
function stationNext()
{
    ++intStation;
    if (intStation >= objRadio.arrStations.length)
    {
        intStation = 0;
    } // end if
    intSong = 0;
    radioPlay();
} // End of the function
function stationPrevious()
{
    --intStation;
    if (intStation < 0)
    {
        intStation = objRadio.arrStations.length - 1;
    } // end if
    intSong = 0;
    radioPlay();
} // End of the function
cxml.url = "radio.xml";
intStation = 0;
intSong = 0;
_root.newSongArray = new Array();
_root.newStationArray = new Array();
_root.objRadio = new Radio();
stop ();

 

GH_radiov2.swf Actionscript Source Frame 2

intStation = 0;
intSong = 0;
radioPlay();
stop ();

 

See its not all that hard to do... lol ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.