AS3 how to check if sound object is buffering http sound stream - actionscript-3

was wondering how i can check if sound object is buffering a http audio stream in as3? like shoutcast/icecast etc. i searched but nothing came to me that can do this job. so any hint or idea will be appreciated. i found isbuffering but the problem that isbuffering only stop when whole sound is loaded and this will never happen in a streamed audio.
Thanks alot

You can handle the "progress" event or check changing of the "bytesLoaded" property.

Related

setInterval with play() in flash as3?

I'm trying to play a sound (notification sound) in my flash application and I need to play the sound until the user clicks on something else to stop it.
I can play the sound properly but the issue is that it will only play once but i need it to play constantly (a short delay between each play maybe?).
my current code is this:
var mySound:Sound = new Sound();
mySound.load(new URLRequest("iphonenoti_cRjTITC7.mp3"));
mySound.play();
so I thought I can use setInterval(mySound,5000); in my code but this doesn't work which means it doesn't play the sound on the loop!
could someone please advise on this?
Thanks in advance.
Well, reading the Documentation of setInterval it states that the first parameter should be a function. In your code, you are passing an Object of the type Sound.
So, there are a couple of options, I'll show you the quickest and dirtiest one.
Instead of setInterval(mySound,5000); you write setInterval(mySound.play,5000);

ActionScript bit operations encoding audio to a FLV

I'm creating an FLV via AS3 using BitmapData; the resulting flv has no audio. So I'm trying to add an audio track on top. I've converted a Sound object's bytearray into a WAV bytearray.
I'm adding on FLV headers (specifically audio headers). I'm looking through documentation (pdf here), and this is how it specifies how to write the header:
I'm pretty new to bytes/bits and bitwise operators, so looking at how the video header was created, I'm wondering about a few things:
When it says bit flags, does this mean that all 4 options should be combined into a bitmask? Is that what the "0x08 : AUDIO" is telling me? That it should be in a byte (base-8, right?). So to store these options, would I do something like this?
//Write byte with options: uncompressed, 44khz, 16-bit, stereo
var tag:ByteArray = new ByteArray();
tag.writeByte(0x0321);
This seems wrong, ugh.
Or can I use tag.writeByte(2) to add each option on one at a time? I've also seen tag.writeByte(2 >>> 0xff) and what-not. I'm thoroughly confused. Could anyone help, or suggest a book or write-up where I might be able to figure this out?
In this image when it says UB(4), UB(2), UB(1), UB(1) under type for each field, does the "UB" tell me that they should all be combined? What does the [#] mean in this situation?
I've got my work cut out for me; but any help would be greatly appreciated!
Thanks a ton
There is an open source lib to encode Flv at runtime in as3, did you tried : https://github.com/zeropointnine/leelib/tree/master/src/leelib/util/flvEncoder ?

FLVPlayback VideoEvent.COMPLETE triggers before the video reaches the end, and the video stops playing

import fl.video.*;
var player:FLVPlayback = new FLVPlayback();
addChild(player);
player.skin = "someSkin.swf";
player.source = "http://someDomian/some.flv";
Here's the code. I just load and play some flv from server, and when I test it via Flash (just press ctrl+enter), the video will stop at about 90% of the video and dispatch the COMPLETE event. Any one knows why? Try it again, the time where the video stops is the same, just about 90%.
I searched it, and I tried to change playheadUpdateInterval of player, set totalTime explictly, or set bufferTime longer. All those solutions make no difference.
I tried to load another movie from the same server, same problem. Any chances something wrong with the server?
EDIT:
I sent the swf to someone else, and the video plays as it's supposed to do. Then another guy, and the same result. So, I guess there's something wrong with my settings? Is there some setting will cause this strange action? But when I tried it on my laptop, the video stops unexpectedly. Why this seems to work on everyone's computer except mine?
before CLOSE:
Eventually my colleagues found the strange reason causes this problem, if changing the publish setting to FP10 & 10.1 or FP9, it'll work as we expect. FP10.2 and up, videos on that server seem not have the talent to find their ending. The videos are H.264/AAC, if I convert them to VP60/MP3, all the FP versions will work. Since I can't modify the setting about the codecs, I'll just change the publish setting and leave the codecs thing alone. Although I'm just frustrated by this, if you see this and so lucky that you happen to know the codecs thing why the "early complete" appears, please please tell me.
The problem could be with the .FLV file, sometimes there could be problems while encoding any video file(AVI,MOV,MP4,3GP,WMV) in to .FLV format that results in skipped frames. Try your code with some other .FLV file if that works good then you need to re-encode your FLV file.
You can also try capturing the video Complete Event by tracking the Video Playback Progress.
import fl.video.*;
var player:FLVPlayback = new FLVPlayback();
addChild(player);
player.skin = "someSkin.swf";
player.source = "http://someDomian/some.flv";
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void {
if(player.playheadPercentage>=99)
{
//On Video Playback Complete Actions here
}
}

About getting sound waveform in AS3

Is it possible to get whole waveform of a mp3 sound in AS3 without the need to pass all the sound with the playhead and how?
Are there any functions that do this work.
I'm not sure if I completely understand your question, but you're probably looking for the SoundMixer class, which has a computeSpectrum() function that gives you a snapshot of the current sound wave: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/SoundMixer.html#computeSpectrum()

How to apply sound distortion in actionscript-3?

Let's say the sound input is either an embedded mp3 file or the microphone.
Is there an example of how to make it sound demonic and creepy, or like a radio transmission from the battlefield in actionscript-3 dynamically on runtime.
Reference:
http://www.youtube.com/watch?v=JAY88WH0FcU
As far as I know, you simply can't with the microphone, unless you first send it to a server.
With an audio file (embedded or not), you can distort it by playing with its bytes (ref), but its not at all a trivial task (I'm not aware of any library for "easy" sound processing).