Android: Youtube Search Application for given Word - android

I want to create a android search application that can be used to search a video from youtube for given word.
how do I do that. please someone give me a tutorial link. Thanks

Please try the below code .
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setPackage("com.google.android.youtube");
intent.putExtra("query", "Android");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

use this API for Searching a Video on Youtube
https://gdata.youtube.com/feeds/api/videos?q=india
where q is word you want to search related videos
for more detail see YouTube APIs

Related

Android intent for display url?

for some time, I have been observing that modern android apps(Telegram) use a new way to open urls in the app. By default, the apps I have made, use ACTION_VIEW and the external browser open the url. These apps now manage that intent with a kind of in-app browser witch adapts to the same style. Any idea of what its?
sample
Those are Custom chrome tabs.In app browser.instead of using webview to open your Url, you are going to customize your chrome browser,to look alike your app.you can modify the toolbar tab color as per your app theme .You could give enter and exit animation like fragments transition.So the user wouldn't feel a big transition from your app to browser.For implementation details check this link https://developer.chrome.com/multidevice/android/customtabs
For security reasons also it could be useful,as because you are not going handle those url on you own or inside your app(there might be some security issues with JavaScript)
This is done with WebView. You will find the documentation very interesting https://developer.android.com/reference/android/webkit/WebView
This is achieved by WebView in an Activity that displays web pages. Instead of
Uri uri = Uri.parse("https://www.google.com/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
You will load the page by calling:
webviewObj.loadUrl("https://www.google.com/");
You can check the official document which describes the whole process. Basic Usage of WebView has been described in this blog which is easy to comprehend and implement.
do the following:
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
try this it helps you.

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);

Populate Google Play Music Searchbar with String passed from intent

I am having trouble inserting a passed String from an intent into the google music app's searchbar.
The following code allows me to open up Google Play Music from my app, but leaves the searchbar empty. Would anyone know how to populate Google Play Music's searchbar with my passed in String? any help would be greatly appreciated.
Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.google.android.music");
intent.putExtra(song ,"song to be inserted in google play searchbar");
startActivity(intent);
I have figured it out thanks to the following documentation
In this example, i am opening up the google play store then entering search?q=drake&c=music")); as part of the URI to go to the music tab and search for drake
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("http://play.google.com/store/search?q=drake&c=music"));
startActivity(i);

How to automatically play Playlist in Spotify Android app

I'm trying to play a known playlist in the Spotify app. The best I've got is to load the playlist, but not play it.
Two things I've tried. Firstly to play from search:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.music",
"com.spotify.music.MainActivity"));
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE);
intent.putExtra(MediaStore.EXTRA_MEDIA_PLAYLIST, <PLAYLIST>);
intent.putExtra(SearchManager.QUERY, <PLAYLIST>);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I've tried replacing PLAYLIST with the name of a known playlist. Also tried things like "4Rj0zQ0Ux47upeqVSIuBx9", "spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9" etc. All these do is a failed search for these strings.
Second attempt is the View intent:
String uri = "https://play.spotify.com/user/11158272501/playlist/4Rj0zQ0Ux47upeqVSIuBx9";
Intent intent= new Intent( Intent.ACTION_VIEW, Uri.parse(uri) );
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
This loads the playlist, but does not play. If I then use one of the many ways to send a KEYCODE_MEDIA_PLAY key, it just resumes the currently playing list, not this newly loaded list.
Any help from anyone (including Spotify devs)?
BTW I don't want to use the Spotify SDK to implement my own Spotify Player - it seems a shame to have to do this when a perfectly good player is already installed on a user's device.
I found the answer from this blog. What I was missing was the playlist URI as a data Uri in the intent. So not using the proper Android way of Play from search.
So, using the first method from the question, you end up with this:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setData(Uri.parse(
"spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
3 things to note:
the Uri can't be the https://play.spotify... but has to be the colon seperated type.
the Spotify account must be premium, otherwise the playlist opens but does not play.
this does not work if the screen is off, or lock screen is showing. The spotify activity needs to display on the screen before it loads and plays!
This final point means it isn't actually usable for me... so not accepting answer yet.
Just add :play to Spotify Intent URI
spotify:album:3avifwTCXoRzRxxGM1O0eN:play

How to play YouTube video via Intent?

In my app I want to click on a particular button and jump to the youtube app and show a youtube user .Eg http://www.youtube.com/user/punjabiradiousa . How is this possible please suggest some technique?
Do it like this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/user/punjabiradiousa")));
Taken from here: Android YouTube app Play Video Intent
This code i have used to play youtube video
Matcher matcher = Pattern.compile("http://www.youtube.com/embed/").matcher(mVideoId);
matcher.find()
Intent lVideoIntent = new Intent(
null,
Uri.parse("ytv://" + mVideoId),
MainScreen.mContext,
com.kids.youtube.OpenYouTubePlayerActivity.class);
startActivity(lVideoIntent);
Its Working
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("")));

Categories

Resources