External Player support fix (MX Player and others)
#1
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
Reply
#2
Here is the pull request:
https://github.com/xbmc/xbmc/pull/3406
Reply
#3
Added binaries link to the initial post.
Reply
#4
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
Reply
#5
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
Reply
#6
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
Reply
#7
(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.
Reply
#8
Installed this but unable to choose a player, when i select a movie it just starts playing with the built in xbmc player.
Reply
#9
(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...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.
Reply
#10
Thanks for this, it works great on my Pipo Max M9 (RK3188) !
Reply
#11
(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...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.
Reply
#12
@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
Reply
#13
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 ?
Reply
#14
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
Reply
#15
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
Reply

Logout Mark Read Team Forum Stats Members Help
External Player support fix (MX Player and others)1