OSMF uncaught Error - actionscript-3

I am using the OSMF to play HDS videos, the player is hosted in a 'parent' player that removes the OSMF using unloadAndStop() which results with the following error:
Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.
at flash.net::NetStream/play2()
at org.osmf.net.rtmpstreaming::RTMPDynamicStreamingNetLoader/reconnectStream()
at Function/<anonymous>()
When removing the OSMF using unload() the error does not occur .
I have made many attempts to resolve this or to try and catch the error but so far with no success, please share if you have any clue on how this might be resolved.
Thanks!
Eran

UnloadAndStop completely clears out everything (ready for Garbage Collector to free up the previously used memory) so now when your Play2() comes in, it finds access to nothing. You can try and separate a part of your code into smaller functions. i.e
Function One for setting up new netStream & netConnection etc
Function Two for playing netstream
Function Three can be for play2() where you have If/Else to check if not_unloaded == true then do play2(); else do Function One from here as a reset
PS: also these two links might help you as I dont (nor need to) know the rest of your code setup. Wether they talk about SWF files or Netstream it all applies the same
http://www.nikesh.me/blog/2010/04/unload-loaded-swf-file-by-unloadandstop-method/
http://www.breaktrycatch.com/problems-with-unloadandstop-a-guide-to-some-undocumented-caveats/

Related

Error #2154 removing OSMF video player from stage

I am using osmf player to play HDS format videos. At a certain scenario I am stopping the video and removing it from stage. For some reason it throws the following error:
Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.
at flash.net::NetStream/play2()
at org.osmf.net.rtmpstreaming::RTMPDynamicStreamingNetLoader/reconnectStream()
My attempts to fix it were not successful so I am looking for a way to catch this specific error somehow.
I am looking for ideas on how to handle this error in my code(can't use global error handling).
Any directions on how to fix this bug would be also awesome!
Thanks!

trouble getting flashdevelop to correctly identify sampling rate of a sound file

I'm trying to put a sound file into a flash program with the following code.
[Embed(source="../lib/DST-Aircord.mp3")]
static var sndtrck:Class; //used to represent the background music file
static var soundtrack:Sound; //used to handle the soundtrack file
soundtrack = new Sound();
soundtrack.load(sndtrck);
soundtrack.play();
I'm not sure that this is correct but it is throwing the following errors.
Error: Unsupported sampling rate (32000Hz)
Error: Unable to transcode ../lib/DST-Aircode.mp3.
Regarding the first error I checked in iTunes and the sampling rate is 44100Hz which I believe is what Flash needs to run. However FlashDevelop is incorrectly determining the sampling rate? I'm guessing that the second error is caused by the first although I'm not entirely sure what it means. Does anyone know what I might be missing in my attempt to embed sound into this SWF?
EDIT: changing the load function to use the path specified in the embed code yields the same error.
the load function of the Sound class only takes a URL of an external sound file. Im not sure what the class your putting into it is, but it probably throws the errors because a Class itself is not a sound file.
This is a link to the load() function of the Sound class, everything about it is there.
While writing this answer I realized that the question is pretty old. ;)
Anyhow, I ran into the same problem a while back and it could be solved
by this: Unsupported sampling flex/actionscript

event listener for flex/air action script errors

