The player is on a different frame, which is accessed by clicking the correct Nav Bar link. This works fine.
Visitors can then browse the rest of the website with songs still playing in the background.
The problem I have is that if they go back into the player, the timer kind of glitches out and the song is stopped and a new one started. I'd liek the timers to work properly, and for the song to carry on, rather than a new one starting.
My live example is here: http://www.nonplayer...o.uk/bands/tbc/
(Go to Media > Player)
here is the code I'm using on the player page:
stop(); display_txt.autoSize = "left"; mutebeat = true; Beat1.stop(); stopAllSounds(); playlist = new XML(); playlist.ignoreWhite = true; playlist.onLoad = function(success) { if (success) { _global.songname = []; _global.songband = []; _global.songfile = []; for (var i = 0; i<playlist.firstChild.childNodes.length; i++) { _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name; _global.songband[i] = playlist.firstChild.childNodes[i].attributes.band; _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file; //trace(songname[i]+" "+songfile[i]+" "+songband[i]); } } _root.createEmptyMovieClip("sound_mc", 1); _global.song_nr = random(songfile.length); playing = true; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); }; function timer(sound_obj) { time = sound_obj.position/1000; min = Math.floor(time/60); min = (min<10) ? "0"+min : min; sec = Math.floor(time%60); sec = (sec<10) ? "0"+sec : sec; timeDisplay_txt.text = min+":"+sec; } MovieClip.prototype.songStarter = function(file, name, band) { if (this.sound_obj) { this.sound_obj.stop(); delete this.sound_obj; } this.sound_obj = new Sound(this); this.sound_obj.loadSound(file, true); this.onEnterFrame = function() { if (this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text = this._parent.display_txt.text=name+" - "+band; this._parent.display_band.text = songband[song_nr]; timeInterval = setInterval(timer, 1000, this.sound_obj); setInterval(soundStatus, 100); } else { this._parent.display_txt.text = "loading..."; } }; this.sound_obj.onSoundComplete = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text = "00:00"; (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); }; this._parent.volume2.drag2.onPress = function() { startDrag(this, true, this._x, this._parent.volBG2._height, this._x, 0); this.onEnterFrame = function() { var p = (this._y/this._parent.volBG2._height)*100; var vp = 100-p; this._parent._parent.sound_mc.sound_obj.setVolume(vp); }; }; this._parent.volume2.drag2.onRelease = function() { delete this.onEnterFrame; stopDrag(); }; this._parent.volume2.drag2.onReleaseOutside = function() { stopDrag(); }; }; btn_play.onRelease = function() { if (pause == true) { this._parent.sound_mc.sound_obj.start(posiP); pause = false; playing = true; } else { clearInterval(timeInterval); this._parent.timeDisplay_txt.text = "00:00"; this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); playing = true; } }; btn_stop.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text = "00:00"; this._parent.sound_mc.sound_obj.stop(); pause = false; playing = false; }; btn_next.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text = "00:00"; (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); }; btn_prev.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text = "00:00"; (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); }; btn_pause.onRelease = function() { //pause button function this._parent.sound_mc.sound_obj.stop(); //stop the current sound posiP = _root.sound_mc.sound_obj.position/1000; // save the current position in a new variable and divide by 1000 (ms -> sec) pause = true; //set the variable pause to true }; function soundStatus() { var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded()/_root.sound_mc.sound_obj.getBytesTotal(); _root.loader.loadBar._width = amountLoaded*170; duration = _root.sound_mc.sound_obj.duration; position = _root.sound_mc.sound_obj.position; _root.playHead._x = position/duration*161+228; } function duration() { timed = _root.sound_mc.sound_obj.duration/1000; mind = Math.floor(timed/60); mind = (mind<10) ? "0"+mind : mind; secd = Math.floor(timed%60); secd = (secd<10) ? "0"+secd : secd; totalDuration = mind+":"+secd; } playlist.load("xml/playlist.xml"); setInterval(duration, 100); setInterval(soundStatus, 100);
thanks