Android intent for playing video?


I'm trying to play video's on Android, by launching an intent. The code I'm using is:

tostart = new Intent(Intent.ACTION_VIEW);
tostart.setDataAndType(Uri.parse(movieurl), "video/*");

This works on most phones, but not on the HTC Hero. It seems to load a bit different video player. This does play the first video thrown at it. However, every video after that it doesn't respond. (it keeps in some loop).

If I add an explicit


(before the startactivity) it does work on the HTC Hero. However, since this is a HTC specific call, I can't run this code on other phones (such as the G1). On the G1, this works:

tostart.setClassName("",""); //g1 version

But this intent is missing from the hero. Does anybody know a list of intents/classnames that should be supported by all Android devices? Or a specific one to launch a video? Thanks!

7/5/2015 5:09:30 AM

Use setDataAndType on the Intent

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(newVideoPath));
intent.setDataAndType(Uri.parse(newVideoPath), "video/mp4");

Use "video/mp4" as MIME or use "video/*" if you don't know the type.

1/7/2013 10:41:18 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow