7 Replies Latest reply on Jan 27, 2009 7:32 AM by mbulpitt

    NetStream under AIR

    starman2049
      I have an existing Flash 8 / AS2 application that for the most part is running just fine under AIR. The one thing that is not working is playing movies (.FLV's). I use NetConnection and NetStream to load my movies as follows:

      var my_nc:NetConnection = new NetConnection();
      my_nc.connect(null); // Create a local streaming connection
      var my_ns:NetStream = new NetStream(my_nc); // Create a NetStream object

      INTROMOVIE.attachVideo(my_ns);
      // Set the buffer time
      my_ns.setBufferTime(6);
      // Begin playing the FLV file
      my_ns.play("videos/pnlogo.flv");

      This has worked just fine for a long time, but under AIR I get nothing but black screen. I am going to track down how to debug/trace under AIR, but wanted to know if anyone had any experiences here as playing .FLV's is a pretty common task...

      Any help is appreciated!!
        • 1. Re: NetStream under AIR
          Oliver Goldman Adobe Employee
          Is "videos/pnglogo.flv" in your application directory? In Flash this would resolve to a file on the server, but in AIR it will resolve to the application directory.

          Oliver Goldman | Adobe AIR Engineering

          • 2. NetStream under AIR
            starman2049 Level 1
            Yes, it is there. I also tried:
            my_ns.play("app:videos/pnlogo.flv");
            my_ns.play("app:/videos/pnlogo.flv");

            and then I also moved the movie to the root (where my main movie is and the app descriptor), and tried:
            my_ns.play("pnlogo.flv");

            I also just clicked on the main swf in the root install directory (not the .exe) and the movie plays just fine there.

            This is a Minigolf game and I load many other things just fine, both in the root directory and in sub-directories. Each hole is a different .swf, and each game object is a .swf in a sub-directory.

            I will add some debug prints to help figure out what is wrong, but I don't make frequent use of movie playing - just an intro movie - and so I am not doing anything fancy, just copied an example of how to load and play a .flv from the documentation. That's why I am a little surprised that I am the only one having this problem.

            Thanks for getting back to me.
            • 3. Re: NetStream under AIR
              starman2049 Level 1
              Ok, so I put up some debug displays and found that when I try to execute:

              NetStream.play("app:/videos/pnlogo.flv"); (and all the combos listed above)

              I get the following error:

              NetStream.Play.StreamNotFound

              Finally, I try the fully qualified path as follows which WORKS!!

              NetStream.play("file://C:/Program Files/Black Mountain Games/Putt Nutz FX AIR Demo/Putt Nutz FX AIR Demo/videos/pnlogo.flv");

              So it is starting to look like you cannot use NetStream to play local files because it doesn't know how to handle the "app:" part (again, this is a Flash 8/AS2 game).

              Anybody else experiencing this?

              So I am going to try to kludge it by somehow determining where the appis installed to and hand-building the relative path, but that concerns me as my quess is that might differ between MAC and Windows.

              Funny thing is when I use the PROCMON tool from Microsoft/Sysinternals I see all the other files opening up but I don't see a request (or error) on the .flv -- just some registry activity on video codecs. Maybe I have to register flv's as a file type in the Application Descriptor???

              Any insight or ideas from anyone is appreciated!!
              • 4. Re: NetStream under AIR
                enorton@adobe Level 1
                Hi starman,

                Relative URL behavior in AIR is different from Flash Player. All calls are relative from the caller. This is true for all versions of AS and SWF.

                If you directory structure looks something like

                {path}/MyApp/appRoot.swf
                {path}/MyApp/app.xml
                {path}/MyApp/videos/theMovie.flv
                {path}/MyApp/swfs/theGameObject.swf

                Where appRoot loads "swf/theGameObject.swf" and it in turn wants to load your "{path}/MyApp/videos/theMovie.flv", either of the following URLs in the NetStream.play call should be okay:

                "app:/videos/theMovie.flv"
                "../videos/theMovie.flv"

                I hope this helps!

                -Erica
                • 5. Re: NetStream under AIR
                  starman2049 Level 1
                  Erica,

                  Thanks for getting back to me. I tried both paths but neither works - still getting "NetStream.Play.StreamNotFound".

                  I also should mention that I am embedding my entire package in an html page so instead of loading my root .swf I am loading an html page that has the movie embedded.

                  If I instead create my air package to load the main .swf then the movie loads ok using the "app:/videos/pnlogo.flv" path, but I have other problems with loading a swf directly that I am goint to post in another thread (The "Stage.width" property is undefined)
                  • 6. Re: NetStream under AIR
                    enorton@adobe Level 1
                    Hi Starman,

                    Thanks for the clarification. Sorry for the delay in responding...had a couple days off there :)

                    SWF in HTML, relative URLs still follow the Flash Player rules. I do see the same problem as you are seeing in that situation with NetStream.play(). Thanks for the report, and we're logging a bug.

                    As for the Stage.width/height issue. That is a bug that we are already aware of. I'll reply to that thread about it as well.

                    -Erica
                    • 7. Re: NetStream under AIR
                      mbulpitt
                      Any idea what the status of this bug is?

                      Mark