Li Che
Li Che

Reputation: 737

How to call the system default player to play the video?

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?

Upvotes: 2

Views: 3976

Answers (4)

Jamil Hasnine Tamim
Jamil Hasnine Tamim

Reputation: 4448

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)

Upvotes: 2

Nargis
Nargis

Reputation: 4787

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

The above code should works for you to play video files

Upvotes: 0

LF-DevJourney
LF-DevJourney

Reputation: 28529

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);

Upvotes: 0

Nirav Ranpara
Nirav Ranpara

Reputation: 13785

Try This

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

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

startActivity(intent);

Upvotes: 4

Related Questions