-
Requesting help tkx?!
hey guys,
im not a flash coder/designer and i already asked for help on this question but i only used the code once in my life-time, and, ive took some tutorials from internet that strangly i cannot find anymore..so basicaly i lost my knowlege about this in the past 1 or 2 years and i need some help on this again:
The thing is im building a small mp3 player to my webpage and i need some help on 2 things:
1 - my playbar extends very long: i have a 200 width graphic converted to movie clip but i cannot get the code to make it width along...this is the code im using but for sure misses someting:
Code:
var position = Math.floor(sound.position/1000)
_root.AreaS.playbar._width = position
2 - this one is realy realy realy amateur that i do not know how i forgot...how the hell do we put the mp3 time on a dynamic text????
well i know is some basic formula considering "getBytesLoaded" and "getBytesTotal" but ive tried to / it and *60 etc and i cannot set the time for the dynamic text..it always get "0" has number???!!!!
Thanks guys and sorry to be such a dumb sometimes, all the time, NEVER ...
Duarte V.
-
Senior Member
1 well obviously you need to know exact maximum of position. then your _width could be 200 * position / max_position.
2 getBytesLoaded is bytes loaded not time. you could be downloading bytes faster than sound plays.
-
Originally Posted by realMakc
1 well obviously you need to know exact maximum of position. then your _width could be 200 * position / max_position.
2 getBytesLoaded is bytes loaded not time. you could be downloading bytes faster than sound plays.
1-> Beatuy hint man... i tried out and remebered...200*position/duration...yeah! Thanks...
2-> im gonna try to figure this out cause i really would like that my player had the time on it...cause it also gonna plays mixsets despite of my original tracks and is always good to have the time for those cause they are always + than 40 minutes....i would like help on this ....if i find out i will warn you.....
Thanks again for the tip and for the quick answer...
Duarte V.
-
ok..i made it...i could get the time for my mp3s....since im not run the time and its there just to tell how much time the mp3 has im ok on this one... now i have a small problem with another thing..well...it can be bypassed if there is no reply to this but i will try to have one anyway...
i have a scroller on my player, but is now fixed and it only moves when i try to find a part of the mp3 ...i tried to put in on move with the playbar and it worked but when i try to scrub it it works ..lets say 1/2 of it.... what i mean is i can scrub but not perfectly as when its quiet waiting for a drag... when i put it on moving along with the playbar and try to drag it it just goes back and foward from the position of the playbar to where i have the mouse, and its not precise, although i can drag it foward but with no precision......this is the code im using:
Code:
onClipEvent (enterFrame) {
loadbar = Math.floor(_root.mysound.getBytesLoaded/200);
var position = Math.floor(_root.mysound.position/1000);
var duration = Math.floor(_root.mysound.duration/1000);
var pos = Math.floor((200*_root.mysound.position)/_root.mysound.duration);
scroller._x = pos;
scroller.onPress = function (){
_root.mysound.stop();
startDrag("scroller", true, 0, 0, 200, 0);
scroller.onRelease = function (){
stopDrag();
var cue = Math.floor((scroller._x*duration)/200);
_root.mysound.start(cue, true);
scroller.onReleaseOutside = function (){
stopDrag();
var cue = Math.floor((scroller._x*duration)/200);
_root.mysound.start(cue, true);
};
};
};
}
Well this is just to try to mmake it better but its not properly very needed...despite of im a complete amateur i dont expect many visitors in my webpage :s
Thanks:
Duarte V.
Last edited by Alienoiz; 02-28-2013 at 12:46 AM.
-
.
Hi,
Without seeing your set up and stuff is this any help to you
PHP Code:
onClipEvent (load) { BarWidth = 200; //BarWidth = MyBar._width;// sets it to whatever width the bar is }
onClipEvent (enterFrame) { loadbar = Math.floor(_root.mysound.getBytesLoaded / BarWidth); var position = Math.floor(_root.mysound.position / 1000); var duration = Math.floor(_root.mysound.duration / 1000); var pos = Math.floor((BarWidth * _root.mysound.position) / _root.mysound.duration); scroller._x = pos; cue = Math.floor((scroller._x * duration) / BarWidth); //cue = Math.floor(((scroller._x * duration) / BarWidth) / 1000);// probably better !! scroller.onPress = function() { startDrag(scroller, true, 0, 0, BarWidth, 0); _root.mysound.stop(); }; scroller.onRelease = scroller.onReleaseOutside = function () { stopDrag(); _root.mysound.start(cue,true); }; }
Last edited by fruitbeard; 02-28-2013 at 03:04 AM.
-
Originally Posted by fruitbeard
Hi,
Without seeing your set up and stuff is this any help to you
PHP Code:
onClipEvent (load) { BarWidth = 200; //BarWidth = MyBar._width;// sets it to whatever width the bar is }
onClipEvent (enterFrame) { loadbar = Math.floor(_root.mysound.getBytesLoaded / BarWidth); var position = Math.floor(_root.mysound.position / 1000); var duration = Math.floor(_root.mysound.duration / 1000); var pos = Math.floor((BarWidth * _root.mysound.position) / _root.mysound.duration); scroller._x = pos; cue = Math.floor((scroller._x * duration) / BarWidth); //cue = Math.floor(((scroller._x * duration) / BarWidth) / 1000);// probably better !! scroller.onPress = function() { startDrag(scroller, true, 0, 0, BarWidth, 0); _root.mysound.stop(); }; scroller.onRelease = scroller.onReleaseOutside = function () { stopDrag(); _root.mysound.start(cue,true); }; }
hi.. thanks for the attention...i believe it does not works...ive tried the code and i cannot drag the scroller...the code i gave seems to work but i cannot drag the scroller smoothly... it kinda drags in "long blocks" through the loadbar.. Thanks again:
Duarte V.
-
.
Hi,
Perhaps if you can attach your fla here then we can help you further, its hard to try and imitate how things are set up and draw everything.
I have a player you can try to de-compile here
or this one, under music here
-
Originally Posted by fruitbeard
Hi,
Perhaps if you can attach your fla here then we can help you further, its hard to try and imitate how things are set up and draw everything.
I have a player you can try to de-compile here
or this one, under music here
hey bro...here it is my small fla code...i will not try to decompile your stuff..i dont know if this looks good to you or not ..anyway when things are tutorials i try to understand and copy some parts of the code but normaly tutorials are very basic for this, i dont saw your code but im sure its has more than 100 thisng i will not understand and will confuse my code and my head if i try to understand it.... anyway... you can easly inspect this and gimme some hints : http://dl.dropbox.com/u/37638606/Untitled.zip
Thanks
Duarte V.
-
.
Hi,
Here you go, you will notice a few changes to the code, its CS5, that is the lowest I can save it to.
-
Originally Posted by fruitbeard
Hi,
Here you go, you will notice a few changes to the code, its CS5, that is the lowest I can save it to.
Tkx but this does not open in Flash 8..and i do not have CS5.....
-
.
Hi,
Ok then, I will guide you through it.
On the main timeline place this code
PHP Code:
var TheWidth = 200;
PlayTime.text = "00:00";
FullTime.text = "00:00";
on your play button remove the code and put this code
PHP Code:
on (release) {
trilha = new Sound();
som = "Test.mp3";
trilha.loadSound(som,true);
Played = true;
}
on AreaS movieclip, remove all code and replace with this code
PHP Code:
onClipEvent (load) {
scroller._x = 0;
playbar._width = 0;
loadbar._width = 0;
}
onClipEvent (enterFrame) {
if (_parent.Played == true)
{
// *** Total Time
var TotalTime = Math.floor(_parent.trilha.duration / 1000);
var TotalMin = Math.floor(TotalTime / 60);
var TotalSec = Math.floor(TotalTime) % 60;
if (TotalMin < 10)
{
TotalMin = "0" + TotalMin;
}
if (TotalSec < 10)
{
TotalSec = "0" + TotalSec;
}
_parent.FullTime.text = TotalMin + ":" + TotalSec;
// *** Playing Time
var PlayingTime = _parent.trilha.position / 1000;
var PlayMin = Math.floor(PlayingTime / 60);
var PlaySec = Math.floor(PlayingTime) % 60;
if (PlayMin < 10)
{
PlayMin = "0" + PlayMin;
}
if (PlaySec < 10)
{
PlaySec = "0" + PlaySec;
}
_parent.PlayTime.text = PlayMin + ":" + PlaySec;
// *** Loadbar fill
var NowLoading = _parent.trilha.getBytesLoaded() / 1000;
var NowComplete = _parent.trilha.getBytesTotal() / 1000;
var NowLoaded = Math.round((NowLoading / NowComplete) * _parent.TheWidth);
loadbar._width = NowLoaded;
// *** Playbar movement
var playpos = Math.floor((_parent.TheWidth * _parent.trilha.position) / _parent.trilha.duration);
playbar._width = playpos;
// *** Scrollbar
scroller._x = playbar._x + playbar._width;
scroller.onPress = function()
{
scroller.onEnterFrame = function()
{
startDrag(this, true, 0, 0, _parent.TheWidth, 0);
_parent.trilha.stop();
};
};
scroller.onRelease = scroller.onReleaseOutside = function ()
{
stopDrag();
delete scroller.onEnterFrame;
var duration = Math.floor(_parent.trilha.duration / 1000);
var cue = Math.floor((scroller._x * duration) / _parent.TheWidth);
_parent.trilha.start(cue);
};
// *** Song finishes
_parent.trilha.onSoundComplete = function()
{
scroller._x = 0;
playbar._width = 0;
loadbar._width = 0;
_parent.Played = false;
_parent.trilha.stop();
_parent.PlayTime.text = "00:00";
_parent.FullTime.text = "00:00";
};
}
}
place on the stage two textfields
one named FullTime
the other named PlayTime
you can delete the empty movieclip from the stage
or perhaps somebody would be kind enough to make it flash 8 compatible for you
good luck
-
Originally Posted by fruitbeard
Hi,
Ok then, I will guide you through it.
On the main timeline place this code
PHP Code:
var TheWidth = 200;
PlayTime.text = "00:00"; FullTime.text = "00:00";
on your play button remove the code and put this code
PHP Code:
on (release) { trilha = new Sound(); som = "Test.mp3"; trilha.loadSound(som,true); Played = true; }
on AreaS movieclip, remove all code and replace with this code
PHP Code:
onClipEvent (load) { scroller._x = 0; playbar._width = 0; loadbar._width = 0; }
onClipEvent (enterFrame) { if (_parent.Played == true) { // *** Total Time var TotalTime = Math.floor(_parent.trilha.duration / 1000); var TotalMin = Math.floor(TotalTime / 60); var TotalSec = Math.floor(TotalTime) % 60; if (TotalMin < 10) { TotalMin = "0" + TotalMin; } if (TotalSec < 10) { TotalSec = "0" + TotalSec; } _parent.FullTime.text = TotalMin + ":" + TotalSec; // *** Playing Time var PlayingTime = _parent.trilha.position / 1000; var PlayMin = Math.floor(PlayingTime / 60); var PlaySec = Math.floor(PlayingTime) % 60; if (PlayMin < 10) { PlayMin = "0" + PlayMin; } if (PlaySec < 10) { PlaySec = "0" + PlaySec; } _parent.PlayTime.text = PlayMin + ":" + PlaySec; // *** Loadbar fill var NowLoading = _parent.trilha.getBytesLoaded() / 1000; var NowComplete = _parent.trilha.getBytesTotal() / 1000; var NowLoaded = Math.round((NowLoading / NowComplete) * _parent.TheWidth); loadbar._width = NowLoaded; // *** Playbar movement var playpos = Math.floor((_parent.TheWidth * _parent.trilha.position) / _parent.trilha.duration); playbar._width = playpos; // *** Scrollbar scroller._x = playbar._x + playbar._width; scroller.onPress = function() { scroller.onEnterFrame = function() { startDrag(this, true, 0, 0, _parent.TheWidth, 0); _parent.trilha.stop(); }; }; scroller.onRelease = scroller.onReleaseOutside = function () { stopDrag(); delete scroller.onEnterFrame; var duration = Math.floor(_parent.trilha.duration / 1000); var cue = Math.floor((scroller._x * duration) / _parent.TheWidth); _parent.trilha.start(cue); }; // *** Song finishes _parent.trilha.onSoundComplete = function() { scroller._x = 0; playbar._width = 0; loadbar._width = 0; _parent.Played = false; _parent.trilha.stop(); _parent.PlayTime.text = "00:00"; _parent.FullTime.text = "00:00"; }; } }
place on the stage two textfields
one named FullTime
the other named PlayTime
you can delete the empty movieclip from the stage
or perhaps somebody would be kind enough to make it flash 8 compatible for you
good luck
OK bro..this seems very simple..well...at least i can understand it without any problems....please do not delete it...i will try it in the morning, i believe is very compatible with Flash 8 ... i do not see any kind of code that is not used in Flash 8, contrary to the new tutorials in internet that only speak in CS5 and i find very hard to understand....im sure i can do something with this.....
Thanks:
Duarte V.
-
Tkx fruitbeard it works very fine..i do not know is why double click over the scroller makes the track open for download..anyway i have all for download at my web page... visit if you like at www.beatassist.eu ..... Thanks Again and Regards: Duarte Vinagre
-
Originally Posted by fruitbeard
Hi,
Here you go, you will notice a few changes to the code, its CS5, that is the lowest I can save it to.
fruitbeard you still there man? i still need some help, im confuse!!!! i have several tracks and i would like to add a button to strem all through a .xml playlist but i cannot combine your code with this one that was given to me earlier here in FlashKit by poltuda...here it is the code already altered by me....
Code:
on (release) {
i = 0;
listaMP3 = new XML();
listaMP3.ignoreWhite = true;
listaMP3.load("House.xml");
listaMP3.onLoad = function() {
_global.songfile = [];
_global.songfile[i] = listaMP3.firstChild.childNodes[i].attributes.url;
trilha = new Sound();
list = listaMP3.firstChild.childNodes;
som = list[i].attributes.url;
trilha.loadSound(som,true);
SongText.text = "House Tracks";
trilha.onSoundComplete = playLoop;
};
function playLoop() {
_root.AreaS.scroller._x = 0;
_root.AreaS.playbar._width = 0;
_root.AreaS.loadbar._width = 0;
if (i<list.length-1) {
i++;
_global.songfile[i] = listaMP3.firstChild.childNodes[i].attributes.url;
som = list[i].attributes.url;
trilha.loadSound(som,true);
SongText.text = "House Tracks";
} else {
_root.AreaS.scroller._x = 0;
_root.AreaS.playbar._width = 0;
_root.AreaS.loadbar._width = 0;
i = 0;
_global.songfile[i] = listaMP3.firstChild.childNodes[i].attributes.url;
som = list[i].attributes.url;
trilha.loadSound(som,true);
SongText.text = "House Tracks";
}
}
}
well... i can do the loop thing but i cannot set the controls to get back into 0...it just plays the first track and then all bars and scroll stay in the end when the track changes..I hope you help me... i just do not understand well even if i put the Played = true given by you in this code....
Thanks:
Duarte V.
-
.
Hi,
Sorry , xml is not my thing, I use php to generate all of my play lists and birts and bobs.
-
birts and bobs??!!! ok..i just dont know how to integrate the code..but tkx anyway!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|