Quick install

How make a linux jukebox (my old paper)

iTux - English - Italian

Install iSmash on iTux box

INSTALL - English

Search

 

Contribute

 

Do you want to develop iSmash? You can develop code, plugins, create theme or translate iSmash in other languages. Contact me to nixw0rm [at] gmail [dot] com

LIBPHPLAY 0.1

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>

------------------------------------------------------------------------

HOW TO USE THIS LIBPHPLAY v0.1:

Include in your php source page this line:

include "lib/id3tagreader/func.inc.php";

so you can use functions and php classes included in this package

less samples into sample/ for example.




MAIN CLASS GUIDE


USE:

Class Track

1) to create a new mp3 track object:

$track=new Track;
$track->createTrack("test.mp3");

and automatically extracts ID3 tags from test.mp3!!

2) $track->getArtist(); //return id3 artist from test.mp3

3) $track->getTitle(); //return id3 title from test.mp3

4) $track->getAlbum(); //return id3 album from test.mp3

5) $track->getGender(); //return id3 gender from test.mp3

6) $track->getYear(); //return id3 year from test.mp3



SERVER SIDE:

7) Playing on remote server (useful for Lan jukebox):

$track->playOnServer($player, $argument);

//$player is a used player with commandline $argument

ex. $track->playOnServer("mpg321"); //play the $track with mplayer

or

$track->playOnServer(); //playing with the default player (mpg321)


8) Stop on remote server (useful for Lan jukebox):

$track->stopOnServer($player);

ex. $track.stopOnServer("mplayer");



Class Playlist

1) CREATE A PLAYLIST OBJECT

To create a new playlist track object:

$customlist=new Playlist;

1.1) you add the test.mp3 to playlist $customlist

$customlist->addTrack("test.mp3");

2) EXTRACT INFO TRACKS FROM LIST

$playlist=$customplaylist->getPlayList(); //extract full Playlist and copy into $playlist var

now playlist is an array where you can access to tracks in this way:

2.1) with a index variable between 1 and N, where N=total number tracks into list

echo $playlist[1]; print number 1 track from playlist

echo $playlist[2]; print number 2 track from playlist

................

echo $playlist[N]; print number N track from playlist

2.2) with a direct access class method getMidTrack(), in this way you don't need to use getPlayList() first,


$customplaylist->getMidTrack(1); print number 1 track from $customplaylist

$customplaylist->getMidTrack(2); print number 2 track from $customplaylist

.............................

$customplaylist->getMidTrack(N); print number N track from $customplaylist

2.3) Extract first or last track from playlist:

$last=$customplaylist->getLastTrack(); // extract last added track from playlist

$first=$customplaylist->getFirstTrack(); // extract first added track from playlist


2.4) Extract and select current selected/playing tracks from playlist (useful to build player frontend)

You can use a var called $currentplaylist->currentTrack to works like an index. The methods used are:

$customplaylist->setCurrent(value); // to set the value (into memory)

$customplaylist->getCurrent(); // to extract the value

$customplaylist->saveCurrToFile(filename); // to save the value into file on disk

$customplaylist->loadCurrFromFile(filename) //to load saved value from a file




Quick sample-> Let's take a look to this code to playing the track number 3 into playlist:

$value=$customplaylist->getMidTrack(3); //extract the number 3 track from playlist

$customplaylist->setCurrent($value); //set $cutomplaylist->currentTrack

$customplaylist->saveCurrToFile("current.txt"); //save the current track into current.txt file

$track=new Track; //create a new Track object named $track

$track->createTrack($value); //link the $value to $track object

$track->playOnServer(); //play current track

In another php page you can say current track playing loading current.txt file:

$customplaylist2=new Playlist; //create a new playlist object

$customplaylist2->loadCurrFromFile("current.txt"); //load $customplaylist2->currentTrack from current.txt

echo "Playing current Track: " . $customplaylist2->getCurrent(); //Show playing


3) SAVE AND LOAD PLAYLIST FROM FILE

$customplaylist->saveToFile("tmp/list.txt");

Warning: with this method you will lose the content of file!!!

Save playlist into tmp/list.txt file, and save all tracks list once for row separated by newline tab (escape char "\n").

$customplaylist->loadFromFile("tmp/list.txt");

Imports tracks to playlist from file. Previous tracks into playlist DON'T LOSE. New tracks will be added to playlist.
Every track is separated by newline tab.


