Best way to play a Video file?

2019-02-25 13:34发布

I have a URL for a video file which I need to play using the native Video-player of the handset.
I figured using Intent.ACTION_VIEW and setting the URI as Intent data, I am able to achieve the aforementioned on G1 except HTC hero. In case of Hero, I have to explicitly set the class Name in the Intent to start the default Video Player: intent.setClassName("com.htc.album","com.htc.album.ViewVideo");

However, I am not comfortable with this approach as it might break on other Android devices. Please advice on :
1. What would be the best way to play this video url via Intent, irrespective of the handset?
2. How to conditionally setClassName in Intent, specific to a Handset?

Note: Writing a standalone Video Player for our app is NOT an option we can afford at the moment.

Thanks!

1条回答
倾城 Initia
2楼-- · 2019-02-25 14:13

Note: Writing a standalone Video Player for our app is NOT an option we can afford at the moment.

First, the video player is not part of the SDK, and relying upon it is a big mistake, as you have already discovered.

Second, creating a simple video player takes about 40 lines of code, and you have already spent more time trying to avoid writing those 40 lines of code that it would have taken just to write the lines in the first place.

查看更多
登录 后发表回答