After recording a sound and converting it into wav...
var enco:WaveEncoder=new WaveEncoder();
var o:ByteArray=enco.encode(soundO,1,16,44100);
I pass it to ShineMP3Encoder
_mp3_encoder = new ShineMP3Encoder(o);
_mp3_encoder.addEventListener(Event.COMPLETE, onMP3EncoderComplete, false, 0, true);
_mp3_encoder.start();
onMP3EncoderComplete has two vars
var mp3:ByteArray = _mp3_encoder.mp3Data;
var wav:ByteArray = _mp3_encoder.wavData;
wav audio is normal, but mp3 almost always (99%) has a clicking sound when audio begins.
Here's a picture from SoundForge app.
We can see these two files are identical, but mp3 has a clicking sound at the beginning.
Is it my system/hardware/compiler problem or it's something else?
btw I tried some online swf example of ShineMP3Encoder and it has same issue. So probably that's not my compiler problem
Related
Right now in my site I'm using
<embed name="audio" src="audio1.mp3" loop="true" hidden="true" autostart="true">
to play audio files on the launch. I want to be able to have randomly choose from a collection of audio files in the directory. How can I do this?
EDIT : Sorry I have misread the question.
It is impossible to select folder and get the files. This is due to security feature of the browser.
You may however
Create an array that stores your url sources. Then randomly select an item from the array
var source = [
"https://www.sample-videos.com/audio/mp3/crowd-cheering.mp3",
"https://www.sample-videos.com/audio/mp3/wave.mp3",
"http://www.kozco.com/tech/organfinale.mp3"
];
function randomPlay(){
var toPlay = source[Math.floor(Math.random()*source.length)];
var player = document.getElementById('player');
player.src = toPlay;
player.load(); //call this to just preload the audio without playing
player.play();
}
See this fiddle
https://jsfiddle.net/tq4ughrc/11/
I'm trying to achieve seamless looping of an MP4 (or M4A to be more specific) sound. The usual method of loading, playing to the end, and then seeking to position zero causes a small delay (less than a second) before the second playback begins.
So now I'm trying to preload the sound data and then use NetStream.appendBytes() to append the whole sound data at the end of the original sound, expecting the sound to repeat once. But first, I want to be able to play the sound just once using the appendBytes() method. Here is the code I wrote that doesn't give any errors but doesn't play a sound either:
var data:ByteArray = new SoundData; // SoundData class contains the embedded M4A file data
var connection: NetConnection = new NetConnection();
connection.connect(null);
var stream: NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
stream.client = {};
function onNetStatus(event:NetStatusEvent): void {
trace(event.info.code, stream.time, stream.bytesLoaded, stream.bytesTotal);
}
stream.play(null);
stream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
stream.appendBytes(data);
Am I using appendBytes() correctly?
I ended up using a hack for achieving apparent seamless looping: loading two sound files through NetStream, playing one, and 100ms before its end, starting to play the other.
I have a video that is an swf file with length 03:02 (3 minutes & 2 seconds) 4552 Frames.
Now in different timing of this video I want to synch 4 audio files.
Is there any possibility to synchronize all sounds on the video?
My audio files must be placed in exactly positions. For example the second audio must be loaded at 01:27:30.
I have extended my timeline to 4552 frames (03:02) and I am using the code below in different frames to load my audio files:
var soundClip:Sound=new Sound();
//Create a new SoundChannel Object
var sndChannel:SoundChannel=new SoundChannel();
//Load sound using URLRequest
soundClip.load(new URLRequest("secondsound.mp3"));
sndChannel=soundClip.play();
And if there is a way to synch my audio files is there any possibility to preload the whole movie with all sounds and with my .swf file?
track the netstream time property and call your sounds when the video reaches the times you want to hear them.
I'm building a webcam recording app in CS5 and I'm having some seemingly random issues with the recorded flv. Currently I'm publishing a stream to Wowza Media Server using the standard _netstream.publish("movieName", "record") command. Everything regarding this works fine and I can play the file back but sometimes there's a 3 to 4 second pause at the beginning or end of the video. There will be a still frame and the time will sit at 0 and then snap to 4. I've explored bandwidth options and I've turned the resolution and quality down considerably and it doesn't seem to have any effect and the rest of the video will play back smoothly. Here are my current camera and mic settings.
_cam.setMode(160, 120, 30, false);
_cam.setQuality(0, 88);
_cam.setKeyFrameInterval(30);
_mic.rate = 11;
I'm also flushing the buffer before closing out the publish stream
_netstream.publish('null');
Could there be something going on with camera initialization/deactivation that causes the lag?
Any help would be greatly appreciated. Let me know if you need more details
I believe this has something to do with the way that the Flash plugin itself initializes and displays the camera.
If you set up a simple test to try setting and unsetting the video stream:
var cam:Camera = Camera.getCamera();
var webcam:Video = new Video(500, 375);
addChild(webcam);
var isPaused:Boolean = false;
function showWebcam():void {
if (!isPaused) {
cam = null;
} else {
cam = Camera.getCamera();
}
webcam.attachCamera(cam);
isPaused = !isPaused;
}
pausingButton.addEventListener(MouseEvent.CLICK, showWebcam);
You'll notice a definite pause as it switches between the two states.
From what I've seen, every time I call attachCamera() with a video object, there is a noticeable pause of the Flash Player itself (including all tweens, interactions, everything) when the method is called, even if the object I'm attaching is null.
Four seconds seems like an excessive lag, but I have noticed that the larger the input/video render and with smoothing = true set on the video object can affect the length of the delay.
As for a solution; I'm not sure if there is one achievable via pure Actionscript, since the delay appears to be down to how the Flash Player itself initializes and renders the live video object.
I am trying to stop the audio of the video swf and I can't get it to stop. Here is my code for loading the file:
var myLoader:Loader= new Loader();
myLoader.x=420;
myLoader.y=200;
// boolean variable set for use below in our function
var screenCheck:Boolean = false;
//These three linces keep stafe elements the same size, so they don't distort
var swfStage:Stage = this.stage;
video_btn.addEventListener(MouseEvent.CLICK,contentvideo);
function contentvideo (event:MouseEvent):void{
myLoader.load(new URLRequest("prevideo.swf"));
addChild(myLoader);
movie_btn.stop();
movie_btn.visible=false;
}
Now I have other functions that load different URLRequest and when they are loading, the audio keeps playing. Do I have to add a line of code to them? I also have an MP3 player and tried SoundMixer.stopAll(). I still need the mp3 player to keep playing.
I'm not familiar with what you're doing but just looking at the code and given the problem you're experiencing I wonder if that
addChild(myLoader);
has anything to do with it. It seems like the kind of thing that could easily create multiple child objects which is why you continue to experience the sound play back. Is there a removeChild[0] option or something?
A shot in the dark I know but I thought I'd offer the possibility anyway.