Skip navigation
dsentivan
Currently Being Moderated

Accessing a local video file

Jul 16, 2010 9:20 AM

I want access a local video file with my app and launch it in the native player. I tired including the movie.m4v file in the app and launching it with: navigateToURL(new URLRequest("movie.m4v")); but it does not work. Is there a way to launch a local video file?

  • Currently Being Moderated
    Jul 17, 2010 9:56 PM

    i have the same problem. Any help would be appreciated


    |
    Mark as:
  • Currently Being Moderated
    Sep 7, 2010 8:08 AM

    hi Guys!

     

    I have the same problem...

     

    here is my code:

     

     

     

    import flash.net.*;

    import flash.events.MouseEvent;

     

    video_btn.addEventListener(MouseEvent.CLICK, mouseDownHandler);

    function mouseDownHandler(event:MouseEvent):void {

    var str:String = "movie.m4v";

    var urlReq:URLRequest = new URLRequest(str);

    navigateToURL(urlReq);

    }

     

     

     

    I also tried with app:/    (app:/lipton.m4v) but it opened the video only in printCentral (which is not good). When i deleted printcentral it's not opening at all...

     

    any luck on your side guys?

     

    thanks,

    Ann

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 20, 2010 11:26 AM

    Same problem here.

     

    I want to access the .h264 video within my application directory. "naviagateToUrl" seems not to work within the application directory. This has nothing todo with the file type. Even a simple .html can't be accessed.

     

    Of course it's not a problem to access files from the internet.

    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2010 3:24 AM

    Hi,

     

    I tested around a little too and found out the following:

     

    var file:File = File.applicationDirectory.resolvePath("example.mp4");

     

    navigateToURL(new URLRequest(file.url);

     

    works fine on the iPad but does nothing on the iPod. Couldn't test iPhone yet.

     

    Greetings~

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 3:59 AM

    Just tired it on iPhone doesn't work.. ;S wow I wish Adobe would just release all the information we need.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 7:18 AM

    @ChoosingNamesCanBeSoXXX: This is confusing since I'm testing on two devices:

     

    - iPhone 3GS with iOS 4.1

    - iPad with iOS 3.2.2

     

    Which iOS is running on your iPad? I think it must be the same version?

     

    Maybe you could paste here your few lines of code or your complete test-setup?

     

    Well, I invested even more time but to me it seems like navigation requests within the app-directory simply fail. No errors will be thrown, nothing happens.

     

    So please Adobe, give us at least some feedback.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 10:02 AM

    Quick update: As I mentioned on my blog I can't access any file type within my application directory. So there might be some restrictions?

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 1:39 PM

    Heya,

     

    @ChoosingNamesCanBeSoXXX: This is confusing since I'm testing on two devices:

     

    - iPhone 3GS with iOS 4.1

    - iPad with iOS 3.2.2

     

    Which iOS is running on your iPad? I think it must be the same version?

     

    Maybe you could paste here your few lines of code or your complete test-setup?

     

    Well,
    I invested even more time but to me it seems like navigation requests
    within the app-directory simply fail. No errors will be thrown, nothing
    happens.

     

    Sadly I can't tell u the current version, since I don't have it around me right now. (Will check later)

     

    Tested and working Code for iPad: (test_btn and status_txt already on stage)

     

    import flash.filesystem.File;
    import flash.events.MouseEvent;

     

    var file:File;
    var urlrequest:URLRequest;

     

    function init():void
    {
        status_txt.text = "app init";
       
        file = File.applicationDirectory.resolvePath("test.mp4");   
       
        urlrequest = new URLRequest(file.url);
       
        test_btn.addEventListener(MouseEvent.CLICK, spam);
    }

     

    function spam(evt:MouseEvent):void
    {
        status_txt.text = "button spam";
       
        try { navigateToURL(urlrequest); }
        catch (e:Error)
        {
            status_txt.text = "error: " + e.name + "/" + e.message;
        }
    }

     

    init();

     

    I tried to work with try and catch for the iPod but as u mentioned no error got thrown here either -___-' I was wondering if it has something to do with the config of the devices, but don't have any for myself to investigate more.

    Quick update: As I mentioned on my blog I can't access any file type within my application directory. So there might be some restrictions?

     

    I already tested mp4 and xml-files successfully. =o Do u know, that u have to include the files for publishing? (Just like the Default.png)

     

    Greetings~

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 2:32 PM

    I've put the video file in the same location as Default.png   .. I even added the video file in the iPhone Settings.

     

    The app calls the file when tested from the Flash IDE .. but not from the iPad.    Button Status msg says "button spam"

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 5:03 PM

    Guys. Just read the manual every once in a while. You can't access h264 encoded files or anything else for that matter other than ON2 VP6 codec, the first video that was available for flash. Legal restrictions. Didn't try any of your code, because i'm sure it's good, especially if it works on your machines, and not the iDevice. Again, legal restrictions. Try encoding to ON2 VP6 codec and you should be fine.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 7:25 PM

    Just tried encoding with the ON2 VP6 codec..  made an FLV ...  still no go.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 21, 2010 7:46 PM
    Guys. Just read the manual every once in a while. You can't access h264 encoded files or anything else for that matter other than ON2 VP6 codec, the first video that was available for flash. Legal restrictions. Didn't try any of your code, because i'm sure it's good, especially if it works on your machines, and not the iDevice. Again, legal restrictions. Try encoding to ON2 VP6 codec and you should be fine.

     

    Depends on what u trying to do...

     

    The topic was to access a local video in the native player (with navigateToURL), not inside the app iteself. And it works fine on the pc and the iPad.

     

    Devguide:

    Video


    Only Sorensen video and ON2 VP6 video are supported within an AIR application for the iPhone.


    You can use the navigateToURL() method to open an H.264 video outside the application. As the request
    parameter, pass a URLRequest object with a URL pointing to the video. The video launches in the video player of the
    iPhone.

     

    Greetings~

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 7:17 AM

    i tried encoding an FLV with ON2 VP6 with the Flash Encoder.. I used the oldest setting for Flash 8 or Higher.  When I call the video using navigateToURL it still will not load in the app.

     

    Has anyone successfully done this ?

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 7:39 AM

    @Applauz78:

     

    FLV videos with On2 VP6 codec will only play within the Flash application. You can't use navigateToUrl because the nativ app only supports h.264 videos.

     

    Playing Flash internal videos works with locally stored videos delivered within the application directory. Will say it's no problem to play them!

     

    But the internal video performance is really, really bad. I wouldn't use it. On my iPhone 2G even really small video's within a already shipped App from the App store doesn't work good.

     

    That's why it is so necessary to start the native video player for local videos with h.264 encoding.

     

    I really hope Adobe will leave a comment here.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 7:45 AM

    Can I use the Flash Video Component or I must create a custom player ?   The app I am workin on will be for iPad.

     

    I really liked the way opening an MP4 performs.  It was fast... great quality.  I just don't like the usability of exiting the app and making the user have to navigate back to the app.

     

    I also dont know  how to save the state of the application so when the user returns they dont have to start all over again

     


    So .. the playing of video within the app is very limited right now?   How about streaming MP3's within the app ?

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 7:21 PM

    I couldn't get the FLV playback components to work. I did manage to get it to work using video class, netstream and netconnect:

     

    Here is a sample code for both internal and external.

     

    import flash.net.NetStream;
    import flash.net.NetConnection;
    import flash.media.Video;

    stop();
    var vidDisplay:Video = new Video();
    vidDisplay.width = 320;
    vidDisplay.height = 240;
    addChild(vidDisplay);
    var nsStream:NetStream;
    var ncConnection:NetConnection = new NetConnection();

    ncConnection.connect(null);
    nsStream = new NetStream(ncConnection);

    nsStream.client = this;

    vidDisplay.attachNetStream(nsStream);

    load_btn.addEventListener(MouseEvent.CLICK, loadVideo);
    external_btn.addEventListener(MouseEvent.CLICK, externalVideo);

    function loadVideo(e:MouseEvent):void{
    nsStream.play("myvideo.flv");
    }
    function externalVideo(e:MouseEvent):void{
    var str:String = "http://your url.com/video/myvideo.mov";

    var urlReq:URLRequest = new URLRequest(str);

    navigateToURL(urlReq)
    }

     

    As mentioned above the internal video option is crap, playback is poor. (although it is a little better after it is viewed once)

     

     

    You'll note that the external video option launches it in the native player on the iphone but when you click done it doesn't return you to your app, you are stuck in safari and have to restart your app. This is a problem which I can't figure out. Using Xcode you can get it to return to the app using MPMoviePlayerPlaybackDidFinishNotification which is triggered when you hit done.

     

    If anyone has solved this please let me know!

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 8:12 PM

    Just a heads up.  I'm getting blazing fast results with netStream on the iPhone4.

     

    Does anyone know if you can limit your apps to only iPhone4  instead of making it available across the Touch, iPhone2G and 3GS ?

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 22, 2010 9:10 PM

    I've only tested on iphone 3, good to know 4 improves things. I don't know whether you can limit it to iphone4. I've seen warnings on the app store that certain apps only work with iphone 4 however.

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points