You are correct that your path is incorrect. Basically, File.nativePath
and File.url
will both give you a URL that uses app://
or app-storage://
(or any number of others), both relative to the app itself. When you try to open that link in a browser or in StageWebView
or in StageVideo
, the link becomes relative to the browser/video player, rather than your app. That is why you cannot link to the files properly.
There is a simple fix, thankfully. I found this (which may be considered a "hack", but it works) in an Adobe Forums post a long time ago. I wish I had a source, but I don't:
trace( new File( file.nativePath ).url );
Try that. It basically creates a new File using the actual native path of the file. The URL of this file is the full path to the file, rather than being relative to the app in any way. As mentioned by Brian, you may end up needing to use StageWebView
instead, but this will give you the proper pathing.
As a quick note, this does not work on Android if I remember correctly. On Android, you want to use either nativePath
or url
directly. But this little workaround will work on iOS (An app I currently have in the app store is using it without issue)