4) EDIT A TRACK INTO PLAYLIST

$customplaylist->setMidTrack(3,"newsong.mp3")

replace the third track into $customplaylist with newsong.mp3.


Previous method make something like this:

$customplaylist[3]="newsong.mp3";


5) DELETE A TRACK FROM PLAYLIST

$customplaylist->delMidTrack(3);

Remove the track number 3 from $customplaylist.



6)CONVERSION FROM A TYPE TO ANOTHER

6.1) Convert from a var to array

Example:

$var_array=$customplaylist->convertToArray();

NB: index starts from 0. ex $var_array[0], $var_array[1], ....

7) SAVE AND LOAD PLAYLIST FROM A MEMORY BY A LOCAL SESSION

7.1) Save playlist into memory (page test1.php)

session_start();
.....
$playlist->saveIntoMem("address_playlist");


7.2) Load playlist from memory to another php page (page test2.php)

session_start();
.....
$old_playlist=new Playlist;
$old_playlist->loadFromMem("address_playlist");

NB: $old_playlist is $playlist data


Class Queue

USE:


1) CREATE A NEW QUEUE:

$mp3Queue=new Queue;

2) ADDING TRACK TO $mp3Queue:

$mp3Queue->put("Track1.mp3"); //Adding track1.mp3 to queue
$mp3Queue->put("Track2.mp3"); //Adding track2.mp3 to queue


3) EXTRACT FRONT TRACK FRONT QUEUE

$front=$mp3Queue->get(); //Get front track from queue


4) DELETE A TRACK FROM QUEUE

$mp3Queue->delMidTrack(N); //Delete track number N from queue


5) EDIT A TRACK INTO QUEUE

$mp3Queue->setMidTrack(4, "othersong.mp3"); //Replace the fourth song with "othersong.mp3" into queue

6) SAVE AND LOAD TO/FROM FILE

$mp3Queue->saveToFile("temp.txt"); //Save into temp.txt file the queue

$mp3Queue->loadFromFile("temp.txt"); //load from temp.txt the queue

7) SAVE AND LOAD TO/FROM MEMORY BY A PHP SESSION

$mp3Queue->saveIntoMem($address); //save a queue by $address to memory by $_SESSION[] global array

$mp3Queue->LoadFromMem($address); ////save a queue by $address from memory by $_SESSION[] global array


Class Stack

USE:


1) CREATE A NEW STACK:

$mp3Stack=new Stack;

2) ADDING TRACK TO $mp3Stack:

$mp3Stack->push("Track1.mp3"); //Adding track1.mp3 to stack
$mp3Stack->push("Track2.mp3"); //Adding track2.mp3 to stack


3) EXTRACT TRACK FRONT STACK

$front=$mp3Stack->pop(); //Get track from stack


5) EDIT A TRACK INTO Stack

$mp3Stack->setMidTrack(4, "othersong.mp3"); //Replace the fourth song with "othersong.mp3" into stack

6) SAVE AND LOAD TO/FROM FILE

$mp3Stack->saveToFile("temp.txt"); //Save into temp.txt file the stack

$mp3Stack->loadFromFile("temp.txt"); //load from temp.txt the stack

7) SAVE AND LOAD TO/FROM MEMORY BY A PHP SESSION

$mp3Stack->saveIntoMem($address); //save a stack by $address to memory by $_SESSION[] global array

$mp3Stack->LoadFromMem($address); ////save a stack by $address from memory by $_SESSION[] global array


Class gender

USE:


1) CREATE A NEW GENDER object:

$genderList=new Gender;

2) ADDING gender TO $genderList:

$genderList->addGender("Blues"); //Adding "Blues" to genderList
$genderList->addGender("My gender"); //Adding "My gender" to genderList


3) EXTRACT GENDER FRONT LIST

$gender=$genderList->getGender(5); //Get number 5 gender from genderList id (5)

NB: if doesn't exist the number into gender list then will be returned the value given (in this time is 5)

4) GET ID GENDER

$idgender=$genderList->findGender("findvalue"); //return id's gender from genderList


5) EDIT A GENDER INTO GENDER

$genderList->setGender(4, "othersong.mp3"); //Replace the fourth song with "othersong.mp3" into genderList

6) SAVE AND LOAD TO/FROM FILE

$genderList->saveToFile("temp.txt"); //Save into temp.txt file the gender list

$genderList->loadFromFile("temp.txt"); //load from temp.txt the gender list