0

I'm new to OSMF. For now, I'm trying to use it in an existing Flex project targetting AIR on desktop (this project was using the spark video player until now).

I've taken this example: http://jodieorourke.com/view.php?id=150&blog=news

However, when I try to load a video file using a local path, it doesn't work.

If I use flash.filesystem.File.resolvePath() and then get a "app:/(...)" path, it crashes at runtime on the below line, probably because the "mediaFactory.createMediaElement()" method could not understand this path:

    protected function playMedia():void
    {
        if( _mediaPlayer )
        {
            if( _element )
            {
                if( _container.containsMediaElement( _element ) )
                {
                    _container.removeMediaElement( _element );
                }
            }
            _element = _mediaFactory.createMediaElement( new URLResource( _source ) );
            _mediaPlayer.media = _element;
            _container.addMediaElement( _element ); // crash on this line
        }
    }

If I try to use an absolute path like 'file:///c:/blablabla/bla/bla.flv', I get a white screen and the following trace:

*** Security Sandbox Violation ***
Connection to 'file:///c:/blablabla/bla/bla.flv halted - not permitted from app:/blabla.swf

So, I'm wondering: is that possible to use OSMF to load and play local video files?

If yes, what did I do wrong?

Żabojad
  • 2,946
  • 2
  • 32
  • 39

1 Answers1

0

Oups, actually, it seems that the following works:

var myFilePath:String = File.applicationDirectory.nativePath + "/" + myFileName;
mediaFactory.createMediaElement( new URLResource( myFilePath ));

So OSMF is able to read local files ^^!

Żabojad
  • 2,946
  • 2
  • 32
  • 39