Kodi Community Forum
External Player support fix (MX Player and others) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: Android Development (https://forum.kodi.tv/forumdisplay.php?fid=184)
+---- Thread: External Player support fix (MX Player and others) (/showthread.php?tid=175341)

Pages: 1 2 3 4


External Player support fix (MX Player and others) - wololo - 2013-10-09

I believe external player support is currently broken on Android (trying to play a video crashes xbmc and sends me back to the android home). As much as I'd love to use the internal player, even with libstagefright it doesn't work as well as I'd like for 1080p. I've also heard some chips will never really get libstagefright support, so for those external players are probably the best solution.

(I only tested my fix with MX Player, and I am not used to Android development, apologies if I am missing anything obvious)

First of all, the following patch by arikhalperin was enough to fix the URI issue (which was reported in the logs) and which is probably what broke most players in the first place. In other words, his patch might be enough to fix most external players, but not for MX Player (with his patch, MX Player runs but goes to its main menu). If any good soul wants to submit that, that would be great:
http://forum.xbmc.org/showthread.php?tid=171689

For MX Player, one of the issue is that somehow the intent created through
CJNIIntent newIntent = GetPackageManager().getLaunchIntentForPackage(package);
is not working correctly.

I didn't try to dig too deep into why, especially because I believe XBMCApp::StartActivity is used for more than external players and I didn't want to disrupt that.
Instead, I created a new function and followed the simple sample described on the mx player API:
https://sites.google.com/site/mxvpen/api

Code:
Intent intent = new Intent(Intent.ACTION_VIEW);

        Uri videoUri = Uri.parse("http://host:port/playlist.m3u8");

        intent.setDataAndType( videoUri, "application/x-mpegURL" );

        intent.setPackage( "com.mxtech.videoplayer.pro" );

        startActivity( intent );


Here is the resulting patch:
Code:
diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp
index 9f8e8c1..cbc21f1 100644
--- a/xbmc/android/activity/XBMCApp.cpp
+++ b/xbmc/android/activity/XBMCApp.cpp
@@ -408,7 +408,29 @@ bool CXBMCApp::StartActivity(const string &package, const string &intent, const
   if (!intent.empty())
     newIntent.setAction(intent);

-   startActivity(newIntent);
+  startActivity(newIntent);
+  return true;
+}
+
+// Note intent, dataType, dataURI all default to ""
+bool CXBMCApp::StartExternalPlayerActivity(const string &package, const string &intent, const string &dataType, const string &dataURI)
+{
+  if (intent.empty())
+    return false;
+
+  CJNIIntent newIntent(intent);
+  if (!newIntent)
+    return false;
+
+  if (!dataURI.empty())
+  {
+    CJNIURI jniURI = CJNIURI::parse(dataURI);
+    newIntent.setDataAndType(jniURI, dataType);
+  }
+
+  newIntent.setPackage(package);
+
+  startActivity(newIntent);
   return true;
}

diff --git a/xbmc/android/activity/XBMCApp.h b/xbmc/android/activity/XBMCApp.h
index 7f23a67..d21cdca 100644
--- a/xbmc/android/activity/XBMCApp.h
+++ b/xbmc/android/activity/XBMCApp.h
@@ -85,6 +85,7 @@ public:
  
   static int GetBatteryLevel();
   static bool StartActivity(const std::string &package, const std::string &intent = std::string(), const std::string &dataType = std::string(), const std::string &dataURI = std::string());
+  static bool StartExternalPlayerActivity(const std::string &package, const std::string &intent = std::string(), const std::string &dataType = std::string(), const std::string &dataURI = std::string());
   static bool ListApplications(std::vector <androidPackage> *applications);
   static bool GetIconSize(const std::string &packageName, int *width, int *height);
   static bool GetIcon(const std::string &packageName, void* buffer, unsigned int bufSize);
diff --git a/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp b/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
index a094536..8b3f6be 100644
--- a/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
+++ b/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
@@ -484,7 +484,7 @@ BOOL CExternalPlayer::ExecuteAppAndroid(const char* strSwitches,const char* strP
{
   CLog::Log(LOGNOTICE, "%s: %s", __FUNCTION__, strSwitches);

-  int ret = CXBMCApp::StartActivity(strSwitches, "android.intent.action.VIEW", "video/*", strPath);
+  int ret = CXBMCApp::StartExternalPlayerActivity(strSwitches, "android.intent.action.VIEW", "video/*", strPath);

   if (ret != 0)
   {

I have never used git before and I am in the process of learning how to fork and submit a pull request.
Again, this has only been tested with MX Player.

[Edit] binaries for those interested: http://wololo.net/downloads/index.php/download/7975


RE: External Player support fix (MX Player and others) - wololo - 2013-10-09

Here is the pull request:
https://github.com/xbmc/xbmc/pull/3406


RE: External Player support fix (MX Player and others) - wololo - 2013-10-09

Added binaries link to the initial post.


RE: External Player support fix (MX Player and others) - Swifty - 2013-10-10

Thank you so much for this, I've been stuck without proper decoding via libstagefright as I have an RK3066 stuck on ICS (so broken libstagefright library)

Will definately be testing this out tonight Smile


RE: External Player support fix (MX Player and others) - wololo - 2013-10-10

Awesome. Crossing fingers as I have only tested my build on RK3188 so far, but I'll also try on RK3066 (mk802 III) one of these days. Please let me know how it goes Smile

Edit: I had time to test my binary on an mk802 III today (running on RK3066) and it works fine Smile


RE: - buhohitr - 2013-10-13

Hi, I downloaded the apk and tried to install but failed with error "the same package name already installed but with different signature", can you tell me how to fix this??can it be manually install? Thanks.
EDIT: I got it figured out and working fine with external player. Good job! Thanks


RE: External Player support fix (MX Player and others) - wololo - 2013-10-13

(2013-10-13, 05:31)buhohitr Wrote: Hi, I downloaded the apk and tried to install but failed with error "the same package name already installed but with different signature", can you tell me how to fix this??can it be manually install? Thanks.

You need to uninstall your previous version of xbmc first.


RE: External Player support fix (MX Player and others) - attobytes - 2013-10-13

Installed this but unable to choose a player, when i select a movie it just starts playing with the built in xbmc player.


RE: External Player support fix (MX Player and others) - wololo - 2013-10-14

(2013-10-13, 19:47)attobytes Wrote: Installed this but unable to choose a player, when i select a movie it just starts playing with the built in xbmc player.

Hmm, yeah, you need to create a playercorefactory.xml file, following the explanations on the wiki: http://wiki.xbmc.org/index.php?title=HOW-TO:Use_external_players_on_Android
Since this is the development subforum I didn't think it was necessary to explain that much, sorry for that. But here's a detailed process:

1 - If you have a previous xbmc install, uninstall it. My build will not install over the official XBMC because it has a debug certificate. Be sure to backup your database!

2 - If you don't have it yet, download MX Player (free, ad supported) from the play store, and run it at least once

3 - Download my xbmc build, install it, and run it once to build the initial files and folder structure

4 - create your playercorefactory.xml file and copy it to /sdcard/Android/data/org.xbmc.xbmc/files/.xbmc/userdata on your device (you can do this with a tool such as ES Explorer. Be sure to select "show hidden files" in your explorer's options, or you will not see the .xbmc folder). A playercorefactory.xml file set up for MX Player can be found here. This is the one I use

5 - Done, next time you run xbmc and start a movie, it should start the movie in mx player.


RE: External Player support fix (MX Player and others) - User 184124 - 2013-10-14

Thanks for this, it works great on my Pipo Max M9 (RK3188) !


RE: External Player support fix (MX Player and others) - attobytes - 2013-10-14

(2013-10-14, 02:16)wololo Wrote:
(2013-10-13, 19:47)attobytes Wrote: Installed this but unable to choose a player, when i select a movie it just starts playing with the built in xbmc player.

Hmm, yeah, you need to create a playercorefactory.xml file, following the explanations on the wiki: http://wiki.xbmc.org/index.php?title=HOW-TO:Use_external_players_on_Android
Since this is the development subforum I didn't think it was necessary to explain that much, sorry for that. But here's a detailed process:

1 - If you have a previous xbmc install, uninstall it. My build will not install over the official XBMC because it has a debug certificate. Be sure to backup your database!

2 - If you don't have it yet, download MX Player (free, ad supported) from the play store, and run it at least once

3 - Download my xbmc build, install it, and run it once to build the initial files and folder structure

4 - create your playercorefactory.xml file and copy it to /sdcard/Android/data/org.xbmc.xbmc/files/.xbmc/userdata on your device (you can do this with a tool such as ES Explorer. Be sure to select "show hidden files" in your explorer's options, or you will not see the .xbmc folder). A playercorefactory.xml file set up for MX Player can be found here. This is the one I use

5 - Done, next time you run xbmc and start a movie, it should start the movie in mx player.

Followed these steps but it's sadly not working for me Sad Movies will just start up with the built in player.


RE: External Player support fix (MX Player and others) - wololo - 2013-10-16

@attobytes : try this first with the official XBMC. When you reach the point where xbmc crashes trying to run the movie, you've got it right. At this point I believe the problem is on your end, not in my patch, but put my patch out of the picture in order to debug your issue, then come back


RE: External Player support fix (MX Player and others) - freakoutguy - 2013-10-25

Hello Wololo

I too have the External media player active issue with some live streams. I currently have the MK808b stick with Finless 1.7 ROM and running XAF build of XBMC. I have the MX media player installed, which is my default player. Yet, I keep on having issues with some streams.

My question is -

Do I have to uninstall my XAF build and install your custom XBMC build (as outlined) and follow all tyhe outlined steps for this to work, or can I just create the playercorefactory file as recommeded by you and edit ?


RE: External Player support fix (MX Player and others) - GatShorty - 2013-10-27

Hi wololo,

i have tried your xbmc Version and it works very nice. Thank you.

Is it possible to apply your patch to any xbmc Version. I had decompiled my favoured xbmc apk. Can i just edit some files with your patch or what can i do to get my version work with external player. I need my version because i need DTS pathtrough in XBMC and only for fev files i need MX Player

Greetz


RE: External Player support fix (MX Player and others) - Romout - 2013-11-01

Hi wololo,

This is my first post on this forum. I have tried your patch build binaries with an Amerry Android Stick (V2). I have taken your playercorefactory.xml and wanted to stream files from my NAS using Samba. As XBMC always used the internal player, I figured out that your xml does mention known problems of MXPlayer concerning Samba and therefore routing SMB to DVDPlayer. I changed that to the MXPlayer but that instantly dropped me back to the desktop when ever I wanted to start a movie. I then switched to VLCPlayer with the same outcome.

Now here comes the interesting part: I added a player configuration for the android gallery with exactly the same behavior (drop back to desktop) but I would have expected that to work as it actually does work using ES Explorer + Network/Samba connection to my NAS. I have chosen the gallery to view the very same movie and it did run like a charm.

Do you have any further ideas on how I could overcome that issue?

Thanks in advance for your time and aforts,
Romout