martin
February 28, 2003, 1:16pm
1
i have got the code working so that there are no errors and i have have
tripled checked instance names and everything but i cant see why it isnt
working
fact is i just aint good enough
any help getting this to work would be greatly appreciated - i reckon its
only a tiny typo or summit but my eyes are about ready to be traded in
many thanks for your time and help people
here are the links to the files
http://www.accepted-designs.com/mp3play/mp3_xml_player.fla
http://www.accepted-designs.com/mp3play/mp3_xml_player.swf
http://www.accepted-designs.com/mp3play/playlist.xml
system
February 28, 2003, 3:41pm
3
hmmz there is actually an mp3 player component that uses xml to load the required information already
maybe u can check it out…
http://componenthq.entclosure.com/?id=26
system
February 28, 2003, 3:57pm
4
thanks eudora
have had a look at the component and it is pretty good will prolly use it as a short term fix
i have spent too long on this monster to give up so will continue to attempt to get it working :crazy:
it will not beat me :rambo:
thanks again for the reply
system
February 28, 2003, 4:05pm
5
no prob
i not gd with xml and flash at all so cant help u debug… hehe
u can wait for the experts to help u
system
March 11, 2003, 6:40am
6
your code doesn’t parse the xml correctly… try this:
function init() {
_global.stream = false;
_global.loop = false;
_global.paused = false;
_global.playlist = true;
setTrackStatus("stop");
playlist.gotoAndStop(2);
updateSettings();
loadSongList("play.xml");
init();
////////////////////////////////////////////////////////////////
////////////// Display Functions ///////////////////////////////
// Load Play List
function loadSongList(URL){
//create new XML
this.mySongList = new XML();
this.mySongList.ignoreWhite = true;
this.mySongList.load(URL);
//callback function creates a playlist
this.mySongList.myClip = this;//onLoad is referenced to the XML so first create a reference to self
this.mySongList.onLoad = function(){
// this now refers to the XML and myClip is used to pass the movieclip reference
this.myClip.makePlayList(this);
};
}
function makePlayList(myPlayListXML){
//Hardwired XML reader to read the XML playlist.
//First get the number of songs
this.songNumber = myPlayListXML.firstChild.firstChild.childNodes.length;
//create playlist object
this.PlayList = new Array(); //new object created
this.songList = new XML();
this.songList = myPlayListXML.firstChild.firstChild;
this.mySong = this.songList.firstChild;
for (var i=0; i<this.songNumber; i++){
song = this.mySong.firstChild.firstChild.nodeValue;
src = this.mySong.firstChild.nextSibling.firstChild.nodeValue;
artist = this.mySong.firstChild.nextSibling.nextSibling.firstChild.nodeValue;
this.PlayList* = {label:artist + " - " + song, artist:artist, song:song, source:src};
this.mySong = this.mySong.nextSibling;
}
this.displayPlayList()
}
function displayPlayList(){
playlistHolder.myListBox.setDataProvider(PlayList);
playlistHolder.myListBox.setSelectedIndex(0);
playlistHolder.myListBox.setAutoHideScrollBar(true);
playlistHolder.myListBox.setChangeHandler("playTrack",_root);
}
function updateSettings() {
fldStream.text = "streaming";
fldLoop.text = "looping";
if(_global.stream){
fldStream.textColor = "0x00CC00";
}else{
fldStream.textColor = "0x336600";
positionSlider.btnPosSlider._visible = true;
}
if(_global.loop){
fldLoop.textColor = "0x00CC00";
}else{
fldLoop.textColor = "0x336600";
}
}
function displaySong() {
display.text = playlistHolder.myListBox.getSelectedItem().artist + "
";
display.text = display.text + playlistHolder.myListBox.getSelectedItem().song;
}
function showPlaylist(flag) {
playlistHolder._visible = flag;
}
function sliderControl(){
if(_global.stream){
positionSlider.btnPosSlider._visible = false;
}else{
positionSlider.btnPosSlider._visible = true;
}
if(!_global.seekDrag){
positionSlider.btnPosSlider._x = (252 / _global.duration) * _global.position;
}
if (_global.volumeDrag) {
display.text = "Volume: " + _global.volume + "%";
}else if(_global.seekDrag){
display.text = "Seek to: " + newTrackTime.minutes + ":" +newTrackTime.seconds + "/" + totalTrackTime.minutes + ":" + totalTrackTime.seconds;
display.text = display.text + " <" + newTrackTime.percent + "%>";
} else if(_global.error){
display.text = "Loading failed!";
}else{
displaySong();
}
}
function setTrackStatus(flag){
trackStatus.gotoAndStop(flag);
}
//////////////////////////////////////////////////////////////////
//////////// General SoundObject Functions ///////////////////////
function playTrack (startPos, streaming) {
mySound = new Sound ();
mySound.stop ();
mySound._soundbuftime = 5; // seconds
mySound.onLoad = function(success){
if(success){
_global.error = false;
mySound.start (startPos, 1);
trackTimeDisplay.text = remainingTrackTime.minutes + ":" + remainingTrackTime.seconds;
displaySong();
}else{
_global.error = true;
}
}
choosenTrack = playlistHolder.myListBox.getSelectedItem().source;
if(streaming){
mySound.loadSound (choosenTrack, streaming);
}else if(_global.paused){
_global.paused = false;
mySound.loadSound (choosenTrack, streaming);
mySound.start (_global.pausedPosition, 1);
setTrackStatus("play");
}else{
mySound.loadSound (choosenTrack, streaming);
mySound.start (startPos, 1);
setTrackStatus("play");
}
}
function stopTrack () {
mySound.stop ();
setTrackStatus("stop");
}
function pauseTrack(){
_global.paused = true;
_global.pausedPosition = (mySound.position/1000);
mySound.stop();
setTrackStatus("pause");
}
function nextTrack () {
if(playlistHolder.myListBox.getSelectedIndex() == playlistHolder.myListBox.getLength()-1){
playlistHolder.myListBox.setSelectedIndex(0);
playTrack (0, _global.stream);
}else{
playlistHolder.myListBox.setSelectedIndex(playlistHolder.myListBox.getSelectedIndex () + 1);
playTrack (0, _global.stream);
}
}
function prevTrack () {
if(playlistHolder.myListBox.getSelectedIndex() == 0){
playlistHolder.myListBox.setSelectedIndex (playlistHolder.myListBox.getLength()-1);
playTrack (0, _global.stream);
}else{
playlistHolder.myListBox.setSelectedIndex (playlistHolder.myListBox.getSelectedIndex () - 1);
playTrack (0, _global.stream);
}
}
function setSeek(){
mySound.stop();
mySound.start (_global.newPosition, _global.stream);
setTrackStatus("play");
}
////////////////////////////////////////////////////////////////////
// ClipEventHandler
_root.onEnterFrame = function(){
// Sound settings Global Vars
_global.volume = volumeSlider.btnSlider._x;
_global.duration = int(mySound.duration /1000); //seconds
_global.position = int(mySound.position /1000); //seconds
_global.newPosition = (_global.duration / 252) * positionSlider.btnPosSlider._x;
// Volume Control
mySound.setVolume(_global.volume);
// Control Sliders
sliderControl();
// Track Time
totalTrackTime = {};
totalTrackTime.minutes = int(_global.duration/60);
totalTrackTime.seconds = int(_global.duration%60);
newTrackTime = {};
newTrackTime.minutes = int(((_global.duration / 252) * positionSlider.btnPosSlider._x)/60);
newTrackTime.seconds = int(((_global.duration / 252) * positionSlider.btnPosSlider._x)%60);
newTrackTime.percent = int((_global.duration / 252) * positionSlider.btnPosSlider._x / (_global.duration)*100);
if(newTrackTime.seconds < 10){
newTrackTime.seconds = "0" + newTrackTime.seconds;
}
remainingTrackTime = {};
remainingTrackTime.minutes = int((_global.duration - _global.position )/ 60);
remainingTrackTime.seconds =int(( _global.duration - _global.position )%60);
if(remainingTrackTime.seconds < 10){
remainingTrackTime.seconds = "0" + remainingTrackTime.seconds;
}
trackTimeDisplay.text = remainingTrackTime.minutes + ":" + remainingTrackTime.seconds;
////////////////////////////////////////////////////////////////////
// Sound EventHandler
mySound.onSoundComplete = function(){
if(_global.loop){
playTrack (0, _global.stream);
}else{
if(playlistHolder.myListBox.getSelectedIndex() == playlistHolder.myListBox.getLength()-1){
playlistHolder.myListBox.setSelectedIndex(0);
playTrack (0, _global.stream);
}else{
playlistHolder.myListBox.setSelectedIndex(playlistHolder.myListBox.getSelectedIndex () + 1);
playTrack (0, _global.stream);
}
}
}
///////////////////////////////////////////////////////////////////
// LoadBar Handler
total = mySound.getBytesTotal()/1024;
loaded = mySound.getBytesLoaded()/1024;
percent = loaded / total * 100;
positionSlider.loaderBar._xscale = percent;
}
////////////////////////////////////////////////////////////////////
that doesn’t include button functions but it’d work…