Digital Signage - After like 2 hours videos are slow - actionscript-3

I have developed a system, in AS3 for Android, where one video after another plays, but after letting them run for an hour or two, the videos show between cut or slow. That happens when I run it on an android with device, but that does not happen on my PC. I have used the "dispose()" of the NetStream and set the NETSTREAM to NULL. Could someone tell me what's wrong? I've also set hardware acceleration to "DIRECT" and RENDER MODE to "AUTO". Oh, I also use System.gc();

Related

Wp8 SetAudioEndpoint messing with audio hardware clock?

I'm using WASAPI to capture and render audio for a VoIP application on Windows Phone 8. The app works fine when using the earpiece, but as soon as I switch to speakerphone, a distinct clicking noise appears on the far end. Looking into the timing of my system, I found that after I switched endpoints to speakerphone the mic hardware timer starts to act weird.
My audio loop starts with a WaitForMultipleObjectsEx which is woken up every 10ms by the mic capture event. After switching audio endpoints, I find this this event fires 101 times in 1 second, instead of 100. Every second, the last capture of 480 frames is split into 2 captures, whose timings add up to 10ms. This confuses me to no end, and is causing problems in my audio system.
Does anyone know what is going on, or can someone point me in the right direction?
MSFT is officially looking into a bug in WASAPI caused by multiple endpoint switches. It is confirmed on RT and being investigated for Wp8. Just an update.

How to Check Adobe AIR applications performance ?Any tools?

Hi I'm creating an adobe AIR application..Its working fine ,But I want to make my application without performance issues..How to Check Adobe AIR applications performance ?Is there any tools available?
Take a look at Adobe Scout
"Adobe Scout is the next-generation profiling tool for Adobe Flash Player and AIR."
When building any flash application you define the application FPS. If the real FPS (flash can skip frames under high load) is lower than the defined FPS- you have troubles. You can check the FPS by vast variety of FPS meters here.
If your real FPS coinsides with the defined one - it is great, but try rising the defined FPS value up to 120 (which is max) and check out the real value, it is hardly be higher than 60 during animations, but the higher you can get - the better your application is. With this approach you can eliminate or at least point out "slow code".
ADD: It also worth mentioning that if the defined FPS value is 24, and the application is in stable state (the amount of animation, animation complexity and computational complexity stay more or less the same) the real value will "float" across some value, let's say 23 FPS with the spread of 1-2 (i.e. 22.7, 23.5, 23.9, 23.1, etc). And the mean value will be always lower than the defined FPS value.
Try to check memory usage. I would start trying to launch Flash Builder profiler remotely while your app is running live on the device and check out memory utilization. Refer this
Try to check redraw regions. Note that MovieClips that are not visible (e.g. throbbers) are still redrawing unless the are stopped. So if you see some region redraws without sencible reason - try to figure out why. The ideal case is to call stop() and visible=false or remove from stage the unused animations.
ADD: Redraw regions indicator is a part of Debug version of Flash Player. You can enable it through the context menu of the debug version of Flash Player.
UPDATE: I added some details to my answer as I see the interest to the Adobe Flash Perfomance issue. I don't remember the exact acticle, but I found a lot of usefull advices on the Abode's site, now I see that the number of such articles there increased.
Also I didn't know about the Adobe Scout before, but it sounds promising. I'll definately try it soon.

My Sound object is using to much memory and causing my application to crash. How can I empty the first half of the objects data?

I'm currently working on a dynamic MP3 player in AS3. The player will also support continuous (in length) radio streams.
Because my player will include a 'seek' bar, I allow the user to seek through the Sound object's data. Now I know that with a continuous stream, data being stored on the users RAM will never stop, as downloading will never stop on a continuous stream. This means, after a few hours of streaming, allot of RAM is being used by my app. I've tested the app on my own machine, running a very high spec, and the app crashes in my browser. When i say the app crashes, I mean the whole of Flash, meaning I have to restart my browser in order to use Flash again. I know my app is the cause as Flash has never crashed in the past. It only does it when my app has been streaming for 2+ hours.
So what I want to do is only allow the user to cache up to an hours worth of audio. After an hour, I want to clear the first half of the sound objects data, meaning that only the most recent half hours audio is stored and available for seeking.
So I have my stream:
var soundObj:Sound = new Sound();
soundObj.load(new URLRequest('stream.mp3'));
//ect ect
and sound is where the data is stored. So my question: How would I clear the first 30 mins of audio from that object?
Perhaps the Sound class is not meant to reliably play "unlimited" MP3 files, which seems to be your case. It is made to play normal MP3 "songs". Two hours of MP3 sound can easily accumulate to be larger than 200 megabytes of data.
But there is a good solution - use NetConnection and NetStream classes to stream audio instead. There are many tutorials out there. You will also be able to stream your MP3s, just a bit differently - a central server will be involved, which will transcode these MP3s on the fly, delivering it to you in a true "streaming" manner. One of such servers is Adobe Flash Media Server, an overpriced piece of work from Adobe. A lot of free and open-source alternatives exist which will work fine for your purposes - Red5, nginx-rtmp to name a few, that I have tested myself.

Is there a way to influence automatic sound settings in Flash / AS3?

