Get selected video in Youtube Intent or Youtube Player - android

Hey everyone, i would like to get the link of an selected video in an "Youtube Intent"
I've this actually ;
Intent intent = YouTubeIntents.createChannelIntent (SelectDocFragment.this.getActivity(), "PitbullVEVO");
startActivity(intent);
I would like an startActivityForResult, and the result should be "https://www.youtube.com/watch?v=ODh6hSZBJqY" which is the youtube that i selected in my YoutubeIntent.
i've tried to achieve this with an Youtube Player Api, and load my channel :
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.cuePlaylist("PLRX442jA-zGKxR-wAfC_xUvpZX1Rh0usm");
I'm able to get the current Video with :
public void onLoaded(String mVideoId) {
String url = "http://www.youtube.com/watch?v=" + mVideoId;
}
But, youTubePlayer.cuePlaylist or youTubePlayer.loadVideo are not able to load an channel where i could selected any videos.
Similarly to this topic : Is it possible to integrate youtube channel in android?
It is possible to get this with YoutubeIntent ?
EDIT :
I would like this in my android APP, and here i choose the video that i will display after, i just want the link of the video selected by the user.

As said Yupi : Get selected video in Youtube Intent or Youtube Player
We have to request the Youtube APi to get a JSON and then parse it.
To do this, i've found a very useful tutorial here :
https://www.codeproject.com/Articles/1214971/Youtube-channel-integration-in-Android-using
For anyone who want to do the same :)
Here is a demo :
https://www.youtube.com/watch?v=GJMdgwvrR_Y

Related

How to implement soundcloud share button

How can i implement share button of soundcloud which share a link of audio track and when user click on it open this track with soundcloud application.
I searched but i didn't find any thing all of them share audio or image or text or application, so any help of how can i do that.
Thanks in advance.
See this for adding sound from Soundcloud app.
See this for accessing Soundcloud to play song in Soundcloud
This code from enadun may help:
String id = "114143409"; //Track id
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("soundcloud://sounds:" + id));
startActivity(intent);

Display subtitle with Android Media Player?

I am using this snippet to open a video using default Android Video Player:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://my.video/link.mp4"), "video/mp4");
startActivity(intent);
Now I want to display subtitle on the video, my subtitle is provided with a url, example http://my.subtitle/link.srt. I think there would be something simple like this:
intent.putExtra("subtitle", "http://my.subtitle/link.srt");
But it doesn't seem to be simple like that.
Could anyone show me how to do it? Thanks a lot.

Android code to play youtube url repeatedly on button click

I am trying to play youtube url play n no of times on button click
I stumbled on the following code on the net:
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.youtube.com/watch?v=Ux_kvgL570A"));
startActivity(browserIntent);
but this code plays youtube url only once,how to modify this code if i want to
play youtube url multiple times
Currently, you're using a browser to display the video, but for it, you need use the Youtube API.
This thread: Youtube data API : Get access to media stream and play (JAVA) can explain you a little more about the youtube implementation on android using a media player.
But to repeat a video, you can add the follow lines:
videoView.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
And this is the reference for the YouTube API: https://developers.google.com/youtube/android/player/sample-applications

Open native video player (full screen) when video is pressed in a WebView

My app uses a WebView. I need to open a native video player any time a user clicks on a video. I see that sometimes in sites, if you click on a video thumb, it opens a dialog asking you how you want to open it (via web or a video player).
What can I do on the server side or my app so an intent like this will be sent after a click on a video?
Thanks!
The question got a little sideways at the end, but I'll respond to the base question.
1.) "I need to open a native video player any time a user clicks on a video"
Verify the link is a video, and fire an intent for ACTION_VIEW, Here's an example:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.endsWith(".mp4")) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
}
else
view.loadUrl(url);
return false;

how to embed Video from Live website in Android app

here is a link!
This link has Video and i want to display only video in my Android app. I think this website haven't provided any xml service so that we can use it, Is there any way to show only Video from this link to android app.
Thanks
hii ali you want to play video in your android app it can be do by two ways .
you can use your default youtube app to play the video or you can play it in your browser by following way.
if (isAppInstalled("com.google.android.youtube")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri
.parse("vnd.youtube://" + b.getString("video")));
startActivity(intent);
finish();
} else {
// Toast.makeText(this,
// "To view this Video you must install the youtube application in your device..",
// Toast.LENGTH_SHORT).show();
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://m.youtube.com/watch?v="
+ b.getString("video"))));
finish();
}
It worked for me
If it worked please vote

Categories

Resources