Jump to content
php.lv forumi

php ģenerē playlist


ziedinjsh

Recommended Posts

pēc pamācības uztaisīju flash playeri.

šeit ir action scripts:

// Setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);

// Array of songs
var sa:Array = new Array();

// Currently playing song
var cps:Number = -1;

// Position of music
var pos:Number;

// Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
	sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.track));
}
playSong();
}

xml.load("songs.xml");

// Play the MP3 File
function playSong():Void
{
s = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
mute.gotoAndStop("on");
if(cps == sa.length - 1)
{
	cps = 0;
	s.loadSound(sa[cps].earl, true);
}
else
{
	s.loadSound(sa[++cps].earl, true);
}
trackInfo.text = sa[cps].artist + " - " + sa[cps].track;
playPause.gotoAndStop("pause");
textPos = 0;
}

// Pauses the music
function pauseIt():Void
{
pos = s.position;
s.stop();
}

// Pauses the music
function unPauseIt():Void
{
s.start(pos/1000);
}

// Music Controls

// Play/Pause Toggle
playPause.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop("pauseOver");
else this.gotoAndStop("playOver");
}

playPause.onRollOut = playPause.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop("pause");
else this.gotoAndStop("play");
}

playPause.onRelease = function()
{
if(this._currentframe == 10)
{
	this.gotoAndStop("playOver");
	this._parent.pauseIt();
}
else
{
	this.gotoAndStop("pauseOver");
	this._parent.unPauseIt();
}
}

// Next Button
next.onRollOver = function()
{
this.gotoAndStop("nextOver");
}

next.onRollOut = next.onReleaseOutside = function()
{
this.gotoAndStop("next");
}

next.onRelease = function()
{
this._parent.playSong();
}

// Mute Button
mute.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop("onOver");
else this.gotoAndStop("offOver");
}

mute.onRollOut = mute.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop("on");
else this.gotoAndStop("off");
}

mute.onRelease = function()
{
if(this._currentframe == 10)
{
	this.gotoAndStop("offOver");
	s.setVolume(0);
}
else
{
	this.gotoAndStop("onOver");
	s.setVolume(75);
}
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Text scroller bonus code

var size:Number = 21;
var textPos:Number = 0;
var intervalID:Number = setInterval(scroller, 1000);

function scroller():Void
{
var t:String = (sa[cps].artist + " - " + sa[cps].track);
if(textPos+size < t.length)
{
	textPos++;
	trackInfo.text = (sa[cps].artist + " - " + sa[cps].track).substring(textPos, textPos+size);
}
else 
{
	clearInterval(intervalID);
	intervalID = setInterval(scroller2, 1000);
}
}

function scroller2():Void
{
var t:String = (sa[cps].artist + " - " + sa[cps].track);
if(textPos > 0)
{
	textPos--;
	trackInfo.text = (sa[cps].artist + " - " + sa[cps].track).substring(textPos, size);
}
else 
{
	clearInterval(intervalID);
	intervalID = setInterval(scroller, 1000);
}
}










 

šādi ievietoju viņu lapā

echo "<object width='300' height='50'>";
echo "<param name='movie' value='misc/mp3Player.swf'>";
echo "<embed src='misc/mp3Player.swf' width='300' height='50'>";
echo "</embed></object>";

 

un šis ir php kas ģenerē playlist

include("misc/dbase.php");


$query = mysql_query('SELECT * FROM songs');
$xml = '';



while ( $data = mysql_fetch_array ( $query ) ){

   $xml .= "<song>\r\n";
   $xml .= '<filename>' . $data['song'] . "</filename>\r\n";
   $xml .= '<artist>' . $data['author'] . "</artist>\r\n";
   $xml .= '<songname>' . $data['title'] . "</songname>\r\n";
   $xml .= "</song>\r\n";
}

$handle = fopen('songs.xml', 'w+');
fwrite($handle, $xml);

 

Situācija sekojoša.. plejeris nenolasa neko.. rāda undefined tur kur būtu jārāda izpildītājs un dziesmas nosaukums

Link to comment
Share on other sites

nūū.. mjā.. playlist ģenerātors ir šāds.

 

songs.php:

<?php
header("Content-type:text/xml");
include("misc/dbase.php");

$query = mysql_query('SELECT * FROM songs WHERE type="1" ORDER BY id DESC');

$xml = "<?xml version='1.0' encoding='UTF-8'?>";
$xml .= "<xml>";

while ( $data = mysql_fetch_array ( $query ) ){

$xml .= "
<song>
<artist>".$data['song']."</artist>
<url>mp3/".$data['song']."</url>
</song>";
}

$xml .= "</xml>";
echo $xml;
?>

 

atverot viņu browserī smuki izvadās it kā ārā:

<xml>
<song>
<artist>D7 - Sleepwalker.mp3</artist>
<url>mp3/D7 - Sleepwalker.mp3</url>
</song>
<song>
<artist>D7 - Changes.mp3</artist>
<url>mp3/D7 - Changes.mp3</url>
</song>
<song>
<artist>D7 - Just a Test (Go! Orginal Mix).mp3</artist>
<url>mp3/D7 - Just a Test (Go! Orginal Mix).mp3</url>
</song>
<song>
<artist>D7 - They Need Space.mp3</artist>
<url>mp3/D7 - They Need Space.mp3</url>
</song>
<song>
<artist>D7 - Will Never Be The Same.mp3</artist>
<url>mp3/D7 - Will Never Be The Same.mp3</url>
</song>
</xml>

 

Bet palyerī vienalga neskan! kas pa vainu?

Link to comment
Share on other sites

Secinām ko tas nozīmē...

 

1) "Plejliste" nav valīda,

2) Kas ir Man "plejliste"?,

3) Hmmm...,

4) XML fails,

5) Skaidrs, XML fails nav valīds,

6) Jāiet tas ierakstīt PHP.lv/f...

 

Ne gluži! Pašam ir jāmēģina problēmas risināt!

 

...kā jau briedis teica, XML fails nav valīds!

 

7) Atveram Google.lv un rakstam "XML",

8) Divas stundiņas palasam (gan jau - noderēs),

9) Saprotam, ka XML fails nav valīds,

10) Izlabojam to!

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...