On Saturday, February 4, 2012 12:46:16 AM UTC+1, droid-stricken wrote:
>
> Hi All, 
>
> I had posted this question yesterday on the stackoverflow. But no one 
> seems to know the answer or have the time to make to share their 
> thoughts. 
>
> http://stackoverflow.com/q/9124314/693959 
>
> Is it possible to play a media file in the application's assets or res/ 
> raw folder in another app like GALLERY or some other external media 
> player? 
> I am aware of the content-provider and content-resolver classes. But i 
> have seen it being used only for sharing the application's database 
> with other apps. Even if i created a content-provider for this video 
> file, i am not sure how to consume it i.e be able to launch an intent 
> and provide the video file as data to the 3rd party app. 
>
> Any inputs is highly appreciated. 
>
> Thanks.


create a ContentProvider (in my case VideoProvider) and override 
openAssetFile like this:
@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws 
FileNotFoundException {
Log,d(TAG, "uri: " + uri.getPath());
AssetFileDescriptor fd = null;
try {
fd = getContext().getAssets().openFd(uri.getPath().substring(1));
} catch (IOException e) {
e.printStackTrace();
}
return fd;
}

in AndroidManifest add:

<provider android:name=".VideoProvider" 
android:authorities="your.package..videoprovider"></provider>

if you want external app to access it i think you could do it be creating 
an Intent like this:

Uri movieUri = Uri.parse("content://your.package.videoprovider/movie.mp4")
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(movieUrl, "video/*");
startActivity(intent);

where movie.mp4 sits in assets/movie.mp4

pskink 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to