I am creating a voice enabled application in Flash using RTMFP and I noticed that the Flash plugin automatically regulates down the sound volume of other processes/applications (at least on Windows) as soon as a RTMFP stream is opened and starts playing - very similar to the way Skype does this. Furthermore it seems that Flash also regulates itself (!) down in volume as soon as the Microphone is accessed what is quite contraproductive in group conferences. See: http://i50.tinypic.com/2415r4k.jpg
So, what I am trying to do is to get access to the automatic sound settings, either to disable or to set my own rules for them because the defaults don't work out very well in my oppinion. Unfortunately, searching on this topic did not raise any usable results so I hope that maybe someone else has managed to do this already and is able to give me a hint.
If this is not possible in general it would still be sufficient to disable automatic sound settings on every NetStream opened so that at least these are always at 100% volume or more, depending on the case. Does anyone know if manually setting the volume/gain on a NetStream instance overrides the automatic settings made by the plugin? Or is the automatic sound setting always overriding that/adding to that settings and entirely out of a developer's influence?
Thanks in advance
It's more of a Windows 7 problem and not directly related to Flash. You can change this behavior if you check your settings in the Control Panel: Sound - Communications - "When Windows detects communications activity".
There is no workaround from the Flash point of view, as the operating system itself controls this volume adjustment. If you use SoundTransform(1) on your NetStream, the Flash Player outputs the full volume, but the Windows sound manager is one level above and turns it down again.

Sound latency in AS3

I am triggering short sounds dynamically from the library for a game (Specifically Air for Android). When the user clicks a button the sound can take up to 600ms to actually play.
I have set it for any silence before the actual sound by calling the sound like so:
private var channel:SoundChannel = new SoundChannel();
private var buttonClickSound:Sound = new button_click();
public function buttonDownClick() {
channel = buttonClickSound.play(63);
}
Still getting a ridiculous amount of latency.
Things I have tried:
converting MP3 to wav
placing Sound Clip in the timeline
calling Sound Clip from urlLoader
All return the same results. I know there are threads here that talk about this but none have offered a real solution that I can find. Is there no way to cache the sound or store it in a buffer?
Thanks for looking.
Important update
The flash CS5 AIR for android functionality was never out of beta. And sadly as adobe is famous for, the functionality has been discontinued for flash CS5 so that the full working/updated version will become a selling feature for CS6 or CS5.5. I have many, many feelings about this as a customer who has spent literally MANY THOUSANDS of dollars on adobe products but I'll keep this about information and not my burning rage towards adobe feelings. For proof of this see:
http://labs.adobe.com/technologies/flashpro_extensionforair/
So it is most likely that this is one of many bugs left unfixed in AIR for android in CS5. This is not a surprise, as when I bought CS4 master collection which promised AIR 1.5, even AIR 1.5 was left broken and all bug fixes were rolled into 2.0, which was only available for CS5. One of the biggest bugs they never fixed in CS4 AIR 1.5 was a major, crippling bug in webkit which nearly rendered any use of webkit in AIR non-functional. In fact when I worked for Webkinz.com, a major project was completely thrown out the window and I was actually ridiculed for proposing using AIR, touting all it's amazingness and then left looking like an idiot in front of all my peers when these bugs appeared. Literally I'm not kidding the head of my 180+ developer division centered me out in a meeting around a gigantic table with every major player in that company.
Anyway perhaps my update did bleed into somewhat of a rant but it's good information I think and a good lesson to be learned, which is always assume the worst with Adobe products. Fortunately, as mentioned in my answer, it's not a dead end and there are ways around their "business model."
Original Answer
It's a bug in AIR for Android:
http://forums.adobe.com/thread/753977
That post is dated, but I've seen several more around the same time frame and enough that I'd call it a fact. Have you updated flash CS5? ( Go to Help->Updates). To be honest I don't even know if they have patched/addressed this bug yet but your best bet of finding out is to grab the very latest Flex SDK and try manually packaging your SWF into an APK using it. Instructions:
http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac25d3d8c712b2d86751e-8000.html#WS901d38e593cd1bac25d3d8c712b2d86751e-7ffb
More detailed/tutorial-like instructions:
http://thulasiramsoft.wordpress.com/2011/01/16/build-apps-for-android-using-as3-without-a-device-using-flex-air/
If this is a bug this is where you're going to see the fix appear first. Try packaging your SWF into an APK manually using the above methods and ensure you've updated the AIR for android on the device to AIR 2.6 (latest, just go to the market to update). This will either fix the problem or eliminate it as a possibility both on the compiler and runtime side.
Sound latency is a bug in Flash exporting to AIR.
Easy way around is to make some background music playing, then sound device doesn't go to sleep. If you don't want music you can make some silent sound playing forever. This solves the problem with sound delay for other short sounds.
[Embed(source="sfx.mp3")]
const snd_sfx:Class;
const sfx:Sound = new snd_sfx();
const SilentSoundTransform:SoundTransform = new SoundTransform(0);
function playSoundSilentlyEndlessly(evt:Event = null):void
{
sfx.play(0, 1000, SilentSoundTransform).addEventListener(Event.SOUND_COMPLETE, playSoundSilentlyEndlessly, false, 0, true); // plays the sound with volume 0 endlessly
}
playSoundSilentlyEndlessly();