2013-10-09, 15:21
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
Here is the resulting patch:
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
(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