0

I'm trying to create and index page for locally hosted movies, with href links that would open directly in MXplayer Pro in android.

I ran into a problem that 2nd link works great, opens player/starts playing. But 1st link just opens Google Play for installation of the app. (this happens when intent url is broken)

So the funny part is that the only difference between the two links are the file paths. And there is no special character difference. Both files stream great on desktop player, also on android when I manually open then in MXplayer Pro.

So either my android devices (v4 and v10) don't like my taste in movies or someone did a very poor job at android.

    <li>  <a href="intent:http://192.168.0.64/media/So.You.Think.You.Can.Dance.S17E01.720p.WEB.h264-BAE[rarbg]/So.You.Think.You.Can.Dance.S17E01.720p.WEB.h264-BAE.mkv#Intent;package=com.mxtech.videoplayer.pro;end"> test1 </a> </li>

    <li>  <a href="intent:http://192.168.0.64/media/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG[TGx]/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG.mkv#Intent;package=com.mxtech.videoplayer.pro;end"> test2 </a> </li>

No JS please, just plain short html.

Vincent Alex
  • 324
  • 3
  • 12
  • Have you tried URL-encoding your `http` URL? Have you tried creating a scrap Android app that creates an `Intent` with your desired values, then [called `toUri()`](https://developer.android.com/reference/android/content/Intent#toUri(int)) on it to see what you get? Also, please bear in mind that there are dozens upon dozens of Web browsers available for Android, and how they parse this may vary. – CommonsWare Jun 17 '22 at 21:20
  • Based on answer below both urls are valid, (they also have the same characters)/same length, I tried 2 different browsers/2 android versions with same issue. So it points to an old OS bug. I don't know about app development. https://stackoverflow.com/questions/7109143/what-characters-are-valid-in-a-url#7109208 – Vincent Alex Jun 18 '22 at 13:05
  • "Based on answer below both urls are valid" -- quoting the answer that you linked to, "Also, some of these characters can only exist in very specific spots in a URI and outside of those spots must be url-encoded". And, if you read [the RFC that is linked to from that answer](https://www.ietf.org/rfc/rfc3986.txt), you will notice that `:` tends to have special rules. So, have you tried percent-encoding your `http` URL? – CommonsWare Jun 18 '22 at 13:28
  • Sure I gave it a go, but still opens gPlay. ``` test ``` – Vincent Alex Jun 18 '22 at 22:01

1 Answers1

0

It would appear that you cannot reliably use an http URL embedded in an intent: URL the way that you are.

In Kotlin, I assembled an Intent that would appear to match what you are looking for (using your first http URL):

val i = Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.64/media/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG[TGx]/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG.mkv"))

i.setPackage("com.mxtech.videoplayer.pro")

I then logged three different ways of creating a URL from that Intent:

Log.d("Foo", i.toUri(0))
Log.d("Foo", i.toUri(Intent.URI_INTENT_SCHEME))
Log.d("Foo", i.toUri(Intent.URI_ANDROID_APP_SCHEME))

toUri(0) says "give me as simple a URL as possible". toUri(Intent.URI_INTENT_SCHEME) says "always give the URL the intent: scheme". toUri(Intent.URI_ANDROID_APP_SCHEME) says "always give the URL the android-app: scheme", which is new to Android 5.1.

Those give me the following URLs:

http://192.168.0.64/media/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG[TGx]/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG.mkv#Intent;package=com.mxtech.videoplayer.pro;end
intent://192.168.0.64/media/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG[TGx]/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG.mkv#Intent;scheme=http;package=com.mxtech.videoplayer.pro;end
android-app://com.mxtech.videoplayer.pro/http/192.168.0.64/media/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG[TGx]/The.Humans.2021.720p.AMZN.WEBRip.800MB.x264-GalaxyRG.mkv

So, try those and see if have better luck (noting again that the third one may only work on Android 5.1 and higher).

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Cheers, 1st is exact same I'm using, 2nd has the same problem (opens gPlay), 3rd is working! but it opens with android player, not in mxplayer (which is default), and gives no option to use with other, only to download. (even though we specified mxplayer in uri), does the 3rd kind work for you? – Vincent Alex Jun 18 '22 at 21:55
  • @VincentAlex: " 1st is exact same I'm using" -- not according to your question. You are using `intent:http://192.168.0.64...`. That is not the same as `http://192.168.0.64...`, as yours has `intent:` in front of it. "does the 3rd kind work for you?" -- I do not use MX Player and I do not have a plain HTTP server running on a local IP address. I agree that the behavior you describe is strange, as that runs counter to [the documentation](https://developer.android.com/reference/android/content/Intent#URI_ANDROID_APP_SCHEME). – CommonsWare Jun 18 '22 at 22:00
  • Sorry, I meant 2nd is exact same. Well if it's an OS bug then it's next to impossible to get a fix for it:( – Vincent Alex Jun 18 '22 at 22:05
  • @VincentAlex: "I meant 2nd is exact same" -- not according to your question. You have `intent:http://192.168.0.64...`. That is not the same as `intent://192.168.0.64...`, as you have `http:` before the IP address. Also, the one from Android has `;scheme=http` as part of the final stanza, and yours does not. – CommonsWare Jun 18 '22 at 22:07
  • Oops, I missed that, tested with `;scheme=http` but same result. Somehow the file path upsets it, I will try to simplifying the name. – Vincent Alex Jun 18 '22 at 22:18