2

I am developing an application. I want to realize a function like that I want to call the system default player.

After downloading the custom Audio or video file. Could it play using the system audio and video player in the program?

I want to create intent, and give the file path. Then call the system’s player.

any idears?

2
  • Do you want explicitly only the system player, or do you want any player capable of playing the file? Or you want to play it in your Activity (and therefore not using an Intent?)
    – RvdK
    Commented Dec 5, 2012 at 8:23
  • davanum.wordpress.com/2007/12/29/… Commented Dec 5, 2012 at 8:23

4 Answers 4

4

Try This

videourl="/sdcard/zzzz.3gp";

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(videourl)); 

startActivity(intent);
2

For kotlin:

val path: String = contentUri.getPath()
val file = File(path)
val intent = Intent(
Intent.ACTION_VIEW,Uri.fromFile(file))
intent.setDataAndType(Uri.parse(path), "video/*")
startActivity(intent)
0
String video = "http://www.nandudu.com/hls/course/video/2/test.m3u8";  

Intent openVideo = new Intent(Intent.ACTION_VIEW);  

openVideo.setDataAndType(Uri.parse(video), "video/*");  

startActivity(openVideo);
0
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(videourl));
startActivity(intent);

The above code should works for you to play video files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.