[F8] Problem With Sound.duration
I am working on a music player where the music list is loaded using xml. I am using sound object and the streaming property is set to 'true'. Now I want to calculate sound.duration, but I don't get the actual value when it is streaming, probably because the entire file is not downloaded at once because of streaming, and it is returning the duration of the portion of the file downloaded. So I am unable to develop a progress bar which shows the current position of the music.
I even tried to get the file duration using ID3 tag but the TIME property does not seem to work either.
Another options could be using php to get the duration of the mp3 file and generate an xml file which specifies the duration of the file.
But I have a little idea about php.
Can anyone help me
FlashKit > Flash Help > Flash ActionScript
Posted on: 08-04-2008, 06:31 AM
View Complete Forum Thread with Replies
Sponsored Links:
Sound.position And Sound.duration On Flash Lite 2.1
I'm using the code below to trace the position and duration of a loaded mp3 file. This works fine when I export as normal flash 9 version swf, though when I export as flash lite 2.0 or 2.1, the trace returns 0 for both position as well as duration. Here is suggested that the two members should be available for all flash lite 2.x versions. Is there a way to find the duration and position of an mp3 file in flash lite 2.x? Am I doing something wrong?
Thank you in advance,
Harry
Attach Code
var mySound:Sound = new Sound();
mySound.onLoad = function(success){
if(success == true) {
mySound.start(0, 0);
}
}
mySound.loadSound("sound.mp3");
function onEnterFrame() {
trace(mySound.duration + " " + mySound.position);
}
Edited: 02/05/2008 at 08:42:28 PM by Harry Vermeulen
View Replies !
View Related
Sound.duration Lags Behind Sound.getBytesLoaded()
This is crazy:
Code:
l = 1779801 t = 1782285 p = 99.8606283506846 dur = 210
l = 1782285 t = 1782285 p = 100 dur = 211
l = 1782285 t = 1782285 p = 100 dur = 212
l = 1782285 t = 1782285 p = 100 dur = 213
l = 1782285 t = 1782285 p = 100 dur = 213
l = 1782285 t = 1782285 p = 100 dur = 214
l = 1782285 t = 1782285 p = 100 dur = 215
l = 1782285 t = 1782285 p = 100 dur = 215
l = 1782285 t = 1782285 p = 100 dur = 216
ActionScript Code:
var l:Number = my_sound.getBytesLoaded();
var t:Number = my_sound.getBytesTotal();
var per:Number = (l/t)*100;
//
trace("l = " + l +" t = " + t +" p = "+per+" dur = "+Math.round((my_sound.duration/1000)));
Has anyone ever experienced this problem of the Sound.duration property lagging behind the Sound.getBytesTotal()? This seems rather ridiculuos! And yes, this happen online too, not just locally!
View Replies !
View Related
Sound Duration Bar, PLEASE HELP :)
i have made an mp3 player that loads mp3s from a dir on my server and streams them. i made a duration bar (duration_mc) to show how much of the song has elaped:
duration_mc.onEnterFrame = function(duration){
this._xscale=my_sound.position/my_sound.duration*100;
it works for the first song, but then when you click another track it will continue from where it left off on the previous song.
my question is, how can i make the duration bar reset to the beginning when you click to stream another song?
View Replies !
View Related
Get Sound Duration Without Id3?
Anyone know if it's possible to to acertain the duration of an externally-loaded mp3, either by time or frames? I'm working on a project where the user records a voice message as an mp3, which is then loaded into a .swf. The .swf contains a movie clip which is supposed to play while the Sound's playing, and stop when the Sound's finished. HOWEVER, the mp3s don't have an .id3.TIME property attached so that property can't be accessed . Many thanks.
View Replies !
View Related
About Sound Duration
Hi I'm newby here and I want some help.
I just building a MP3 Player and load the external MP3 file into flash and I load it as a stream. I want to get the duration of the song for update my progress bar and now I using "sound.duration" to get that but this value will change when the whole file is not loaded (I mean if it loaded 1 sec. it return 1sec so that is not the actualy song duration)
Is there any method to get the file duration at the begining of sound loaded.
thank you and sorry for my English
View Replies !
View Related
Sound Duration
I'm importing an MP3 on the fly and it's approx 69000ms seconds long.
However, when I trace the sound duration, it comes out 24890ms. It's losing 45 seconds The MP3 itself seems to be fine when I open it in sound forge. Anyone experienced this before?
View Replies !
View Related
Check For Sound Duration
Does anyone knows how to check for sound duration?? I mean using action script to check for it, not manually using stop watch. I have a music attached using scripts, I need to check that when the song ends, everything puts to a stop.
Any idea anyone??
View Replies !
View Related
Sound.duration + Levels
actionscript 1.0/2.0
Hi basically I have a really annoying problem - all I want to do is use sound.position to retrieve the number of milliseconds a particular sound has been playing.
Which I've done in a test harness program which uses the linkage feature to dynamically import sounds from the library and bring in to an empty movie clip and then control it from there.
However this flash swf is part of a bigger flash file (_level0.swf) which loads this test harness into an empty movie clip called 'content'and displays it.
However when played through _level0.swf, which ultimately loads the test harness into the content mc within _level0 - the sound plays - but refuses to divulge the amount of milliseconds the sound has been playing.
I've used all sorts of paths - which all work standalone in test harness - but fail when loaded through other _level0.swf.
It's doing my head in now! - one thing I did notice however when I first tried to do it it wouldn't even play the linked sound before I embedded it in a empty movie clip (even though all the code was correct and it played in test harness).
Any suggestions welcomed
Heres the code I have in test harness
Code:
current_audio = 1;
this.createEmptyMovieClip("sounds", 1);
this.sounds.sound_duration = 0;
function playReply(){
this.sounds["mc_sound_" + current_audio] = new Sound("sounds");
this.sounds["mc_sound_" + current_audio].attachSound("reply_" + current_audio);
this.sounds["mc_sound_" + current_audio].onSoundComplete = function (){
this.sounds.sound_duration = 0;
audio_button.gotoAndStop(1);
};
this.sounds["mc_sound_" + current_audio].start(this.sounds.sound_duration, 1);
audio_button.gotoAndStop(2);
}
function pauseReply(){
this.sounds.sound_duration = ((this.sounds["mc_sound_" + current_audio].position)/1000);
this.sounds["mc_sound_" + current_audio].stop("reply_" + current_audio);
}
where my sound and exported from the library using the identifers reply_1, reply_2 etc.
And on stage is an audio button with two states pause and play and clicking on them calls the appropriate function.
The othe paths I've tried are with no paths included and using _level0.content before it instead of this - which all work in test harness and not when played through the _level0 hierachy.
_level0 uses the following code to load test harness (activity into a manually created empty movie clip called 'content'.
Code:
content.loadMovie("testharness.swf");
View Replies !
View Related
[F8] Question About Sound Duration And XML
Hi!
I am making a sound player that gets the mp3 files from a xml file, plays them one by one and stops when it reaches the last file.
The thing is that I wanted to do a little crossfading thing between the tracks to make it nicer, but as I try to get a simple "showTune.duration" it returns 0 all the time. Is there a way to get the duration of the track without having to insert it manually on the XML?
Thanks for your time.
View Replies !
View Related
Duration Of A Sound Object?
Is there a way to get the full duration of a sound object BEFORE it is compleatly loaded?
I am using
Code:
this.duration/1000;
right now to get the duration of the sound in seconds, but becouse the sound is streaming it seems the duration gets longer as the sound loads more, and more.....
Can anyone please help?
Thanks
~Gabor
View Replies !
View Related
Sound Duration Issue
this code in frame 1:
Code:
s = new Sound();
s.loadSound("ms_basses2.mp3", false);
track_totalTime = s.duration;
returns this in the variable list when debugging:
Code:
duration:[getter/setter] 66194,
Variable _level0.track_totalTime = 0
is it just me or is there conflicting feedback there?
I may just not understand something about debugging this.
View Replies !
View Related
ID3 And Sound Object Duration
Hey all,
I have been building out a simple audio player but seem to be having some difficulty acquiring the total duration of the mp3 file. Intially I tried to get the duration via onID3, this however returns a value slitgly smaller than what it should be. It gives me a time of 1:21, where it should be 1:25.
I eventually solved it by changing the function trigger from on ID3 to onLoad. This fixed the issue and gave me the correct time. However, upon further testing I realized that people using this would have to wait for the entire sound clip to load in order to see the value.
Is there a better way of achieving the .duration, do I have to add some kind of buffer to allow more to load?
View Replies !
View Related
Undefined Sound.duration?
I've got a math lesson that I'm playing some feedback audio (short narration) using mySound.attachSound("linkage") and I want to make the buttons on stage not accessible until after the feedback.
I used delay=mySound.duration to get the duration of the sound and then I use setTimeout(enableButtons,delay);
It works fine in the testing environment or when I play just the published swf. But if I load that swf into an empty movieclip, mySound.duration returns "undefined." The sound does still play and the scoping is correct. Anybody have any ideas?
View Replies !
View Related
Sound Position And Duration
The sounds come from an array, when I click on the sound icon a new mp3 is loaded, that part works. The problem is with the txtPlayTime.text, when I load a new mp3 soundPlayingTime does not initialize from 00:00 but continues counting and the content of the text field txtPlayTime.text bliks from 00:00 / 00:00 to the current value every time the interval refreshes.
I tried all kind of things but I cannot make it work properly. Any help will be appreciated.
Thank you in advanced,
Attach Code
sound_interval = setInterval(updateSoundProgress, 100, s);
function updateSoundProgress(the_sound:Sound):Void
{
//Playing Time
var s_seconds:Number = the_sound.position/1000;
var spminutes:Number = Math.floor(s_seconds/60);
var spseconds = Math.floor(s_seconds%60);
if (spseconds < 10)
{
spseconds = "0" + spseconds;
}
var soundPlayingTime = spminutes + ":" + spseconds;
//Total time
var sTotalSeconds:Number = the_sound.duration/1000;
var stminutes:Number = Math.floor(sTotalSeconds/60);
var stseconds = Math.floor(sTotalSeconds)%60;
if (stseconds < 10)
{
stseconds = "0" + stseconds;
}
var soundTotalTime = stminutes + ":" + stseconds;
txtPlayTime.text = soundPlayingTime + " / " + soundTotalTime;
}
View Replies !
View Related
Pause Sound Duration
Here it is my duration function, play funtion and pause funcion
the problem is i can't find a way to stop the timer of the duration
the text field is called t1.
Thank you
this.onEnterFrame = function() {
t1 = int(sndObject.duration/1000/60);
t1 = t1+" : "+int((sndObject.duration/1000-(t1*60)));
sndObjectf = int((sndObject.duration-sndObject.position)/1000/60);
elapsed_sec = int((((sndObject.duration-sndObject.position)/1000/60)-sndObjectf)*60);
if (elapsed_sec<10) {
elapsed_sec = "0"+elapsed_sec;
}
if (sndObjectf<10) {
sndObjectf = "0"+sndObjectf;
}
if (_root.stpd) {
elapsed = _root.t1;
} else {
elapsed = sndObjectf+" : "+elapsed_sec;}
//mo=sndObject.position/1000
//elapsed =
vol = sndObject.getVolume()+" %";
dur = sndObject.duration;
pos = sndObject.position;
per = (pos/dur)*100;
m = (pos/dur)*100;
bar._width = (m*xx)/100;
drag._x = _root.bar._width+_root.bar._x;
//drag._y = 136;
if (stpd) {
xx = 0;
} else {
xx = orginal_width;
}}
// function keys
function playSong()
{
if (pausePos == 0)
{
sndObject.setVolume(songVolume);
sndObject.loadSound(file, true);
loadProgressInt = setInterval(loadProgress, 50);
} // end if
sndObject.start(pausePos);
playProgressInt = setInterval(playProgress, 50);
pauseBut._visible = true
playBut._visible = false;
gotoAndPlay("play");
dur = sndObject.duration;
} // End of the function
function pauseSong(p)
{
if (!p)
{
pausePos = sndObject.position / 1000;
}
else
{
pausePos = p;
} // end else if
sndObject.stop();
pauseBut._visible = false;
playBut._visible = true;
clearInterval(playProgressInt);
gotoAndPlay("pause");
} // End of the function
View Replies !
View Related
Problem With Sound Duration
Hi,
i have a mp3 player that works perfectly offline but once online the sound.duration seems to be incorrect. The sound.duration = 15' online and 52' offline. And it's the same for each mp3 with an incorrect duration.
You can see what i mean here :
http://adesign.tonsite.biz/v4
Any ideas ?
Thank's.
Chris
View Replies !
View Related
Streaming Sound Duration?
I have currently a music player that uses Sound.position and Sound.duration to use as a playlist. However, the sound is streaming, so then Sound.duration is the number of loaded seconds/miliseconds. Is there a way for me to figure out the duration of a sound without fully loading it? Right now, it really messes up the playhead.
View Replies !
View Related
Sound Duration, Problems
Hello!
I am crating a MP3 Player, and i have one problem to fix. When i use the my_sound.duration (where my_sound is var my_sound:Sound = new Sound(); ), the duration only shows correcty when i use the onLoad method. Exemple:
var my_sound:Sound = new Sound();
my_sound.loadSound ("my file.mp3", true);
my_sound.onLoad = function() {
duration_txt.text = my_sound.duration;
}
But, i dont want wait the music complete loaded to show the duration, but when the music starts show the duration.
I cant use the id3.LEN on my file. The other soluction is put the duration information in a XML file and later show in the Flash, but i want somethig ease, more dinamic.
So, have soluction to my problem or i have to say the duration of the Music.
Thanks
Ps: Sorry for my English
View Replies !
View Related
Sound.duration Problem
I am working on a music player where the music list is loaded using xml. I am using sound object and the streaming property is set to 'true'. Now I want to calculate sound.duration, but I don't get the actual value when it is streaming, probably because the entire file is not downloaded at once because of streaming, and it is returning the duration of the portion of the file downloaded. So I am unable to develop a progress bar which shows the current position of the music.
I even tried to get the file duration using ID3 tag but the TIME property does not seem to work either.
Another options could be using php to get the duration of the mp3 file and generate an xml file which specifies the duration of the file.
But I have a little idea about php.
Can anyone help me
View Replies !
View Related
Problem With Sound Duration
Hi,
i have a mp3 player that works perfectly offline but once online the sound.duration seems to be incorrect. The sound.duration = 15' online and 52' offline. And it's the same for each mp3 with an incorrect duration.
You can see what i mean here :
http://adesign.tonsite.biz/v4
Any ideas ?
Thank's.
Chris
View Replies !
View Related
Sound Duration - Problem
Hello!
I am crating a MP3 Player, and i have one problem to fix. When i use the my_sound.duration (where my_sound is var my_sound:Sound = new Sound(), the duration only shows correcty when i use the onLoad method. Exemple:
var my_sound:Sound = new Sound();
my_sound.loadSound ("my file.mp3", true);
my_sound.onLoad = function() {
duration_txt.text = my_sound.duration;
}
But, i dont want wait the music complete loaded to show the duration, but when the music starts show the duration.
I cant use the id3.LEN on my file. The other soluction is put the duration information in a XML file and later show in the Flash, but i want somethig ease, more dinamic.
So, have soluction to my problem or i have to say the duration of the Music.
Thanks
Ps: Sorry for my English
View Replies !
View Related
Streaming Sound Real Duration...
Everybody knows that .duration property shows the duration of the part loaded when talking about streaming sound. I predefine such a method:
Sound.prototype.realDuration = function() {
return (this.getBytesTotal()/this.getBytesLoaded())*this.duration;
}
But it returns different values while loading too... Why so? Is there any effective solution?
View Replies !
View Related
Sound.duration Problem.. Xml Mp3 Player
Hi guys/gals..ive made an xml driven mp3 player...everything is working fine expect the playback progress head.. its works FINE locally.
The problem is online. For some reason intially the sound duration property keeps changing (instead of being a CONSTANT) until it reaches its final constant value.
You can look at this at http://www.flashmatics.co.uk/blog/sa...mp3player.html
Therefore obvisuoly the playhead is out of sync with the song
Does anyone have an idea why/how this is so?why is the duration property changing when it should be a constant? Thanks..ive made players before but never experienced this problem..
Any help appreciated..cheers
View Replies !
View Related
How Do I Display The Sound Duration Property?
Hi.
I have the code below for my mp3 player. It works fine. I found the code on 'sound duration' in the Flash help section on how to get the duration of a song. But how do I actually display the info in a dynamic text box?
function playMusic() {
myMusic = new Sound();
// get Duration Property onLoad
myMusic.onLoad = function(success:Boolean) {
var totalSeconds:Number = this.duration/1000;
trace(this.duration+" ms ("+Math.round(totalSeconds)+" seconds)");
var minutes:Number = Math.floor(totalSeconds/60);
var seconds = Math.floor(totalSeconds)%60;
if (seconds<10) {
seconds = "0"+seconds;
}
trace(minutes+":"+seconds);
};
myMusic.onSoundComplete = function() {
if (curTrackNum == (myMusicLv.totalTracks) -1) {
curTrackNum = 0;
} else {
curTrackNum++;
}
playMusic();
};
myMusic.onID3 = function() {
trackInfo.text = myMusic.id3.TIT2;
trackCount.text = myMusic.id3.TRCK;
};
myMusic.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
}
myMusic.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
View Replies !
View Related
How Do I Display The Sound Duration Property?
Hi.
I have the code below for my mp3 player. It works fine. I found the code on 'sound duration' in the Flash help section on how to get the duration of a song. But how do I actually display the info in a dynamic text box?
function playMusic() {
myMusic = new Sound();
// get Duration Property onLoad
myMusic.onLoad = function(success:Boolean) {
var totalSeconds:Number = this.duration/1000;
trace(this.duration+" ms ("+Math.round(totalSeconds)+" seconds)");
var minutes:Number = Math.floor(totalSeconds/60);
var seconds = Math.floor(totalSeconds)%60;
if (seconds<10) {
seconds = "0"+seconds;
}
trace(minutes+":"+seconds);
};
myMusic.onSoundComplete = function() {
if (curTrackNum == (myMusicLv.totalTracks) -1) {
curTrackNum = 0;
} else {
curTrackNum++;
}
playMusic();
};
myMusic.onID3 = function() {
trackInfo.text = myMusic.id3.TIT2;
trackCount.text = myMusic.id3.TRCK;
};
myMusic.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
}
myMusic.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
View Replies !
View Related
Reset Sound Positon/duration
Im trying to make a flash mp3 player using the loadSound command and I cant figure out how to make the mysound.position/duration property reset when I change the song thats playing. Also when I go to the next song and then return to the previous song flash has memorised the old position?? How do I stop this?
View Replies !
View Related
Sound Duration = MyBar Width
Hi to all!:
Hope u can help me out. I´ve built a bar that grows as the sound is played. In the code I'm using, the position of the sound is expressed in milliseconds.
Code:
position = _root.track1.position/1000;
_root.myBar._xscale = position;
The thing is that i'd like to equal the bar width (250 pixels) with the total sound duration. So when the sound has got to the end, the bar has fully grown to 205 pixels.
I´ve already checked the Kenny Bellew tutorial, but still can't figure out how this precise issue is solved.
Thanks in advance!!!...
View Replies !
View Related
Trouble Accessing Sound Duration - Help
I can't seem to access the sound duration value in my code, I am not sure what I am doing wrong.
ActionScript Code:
var directory:String = "Voices/";var noOfSongs:Number = 100;var aSongs:Array = [];var currIndex:Number = 0;for (var i = 1; i<=noOfSongs; i++) {aSongs.push("v"+i+".mp3");}VSound = new Sound(Voice1_mc);function playSound(songIndex:Number):Void {VSound.loadSound(directory+aSongs[songIndex], true);VSound.setVolume(VSound.getVolume()+50);trace(VSound.duration);VSound.start(0, 0);}VSound.onSoundComplete = function() {currIndex++;if (currIndex == aSongs.length) {currIndex = 0;}playSound(currIndex);};playSound(currIndex);
View Replies !
View Related
Sound Duration = MyBar Width
Hi to all!:
Hope u can help me out. I´ve built a bar that grows as the sound is played. In the code I'm using, the position of the sound is expressed in milliseconds.
Code:
position = _root.track1.position/1000;
_root.myBar._xscale = position;
The thing is that i'd like to equal the bar width (250 pixels) with the total sound duration. So when the sound has got to the end, the bar has fully grown to 205 pixels.
I´ve already checked the Kenny Bellew tutorial, but still can't figure out how this precise issue is solved.
Thanks in advance!!!...
View Replies !
View Related
Duration And Position Of Sound Object
Hi, I have a MP3 player which progressively downloads MP3s from my server. I can display the IDtags for song name and track info just fine. But I am having trouble displaying the current time and total time of the current mp3 in my dynamic text fields: 'posTime' and 'songInfo'.
Can anybody help? Thanks, Henrik
ActionScript Code:
function playMusic() {
myMusic = new Sound();
//MP3 Timecode Code:
posMins = Math.floor(myMusic.position/1000/60);
posSecs = Math.round(myMusic.position/1000%60);
//Single Digit Check Code:
if(posSecs<10){
posSecs = "0"+Math.round(myMusic.position/1000%60);
}
//Display MP3 Time to user:
posTime.text = " "+posMins+":"+posSecs+" ";
songInfo.text = ""+posTime+""
myMusic.onSoundComplete = function() {
if (curTrackNum == (myMusicLv.totalTracks) -1) {
curTrackNum = 0;
} else {
curTrackNum++;
}
playMusic();
};
myMusic.onID3 = function() {
trackInfo.text = myMusic.id3.TIT2;
trackCount.text = myMusic.id3.TRCK;
};
myMusic.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
}
myMusic.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
View Replies !
View Related
[streaming Sound] GetBytesLoaded And Duration
Does anyone know a solution to this problem? Please
Intro:
When you trace mySound.duration while you are streaming an mp3, you won't get the correct length but approximately the length of the part of the mp3 file which already has been loaded.
Now it should be possible to calculate the total length with the loaded Bytes:
ActionScript Code:
var p= mySound.getBytesLoaded()/ mySound.getBytesTotal()
var correctLength = p* mySound.duration
But the loaded Bytes are tricky !
Question:
Why does the Bandwidth Profiler in the testing mode of Flash show a lower value of loaded Bytes than when i use trace (mySound.getBytesLoaded()) ?
Remark:
mySound.duration stops increasing at the same time as when the Bandwidth profiler says that loading has finished.
View Replies !
View Related
Increment Of Time On Sound Duration
Hi, i have a textfield which is called "postionTime" which gives…well the position of the time of a song, i have a function which launch my song, and I have a button who stop my song.
here is the function which launch the song
ActionScript Code:
Zic=new Sound();
function music(indiceSon) {
Zic.loadSound(indiceSon, true);
this.onEnterFrame = function() {
//loading the song
}
here is the function which calculate the position of the time in my song
ActionScript Code:
function soundTime() {
onEnterFrame = function () {
//calcul du temps écoulé de ZIC
}
the action on my stop button
ActionScript Code:
on (press) {
music (“”,false);
}
it works perfectly until i want to launch an another song. When I press the stop button the textfield positionTime is not reinitialized to 0, even I put positionTime= 0; it won’t do it.
The problem is that when I launch an another song which of course use the same sound object Zic, well my textfield starts the time from the time I stoped the song before with. I hop you understand.
ej:
1st: I launch a song-> it loads -> i let it play for 5 seconds-> I stop it.
Second: I launch again a song (the same one or an another one) -> it loads also-> the time starts from 5. so in my textfield “positionTime” the first second of the second I choose to play will be 6, the second second will be 7, the third will be 8 etc.. so it’s like my textfield is recording the all the time that went thought it….got it?
Thank you for the help
View Replies !
View Related
How To Display Duration And Position Of Sound Object
Hi, I have a MP3 player which progressively downloads MP3s from my server. I can display the IDtags for song name and track info just fine. But I am having trouble displaying the current time and total time of the current mp3 in my dynamic text fields: 'posTime' and 'songInfo'.
Can anybody help? Thanks, Henrik
function playMusic() {
myMusic = new Sound();
//MP3 Timecode Code:
posMins = Math.floor(myMusic.position/1000/60);
posSecs = Math.round(myMusic.position/1000%60);
//Single Digit Check Code:
if(posSecs<10){
posSecs = "0"+Math.round(myMusic.position/1000%60);
}
//Display MP3 Time to user:
posTime.text = " "+posMins+":"+posSecs+" ";
songInfo.text = ""+posTime+""
myMusic.onSoundComplete = function() {
if (curTrackNum == (myMusicLv.totalTracks) -1) {
curTrackNum = 0;
} else {
curTrackNum++;
}
playMusic();
};
myMusic.onID3 = function() {
trackInfo.text = myMusic.id3.TIT2;
trackCount.text = myMusic.id3.TRCK;
};
myMusic.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
}
myMusic.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
View Replies !
View Related
How To Find Total Duration Time Of Sound?
Hi all,
my first post here...
I was trying to find total time duration of a sound... but it seems that it works only when the complete sound is loaded..
I want to find to total time of a streaming sound??
well.. i used..
var mySound:Sound = new Sound();
var sc:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("track1.mp3"));
sc = mySound.play();
trace(mySound.length); // This doesn't work.. returns 0
View Replies !
View Related
Sound.duration Continues To Increase After GetBytesLoaded()==getBytesTotal()?
Try this:
ActionScript Code:
var s = new Sound();
s.loadSound('sound.mp3',true);
onEnterFrame = function(){
var a = s.duration+" : "+s.getBytesLoaded()+" / "+s.getBytesTotal();
}
Have sound.mp3 or whatever in the same dir as the fla. Test movie, and simulate download. Notice that the Sound.duration continues to steadily increase even after getBytesLoaded()==getBytesTotal()! Example:
45166 : 201558 / 201584
45322 : 201584 / 201584 // done loading bytes
45558 : 201584 / 201584 // duration increasing??
45793 : 201584 / 201584 // still increasing?! and continues for a long time
I was trying to extrapolate the duration of the mp3, since Sound.duration only returns milliseconds of audio downloaded when loadSound stream is set to true(like above). I got so close, but fear I'm stuck. The discrepancy created by this is as long as 10 seconds, which is not acceptable. I am probably going to have to settle for a nasty alternative, like creating id3 tags(ug) or manually enter all the timestamps into XML. If any gurus have any last ideas, I'm all ears.
View Replies !
View Related
Reset Dynamic Text Box For Sound Duration On Stop
Hi there.
I have a function playMusic which has an onEnter frame function for the duration property called "textfields". Works fine, for accept the fact , that the dynamic text boxes are not being reset to "0" after the stop btn has been activated.
ActionScript Code:
textfields.onEnterFrame = function() {
musicDuration = myMusic.duration/1000;
//
minutesTotal = Math.floor(musicDuration / 60);
secondsTotal = Math.floor(musicDuration-minutesTotal*60);
seconds = Math.floor((myMusic.position/1000)%60);
minutes = Math.floor((myMusic.position/1000)/60);
hours = Math.floor((myMusic.position/1000)/120);
textfields.timeText01.text = minutes + " : " + seconds;
textfields.timeText02.text = + minutesTotal + " : " + secondsTotal;
}
The stop/play toggle button calls the play Music or stop Music function. The problem is, that the textfields for duration are not being reset to "0" after the sound has stopped. I set the textfileds.timeText1 and 2 to "", but it did not do the trick. I guess the onEnter Frame function is still being called?
Can anyone help?
ActionScript Code:
function stopMusic() {
delete myMusic;
_root.textfields.timeText01.text = "";
_root.textfields.timeText02.text = "";
}
View Replies !
View Related
Voice Synthesizer: Set Playing Sound's Start Point And Duration To Its Length
How do I set playing sound's start point using an interval and also set the duration of play time to the sounds length? Then keep this happening for multiple sound that play one after the other?
I want to make a voice synthesizer and reduce the distance of gaps between sounds. "G"+"l"+"e"+"n" to "Glen" ect.
By the way, I'm making this from scratch and just want to understand how to do it. I don't actually need a working piece of software. I might make a mixing program later but wanna learn how to do all this stuff first.
Glen Charles Rowell
View Replies !
View Related
How To "refresh" Variable's Sound Duration Property?
I haven't been able to figure out how to make the PositionPercent variable reset after every onRelease. Any ideas, suggestions? It's probobly something super easy I've overlooked...THX in advance!
mcButtonOne.onRelease = function():Void {
sAudio.loadSound(this.data.href, true);
}
sAudio.onLoad = function() {var totalSeconds:Number = Math.round(this.duration/1000);
var minutes:Number = Math.floor(totalSeconds/60);
var seconds = Math.floor(totalSeconds)%60;
var nInterval:Number = setInterval(checkProgress, 500);
function checkProgress():Void {
var PositionPercent:Number = Math.round(((sAudio.position/1000)/totalSeconds)*100);
trace(PositionPercent);
View Replies !
View Related
Getting The Duration Of An FLV
I currently already have an flvplayback imported onto the stage with name of flvPlayback. This flvplayback detects events such as VideoEvent.playheadTime,VideoEvent.complete etc. I realise that in the API flvPlayback has a totalTime property (total playing time for the video in seconds- which seems to do nothing ) and metadataReceived event. So now i need an alternative of the netstream code i have below but for FLVplayback. The net stream is:
Code:
stream_ns.onMetaData = function(infoObject:Object) {
/*for (var propName in infoObject) {
trace(propName+" = "+infoObject[propName]);
}*/
var FLVduration = infoObject["duration"];
var minutes2:Number = Math.floor(FLVduration/60);
var seconds2 = Math.floor(FLVduration%60);
if (seconds2<10) {
seconds2 = "0"+seconds2;
}
totalTimeText = " Total time:"+minutes2+":"+seconds2;
};
So in theory i should be able to use something like flvPlayback.metadataReceived = function(bla bla) {bla bla} but i can't seem to do that. Any ideas?
View Replies !
View Related
Mp3 Duration
hello:
i'm trying to create an mp3 player...
buttons are created dynamically by loading xml file.
i can only get the duration of the mp3 after i "loaded" it.
how can i display the duration of each song without
loading it? i want it to display like (pls see below), after xml file is loaded:
song_1 - 03:51
song_2 - 02:53
song_3 - 04:25
etc ...
etc ...
*i already have the timeformat to display "00:00"
any input is very much appreciated.
thanks in advance.
View Replies !
View Related
Flv Duration
Hia, I'm trying to make a progress/duration bar for an flv player.
The flvs are loaded from an xml file into a playlist with an instance name of "list", when an item in the list is selected the ns is attached to a video holder with an instance name of "video".
The handle to show the progress is called "knob" and the progress bar is called "track".
All I need it to do is show the ratio of total time / current time.
So far I have this but I cant seem to make it work.
Actionscript Code:
listListener.change = function(evtobj) {
var nav = list.dataProvider[list.selectedIndex];
nc = new NetConnection();
//create a connection
nc.connect(null);
//null connection for progressive download
ns = new NetStream(nc);
//create a stream
video.attachVideo(ns);
//pipe stream to this video object
//get duration
ns.onMetaData=function(obj) {
var TotalDuration:Number=obj.duration
trace(Math.round(TotalDuration));
ratio = track._width / TotalDuration;
id = setInterval(function ():Void {
knob._x = track._x + ns.time * ratio;
}, 50
);
};
ns.onStatus = function(evt:Object):Void {
if (this.time > 0 && this.time >= (TotalDuration - 0.5)) {
trace("Video complete");
clearInterval(id);
delete this.onStatus;
}
};
// walk through the chosen item, build and play it
var reset = true;
for (var i = 0; i < nav.childNodes.length; i++) {
var stream = nav.childNodes[i];
if (stream.nodeName == "stream") {
// build path to flv, and play it
myStreamPath = nav.attributes.url + "/" + stream.attributes.name;
ns.setBufferTime(10);
ns.play(myStreamPath);
title_txt = nav.attributes.name;
trace(title_txt);
reset = false;
}
}
};
Is there anything glaringly obvious that I've done wrong in there?
Thanks
James
View Replies !
View Related
HELP Duration Bar?
Hello all, once again after making progress I am stuck yet again.
I have a flv on my stage, with all the components I need, play/pause, etc and the seek bar/progress bar.
What I need is a way that a new color would appear over the seek bar and scale accourding to the location of the seek bar handle. basically giving a difference of what has been played and what remains as seen on this example
http://www.any-flv-player.com/flv_playe ... shot-1.jpg
as you can see the progress bar is black, and the handle bar is leading a white strip to show how much has played. I don't even know what to call this to even search the internet right. Can anyone point me in the right direction.
of course i need this to work in AS3
Thanks in Advance
Fluid5Design
View Replies !
View Related
|