jackuess / pirateplayer

Qt-based utility for watching and downloading swedish broadcasting.
http://pirateplay.se/
GNU General Public License v3.0
42 stars 12 forks source link

Fall back on mimetype "video/*" if unknown #10

Closed Mhnix closed 11 years ago

Mhnix commented 11 years ago

By falling back to "video/*" on Android, the program should not try to open the stream using a browser as it does now (when the url does not start with "file:" ):

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "video/*");
QtActivity.getQtActivityInstance().startActivity(intent);
jackuess commented 11 years ago

On my phone the browser after opening the URL almost instantly gives me the choice of openening it with a video player. Is this not the case for you?

The custom java code you are reffering to isn't used for anything else than file: URLs right now. All videos not streamed over RTMP is opened with QDesktopServices::openUrl() for which there is no way of manually setting the mime type.

Setting the mime-type to "video/" seams pretty ugly to me. The nice thing about opening in the browser is that (at least on my phone) the browser reads the Content-Type header returned by the server and creates a proper intent according to that. What is to say tha all video players that accepts "video/" can actually handle say "application/vnd.apple.mpegurl"?

Mhnix commented 11 years ago

Hmm, I had not tried the native browser... Opera Mobile and Dolphin Browser only wants to download. The native browser however works as you describe.

jackuess commented 11 years ago

Ah ok, didn't think of other browsers. My solution might not be that good then after all. I might try to let Pirateplayer read the Content-Type header and start an intent accordingly.

Mhnix commented 11 years ago

I thought you already knew the mime type since you know the "suffix-hint" (at least the pirateplay API seems to know)?

jackuess commented 11 years ago

A mime type is not the same thing as a filename suffix. Sure you could hardcode it, ie. look for .m3u8 in the url and set mime type to application/vnd.apple.mpegurl but reading the Content-Type header - as I suspect the native browser does - seams like a cleaner and more universal solution.