I'm trying to add an event listener to my air application that would prevent the "ActionScript error" window from appearing, so I can handle the error within my application.
I was able to find a little information about this from adobe. I'm just not sure what I should be listening for.
It depends quite a lot on what error is thrown, and why.
Your best bet is to carefully read the ActionScript documentation and add listeners to react to all of the errors that have explicit ErrorEvents (such as IOErrorEvent and SecurityErrorEvent). Those are usually related to network and/or file access, and security issues.
For most other errors, there is the try {} catch() {} finally {} statements. This tutorial might be a good place to start.
And if all else fails, there's UncaughtErrorEvent.
But you should really be using that one as a last resort, not as a magic bullet - the best error handling is a) trying to prevent errors from being thrown in the first place (make sure all variables are properly initialized, test for null, etc.), and b) handling expected runtime errors by catching them explicitly, in order to keep the application running and stable.
You have a couple options. As you know, exception handling is not always possible for certain asynchronous operations.
First off, you need to know what object is responsible for the asynchronous operation that is causing the error. The most sensible approach would be to add the necessary error event handlers to this object.
For instance, a URLLoader performs asynchronous operations; and it's failure can only be handled by adding error event listeners. For example:
var loader: URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
Another 'catch-all' option is to take advanage of the new UncaughtErrorEvent feature of Flash Player 10.1. For this to work, you need to attach the uncaught error handler to the loader of the main application; this will catch everything! For example:
loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, loaderErrorHandler);
private function loaderErrorHandler(e:UncaughtErrorEvent):void {
if(event.error is Error) {
// handle error from embedded SWF
}
// suppress error dialog
e.preventDefault();
}
The last option may not be the best approach as it promotes the swallowing of exceptions instead of addressing and handling the problem properly; nevertheless it can be useful in certain unique circumstances (embedding SWFs).
The window won't appear if you're running the standard version of Flash Player.
It will manifest only as a dialog box on the debugger versions of the
browser plug-ins and stand-alone players, as a message in the output
panel in the authoring player, and as an entry in the log file for
Adobe Flex Builder 3. It will not manifest at all in the release
versions of Flash Player or AIR.
Source : here.

Flash AS3 security errors attempting to load chromeless YouTube

I am getting flash-base security errors when attempting to load a chromeless YouTube swf...
Warning: Domain www.youtube.com does not explicitly specify a meta-policy, but Content-Type of policy file http://www.youtube.com/crossdomain.xml is 'text/x-cross-domain-policy'. Applying meta-policy 'by-content-type'.
Error: Request for resource at http://www.youtube.com/apiplayer?version=3 by requestor from http://... is denied due to lack of policy file permissions.
*** Security Sandbox Violation ***
Connection to http://www.youtube.com/apiplayer?version=3 halted - not permitted from http://...
I've attempted all relevant variations of Security.loadPolicyFile and Security.allowDomain, but I continue to get these errors.
If I ignore these trace errors (I get no callback errors from the Loader) and attempt to use the player (via loader.content during the Loader's Event.INIT), then any attempts to access the YouTube APIs causes a crash.
If I look at my player (Object) variable in a debugger, I see that it is actually a com.goggle.youtube.application::SwfProxy which is derived from Sprite. Outside of the standard Sprite vars and functions, it contains enableJsApi = false, loader = null, and player = "http://s.ytimg.com/yt/swfbin/apiplayer3-vfljSpMoI.swf"
But attempts to call functions such as player.setSize or player.loadVideoByUrl will cause a crash such as...
Exception thrown (TypeError: Error #1006: setSize is not a function.
Please advise.
I have worked with the Chromeless player before and gotten these errors. They are so frustrating. A number of the errors can be ignored because YouTube still hasn't renewed their default policy file.
Whevener you try to add any mouse event listeners to the gadget directly you will get errors that will cripple the runtime process. What I had to do to add mouse interactivity was to add a sprite above the movie clip with a hole where their logo shows up (so that someone can still click their logo) and then add event listeners to your own srite.
Hope this helps.
What finally worked to remove the errors was specifying... LoaderContext(false, new ApplicationDomain())

Merge FLA files or Loading a swf file on another swf

I have two FLA files, call them MAP.fla and ANI.fla, that I have to merge. One way I tried was to load the ANI.swf in MAP.swf during runtime using the normal way of doing it, using Loader and URLRequest. However, when I try to run it, flash detects errors about methods I have included in ANI.swf.
I do know that the Loader and URLRequest method of doing it works because I tried using it with a different SWF file with simpler content.
P.S. ANI.swf contains methods, instances with classes of their own and timer events. If Loader cannot work on my SWF, is there any other way of carefully doing this without affecing my FLAs?
Below is the error message i am getting. Thanks. :)
TypeError: Error #1010: A term is undefined and has no properties.
at stageRotation/stageRotation::pause()
at stageRotation/::create()
at stageRotation/::initStage()
at stageRotation$iinit()
Loader and URLRequest, are the best ways for doing this work.
your problem may causes by an illegal (unsafe) refering to "stage", from ANI.SWF, or calling ANI.SWF functions from MAP.SWF but in a wrong way.
Can you attach that error message?