buschmannd
Grünschnabel
Hai Leute
mein erster Beitrag hier im Forum, daher seid nicht böse wenn ich was falsch mache =). Nun aber zu mienm Problem:
ich habe mir mit einem Tuturial einen MP3-Player gebaut
http://87.139.116.112/buschi/mp3player/mp3player2.html. Mein Problem jedoch ist das man jedes Lied manuel starten muss, dh am Anfang muss man erstma auf Weiter und Paly drücken damit das erste Lied geladen wird. Wenn ein Lied fertig ist, so fängt auch kein Neues an. Ich bin in Flash noch sehr unerfahren (is mein erstes Projekt ) Also helft mir bitte =)
mfg buschmannd
//EDIT
ich habe das mit dem Tuturial hier ausm Forum gemacht ...sieht nur ganz naders aus
http://www.tutorials.de/forum/flash...-ein-audioplayer-mx2004-fortgeschrittene.html
mein erster Beitrag hier im Forum, daher seid nicht böse wenn ich was falsch mache =). Nun aber zu mienm Problem:
ich habe mir mit einem Tuturial einen MP3-Player gebaut
http://87.139.116.112/buschi/mp3player/mp3player2.html. Mein Problem jedoch ist das man jedes Lied manuel starten muss, dh am Anfang muss man erstma auf Weiter und Paly drücken damit das erste Lied geladen wird. Wenn ein Lied fertig ist, so fängt auch kein Neues an. Ich bin in Flash noch sehr unerfahren (is mein erstes Projekt ) Also helft mir bitte =)
Code:
slide_volume._label = "VOLUME";
slide_pan._label = "PANORAMA";
slide_position._label = "POSITION";
_global.player_root = this;
var song = new Sound(this);
var list = new Array();
var isplaying = false;
var ispaused = false;
var last_position = 0;
var current_song = -1;
// SONG EVENTS:
function initSound() {
song = new Sound();
song.onID3 = function() {
display.updateID3(this.id3);
}
}
function updateStatus() {
updateButtons();
if (isplaying && !ispaused) {
display.updateStatus("PLAYING", true);
var noduration = true;
this.onEnterFrame = function() {
if (song.duration > 0 && noduration) {
display.updateDuration(song.duration);
//noduration = false;
}
slide_position.setPerc(song.position * 100 / song.duration, false);
display.updatePosition(song.position, true);
}
} else {
delete this.onEnterFrame;
if (ispaused) {
display.updateStatus("PAUSED", true);
} else {
display.updateStatus('<font color="#EE3300">' + "STOPPED" + '</font>', false);
}
display.updatePosition(song.position, true);
}
}
function holdStatus() {
delete this.onEnterFrame;
}
// CONTROLS:
this.onEnterFrame = function() {
slide_volume.setPerc(25);
slide_pan.setPerc(50);
slide_position.setPerc(0);
but_stop.activate();
delete this.onEnterFrame;
}
but_stop.symbol = "stop";
but_stop.cantoggle = false;
but_play.symbol = "play";
but_play.cantoggle = true;
but_back.symbol = "back";
but_back.cantoggle = false;
but_fore.symbol = "fore";
but_fore.cantoggle = false;
function updateButtons() {
if (isplaying && !ispaused) {
but_play.symbol = "pause";
but_stop.deActivate();
} else {
but_play.symbol = "play";
if (!isplaying) {
but_stop.activate();
} else {
but_stop.deActivate();
}
}
}
function pressed(obj) {
switch(obj) {
case but_stop:
stopSong();
updateButtons();
break;
case but_play:
if (!isplaying) {
playSong(true);
} else if (ispaused) {
playSong(false);
} else {
pauseSong();
}
updateButtons();
break;
case but_back: doStep(-1); break;
case but_fore: doStep(1); break;
}
}
slide_volume.onMove = function(p) {
song.setVolume(Math.round(p));
holdStatus();
display.updatePosition(Math.round(p), false);
}
slide_volume.onTouch = function() {
display.updateStatus('<font color="#FFCC00">' + "VOLUME" + '</font>', false);
}
slide_volume.onChange = function() {
updateStatus();
}
slide_pan.onMove = function(p) {
var pan = Math.round(p * 2) - 100;
if (Math.abs(pan) < 2) pan = 0;
song.setPan(pan);
holdStatus();
var dir = (pan < 0)? "L" : "R";
if (pan == 0) dir = " ";
display.updatePosition(Math.abs(pan) + dir, false);
}
slide_pan.onTouch = function() {
display.updateStatus('<font color="#FFCC00">' + "PANORAMA" + '</font>', false);
}
slide_pan.onChange = function() {
updateStatus();
}
slide_position.onMove = function(p) {
holdStatus();
var pos = p * song.duration / 100;
display.updatePosition(pos, true);
}
slide_position.onTouch = function() {
if (isplaying) display.updateStatus('<font color="#FFCC00">' + "POSITION" + '</font>', false);
}
slide_position.onChange = function(p) {
var pos = p * song.duration / 100;
if (isplaying && !ispaused) {
song.start(pos / 1000, 0);
} else if (isplaying) {
last_position = pos / 1000;
}
updateStatus();
}
// SONG CONREOL:
function setSong(n, willplay) {
stopSong();
current_song = n;
initSound();
if (willplay) {
playSong(true);
}
}
function playSong(newsong) {
if (current_song > -1) {
isplaying = true;
ispaused = false;
if (!newsong) {
song.start(last_position, 0);
} else {
song.loadSound(list[current_song], true);
song.setVolume(slide_volume._value);
song.setPan(Math.round(slide_pan._value * 2) - 100);
}
updateStatus();
}
}
function stopSong() {
isplaying = false;
ispaused = false;
last_position = 0;
song.stop();
updateStatus();
}
function pauseSong() {
if (!ispaused && isplaying) {
ispaused = true;
last_position = song.position / 1000;
song.stop();
updateStatus();
} else if (isplaying) {
playSong();
}
}
function doStep(offset) {
current_song += offset;
if (current_song < 0) current_song = list.length - 1;
if (current_song > list.length - 1) current_song = 0;
playlist.select(current_song);
setSong(current_song, isplaying);
}
// LOADING PLAYLIST:
var xm = new XML();
xm.ignoreWhite = true;
xm.onLoad = function() {
parse(this);
}
xm.load("playlist.xml");
function parse(obj) {
for (var i=0; i<obj.childNodes.length; i++) {
list[i] = obj.childNodes[i].firstChild.toString();
}
playlist.initList(list);
}
mfg buschmannd
//EDIT
ich habe das mit dem Tuturial hier ausm Forum gemacht ...sieht nur ganz naders aus
http://www.tutorials.de/forum/flash...-ein-audioplayer-mx2004-fortgeschrittene.html
Zuletzt bearbeitet: