Simple Playlist

mikeandike22 1 Tallied Votes 294 Views Share

So im new to the PHP world because I have to learn it for work. So one of my clients is a musician and wanted a music player so I made a simple way the user could click a link and load a song.


ok first I set the variable that would change inside the player which I made "$song" and the variable is retreiving the song information from the url. Then in the urls you can see I set the attribute song equal to the mp3 file I want to load.
So now the page loads and when you click a link it gets the $song data from the url. The next step is to insert it into the player where the source was I put in the variable $song. And now your users can click the links and load what ever song they like. I know it is very basic but it gives the user more control over the quicktime player that you would normally need to use a flash player for.

LastMitch commented: Nice! Thanks for sharing! +12
<?php
$song = $_GET['song'];
echo '<a href="/jacobsite/music.php?song=Shpadoinkle.mp3">Shpadoinkle</a><br/>';
echo '<a href="/jacobsite/music.php?song=Dani_California.mp3">Dani California</a><br/>';

echo '<embed qtsrc='.$song.' height"256" width="320" src='.$song.' type="image/x-quicktime" pluginspage="[http://www.apple.com/quicktime/download/]" autoplay="true">';
?>
Member Avatar for LastMitch
LastMitch

ok first I set the variable that would change inside the player which I made "$song" and the variable is retreiving the song information from the url. Then in the urls you can see I set the attribute song equal to the mp3 file I want to load.So now the page loads and when you click a link it gets the $song data from the url. The next step is to insert it into the player where the source was I put in the variable $song. And now your users can click the links and load what ever song they like. I know it is very basic but it gives the user more control over the quicktime player that you would normally need to use a flash player for.

This is very creative and it was a simple code snippet. I enjoy playing around with it. Thanks for sharing.

I attached an image of how it looks like:

306fe5e751fd2db899dc7bdd81979154

dannette 4 Newbie Poster

You may want to look into JW Player for a nice looking player as well. You can use the path to the video as the variable. I combine the js code (they give tons of example code) along with php code to put several on a page.

Member Avatar for diafol
diafol

Flowplayer too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.