Add option to play youtube URLs on Kodi

This commit is contained in:
Synced Synapse 2015-04-18 18:23:31 +01:00
parent 7d19a43b61
commit a70f766442
2 changed files with 24 additions and 4 deletions

View File

@ -29,6 +29,16 @@
<data android:mimeType="text/plain"/>
</intent-filter>
<!-- Intent filter for sharing youtube URLs -->
<intent-filter android:label="@string/play_on_kodi">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="youtube.com"/>
<data android:scheme="http" android:host="m.youtube.com"/>
<data android:scheme="http" android:host="www.youtube.com"/>
</intent-filter>
</activity>
<activity android:name="org.xbmc.kore.ui.hosts.HostManagerActivity"/>

View File

@ -321,12 +321,22 @@ public class RemoteActivity extends BaseActivity
*/
private void handleStartIntent(Intent intent) {
final String action = intent.getAction();
LogUtils.LOGD(TAG, "Action: " + action);
LogUtils.LOGD(TAG, "Data: " + intent.getData());
// Check action
if ((action == null) || !action.equals(Intent.ACTION_SEND)) return;
if ((action == null) ||
!(action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_VIEW)))
return;
// Get the URI, which is stored in Extras
final Uri youTubeUri = getYouTubeUri(intent.getStringExtra(Intent.EXTRA_TEXT));
if (youTubeUri == null) return;
Uri youTubeUri = null;
if (action.equals(Intent.ACTION_SEND)) {
// Get the URI, which is stored in Extras
youTubeUri = getYouTubeUri(intent.getStringExtra(Intent.EXTRA_TEXT));
if (youTubeUri == null) return;
} else if (action.equals(Intent.ACTION_VIEW)) {
if (intent.getData() == null) return;
youTubeUri = Uri.parse(intent.getData().toString());
}
final String videoId = getYouTubeVideoId(youTubeUri);
if (videoId == null) return;