8 Replies Latest reply on May 4, 2010 9:14 AM by robertelrod

    Play local FLV files in AIR




      Here is another question regarding FLV files: I'm developing my AIR application using Dreamweaver. My app will need to play some local FLV files wich will be delivered together with the application (they are not online).


      I'm using the built in feature of Dreamwever, wich creates a small SWF called "FLVPlayer_Progressive.swf" when you insert an FLV in the page. If I preview the page in Firefox, everything works fine and the video is played, but if I preview it in AIR, there is just a blank box where the video should be.


      All the files are in the site's root folder and are included in the "AIR application settings" (FLVPlayer_Progressive.swf, Clear_Skin_2.swf, video.flv, index.html and application.xml).


      I tryed importing the video in Flash (through progressive download) and then creating a small SWF wich would work only as a player but it didn't work either. The only way it worked was if I actually embedded the video in the SWF (so there is no external file), but then I have some audio synchronization problems and I loose quality...


      So the problem seems to be that AIR doesn't allow the SWF file to access external files, even if they are in the same folder. Is this a bug or is there a workaroud?





        • 1. Re: Play local FLV files in AIR
          Joe ... Ward Level 4

          You may be running into a bug. What is probably happening is that AIR helps the SWF resolve the relative path to the video file, but mistakenly uses the "app:/" URL scheme in this situation. The workaround is to construct an absolute path to the video or to make sure both the SWF and the video are outside the application directory so that the app:/ URL scheme isn't used.

          1 person found this helpful
          • 2. Re: Play local FLV files in AIR
            mschutze Level 1

            Well, I just spent a few hour trying to make this work, and still nothing... but I think I know now what the problem is.


            As you said, after putting an absolute path in (I used "C:\video.flv" for testing) it worked fine! So what I did was create a code that would get the absolute path to the video located in the app-storage folder. I came up with the following:


            var flvFile = air.File.applicationStorageDirectory.resolvePath("data/flv/video.flv");
            var flvFilePath = flvFile.nativePath;


            This code returns flvFilePath as "C:\Documents and Settings\Manuel\Application Data\Test.08196269638DC859464A7A09369FF97BAC18DD7A.1\Local Store\data\flv\video.flv".


            I tried suplying this path to the player but it didn't work. So I inserted a new player in Dreamweaver using the path above and I got a message saying that the path can't have any spaces. This seems to be the cause of all my problems! I tried substituting the spaces with "%20" but it didn't work either.


            Do you have any ideas?

            • 3. Re: Play local FLV files in AIR
              mschutze Level 1

              I actually found simple sollution: I just switched from the Dreamweaver FLV player to a player called JW FLV Player. It works fine now!


              Thanks for the help!

              • 4. Re: Play local FLV files in AIR

                This would seem like it would be something that a lot of people would want to know.  Does anyone know if this is a bona fide bug for Dreamweaver?



                • 5. Re: Play local FLV files in AIR
                  Quentin T

                  I also ran into this problem...

                  Fixed by using an absolute path, for which window.runtime.flash.filesystem.File.applicationDirectory.nativePath can help.


                  I hope this gets fixed in a future AIR release, that app:/ issue is quite annoying and hardly documented!

                  • 6. Re: Play local FLV files in AIR

                    mschutze, i've downloaded and attempted to use jw flv player but it's not working for me. any chance you could pass along your solution with jw flv player?


                    thank you!


                    • 7. Re: Play local FLV files in AIR
                      Manuel Schutze

                      Try using the following code:

                      <script type="text/javascript" src="scripts/swfobject.js"></script>

                      <div id="player"></div>
                      <script type="text/javascript">
                           var videoName = "videos/video.flv";
                           var flvFile = air.File.applicationStorageDirectory.resolvePath(videoName); //videos are in the storage directory
                           flvFile = flvFile.nativePath; //gets the absolute path to the flv file

                           var slash = air.File.separator; //gets if the separator slash is "\" or "/" (windows or linux/mac)
                           if(slash == "\\") { //if the slash is "\" (running windows), turns it into "/"
                                flvFile = flvFile.replace(/\\/g,"/");
                           var video = '&file='+flvFile;
                           var so = new SWFObject('app:/player.swf','mpl','610','426','9');


                      Hope it works!

                      • 8. Re: Play local FLV files in AIR
                        robertelrod Level 1

                        Thanks for forwarding that script. Unfortunately, it doesn't want to work for me.