Add option to play vimeo URLs on Kodi
This commit is contained in:
parent
eca7d2b2ad
commit
9bec745dac
|
@ -40,8 +40,9 @@
|
||||||
<data android:scheme="http" android:host="youtube.com"/>
|
<data android:scheme="http" android:host="youtube.com"/>
|
||||||
<data android:scheme="http" android:host="m.youtube.com"/>
|
<data android:scheme="http" android:host="m.youtube.com"/>
|
||||||
<data android:scheme="http" android:host="www.youtube.com"/>
|
<data android:scheme="http" android:host="www.youtube.com"/>
|
||||||
|
<data android:scheme="http" android:host="vimeo.com"/>
|
||||||
|
<data android:scheme="http" android:host="www.vimeo.com"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="org.xbmc.kore.ui.hosts.HostManagerActivity"/>
|
<activity android:name="org.xbmc.kore.ui.hosts.HostManagerActivity"/>
|
||||||
|
|
|
@ -361,22 +361,22 @@ public class RemoteActivity extends BaseActivity
|
||||||
!(action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_VIEW)))
|
!(action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_VIEW)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Uri youTubeUri = null;
|
Uri videoUri = null;
|
||||||
if (action.equals(Intent.ACTION_SEND)) {
|
if (action.equals(Intent.ACTION_SEND)) {
|
||||||
// Get the URI, which is stored in Extras
|
// Get the URI, which is stored in Extras
|
||||||
youTubeUri = getYouTubeUri(intent.getStringExtra(Intent.EXTRA_TEXT));
|
videoUri = getYouTubeUri(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||||
if (youTubeUri == null) return;
|
if (videoUri == null) return;
|
||||||
} else if (action.equals(Intent.ACTION_VIEW)) {
|
} else if (action.equals(Intent.ACTION_VIEW)) {
|
||||||
if (intent.getData() == null) return;
|
if (intent.getData() == null) return;
|
||||||
youTubeUri = Uri.parse(intent.getData().toString());
|
videoUri = Uri.parse(intent.getData().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
final String videoId = getYouTubeVideoId(youTubeUri);
|
final String videoId = getVideoId(videoUri);
|
||||||
if (videoId == null) return;
|
if (videoId == null) return;
|
||||||
|
|
||||||
// final String kodiAddonUrl = "plugin://plugin.video.youtube/?path=/root/search&action=play_video&videoid="
|
final String kodiAddonUrl = "plugin://plugin.video." +
|
||||||
// + videoId;
|
(videoUri.getHost().endsWith("vimeo.com") ? "vimeo" : "youtube") +
|
||||||
final String kodiAddonUrl = "plugin://plugin.video.youtube/play/?video_id=" + videoId;
|
"/play/?video_id=" + videoId;
|
||||||
|
|
||||||
// Check if any video player is active and clear the playlist before queuing if so
|
// Check if any video player is active and clear the playlist before queuing if so
|
||||||
final HostConnection connection = hostManager.getConnection();
|
final HostConnection connection = hostManager.getConnection();
|
||||||
|
@ -516,19 +516,17 @@ public class RemoteActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the youtube video ID from its URL
|
* Returns the youtube/vimeo video ID from its URL
|
||||||
*
|
*
|
||||||
* @param playuri Youtube URL
|
* @param playuri Youtube/Vimeo URL
|
||||||
* @return Youtube Video ID
|
* @return Youtube/Vimeo Video ID
|
||||||
*/
|
*/
|
||||||
private String getYouTubeVideoId(Uri playuri) {
|
private String getVideoId(Uri playuri) {
|
||||||
if (playuri.getHost().endsWith("youtube.com") || playuri.getHost().endsWith("youtu.be")) {
|
if (playuri.getHost().endsWith("youtube.com") || playuri.getHost().endsWith("youtu.be") || playuri.getHost().endsWith("vimeo.com")) {
|
||||||
// We'll need to get the v= parameter from the URL
|
// We'll need to get the v= parameter from the URL
|
||||||
final Pattern pattern =
|
final Pattern pattern =
|
||||||
Pattern.compile("(?:https?:\\/\\/)?(?:www\\.|m\\.)?youtu(?:.be\\/|be\\.com\\/watch\\?v=)([\\w-]+)",
|
Pattern.compile("(?:https?:\\/\\/)?(?:www\\.|m\\.)?(?:youtu(?:\\.be\\/|be\\.com\\/watch\\?v=)|vimeo\\.com\\/)([\\w-]+)",
|
||||||
Pattern.CASE_INSENSITIVE);
|
Pattern.CASE_INSENSITIVE);
|
||||||
// final Pattern pattern = Pattern.compile("^http(:?s)?:\\/\\/(?:www\\.)?(?:youtube\\.com|youtu\\.be)\\/watch\\?(?=.*v=([\\w-]+))(?:\\S+)?$", Pattern.CASE_INSENSITIVE);
|
|
||||||
// final Pattern pattern = Pattern.compile(".*v=([a-z0-9_\\-]+)(?:&.)*", Pattern.CASE_INSENSITIVE);
|
|
||||||
final Matcher matcher = pattern.matcher(playuri.toString());
|
final Matcher matcher = pattern.matcher(playuri.toString());
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
return matcher.group(1);
|
return matcher.group(1);
|
||||||
|
|
Loading…
Reference in New Issue