how to embed Video from Live website in Android app - android

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

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

Launching Android Netflix App And Passing Video Id

In the app I am working on I want to support Netfilx streaming. I intend on doing this by simply starting Netflix and passing a specific URI so it plays a specific video when started. Simple right? Well, the issue is I'm not sure how to pass the video id info in the Intent I use to start the Activity.
I've read the post here , but am unsure where to use this. I used Intent.setData() since it accepts a URI, but to no avail.
Here is what I have been doing (I am hard coding the movie data, this is just for testing purposes) :
// the Netflix intent
Intent intent = getPackageManager().getLaunchIntentForPackage("com.netflix.mediaclient");
//the uri
Uri uri = Uri.parse("http://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
intent.setData(uri);
//launches but does not go to the video
startActivity(intent);
I've also tried using the URI protocol in the link above like so:
Uri uri = Uri.parse("nflx://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
but still am not seeing the video play.
I feel like I am missing something simple here, although I have had very little luck Googling for this, I could find next to nothing about starting the Netflix Android app from another application. The Netflix developer resources don't have any info on this.
Does anyone have any suggestions on how I can do this or where I should be looking for documentation on this? Any help would be appreciated. Thanks much!
Just some Android Apps intent names to help anyone.
Format: appName, packageName, className
Skype: com.skype.raider, com.skype.raider.Main
Netflix: com.netflix.mediaclient, com.netflix.mediaclient.ui.launch.UIWebViewActivity
ESexplorer: com.estrongs.android.pop, com.estrongs.android.pop.view.FileExplorerActivity
Youtube: com.google.android.youtube,com.google.android.youtube.HomeActivity
Chrome: com.android.chrome,com.google.android.apps.chrome.Main
VLC: org.videolan.vlc, org.videolan.vlc.gui.MainActivity
MBOXSettings: com.mbx.settingsmbox, com.mbx.settingsmbox.SettingsMboxActivity
I've managed to do this. With the following code. First you need the movieId (or videoId) for netflix, then compose the URL to watch.
String netFlixId = "43598743"; // <== isn't a real movie id
String watchUrl = "http://www.netflix.com/watch/"+netFlixId;
Then with this intent
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.launch.UIWebViewActivity");
intent.setData(Uri.parse(watchUrl));
startActivity(intent);
}
catch(Exception e)
{
// netflix app isn't installed, send to website.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(item.url));
startActivity(intent);
}
I haven't tried with TV Shows yet. But this works beautifully. If you want to send to the profile page of the movie.. Send it to a url formatted this way
http://www.netflix.com/title/324982
I also found out how to search for a title.
try {
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.search.SearchActivity");
intent.putExtra("query", item.label);
startActivity(intent);
}
catch(Exception e)
{
Toast.makeText(this, "Please install the NetFlix App!", Toast.LENGTH_SHORT).show();
}
Here is how to start a movie from an ADB command for com.netflix.mediaclient
adb shell am start -n com.netflix.mediaclient/.ui.launch.UIWebViewActivity -a android.intent.action.VIEW -d http://www.netflix.com/watch/60000724
I still can't find a way to do it for com.netflix.ninja (Netflix for Android TV)

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

Play youtube video from URL in android

I want to play youtube video in my application. I am getting video URL from SAX Parsing. My question is how to play video from URL in VideoView, not in Webview or Browser.
I tried this code :
Intent lVideoIntent = new Intent(null, Uri.parse("VIDEO URL"));
startActivity(lVideoIntent);
It is displaying one popup screen with 'Internet' and 'YouTube' options. I want to play the video directly in youtube.
Please let me know your thoughts. Any code or any example is highly appreciated.
you can try below code for direct play in Youtube application.
Intent videoClient = new Intent(Intent.ACTION_VIEW);
videoClient.setData(Uri.parse("https://www.youtube.com/watch?v=EwSdmxyayx0&feature=youtube_gdata"));//you can try here your own video url
videoClient.setClassName("com.google.android.youtube", "com.google.android.youtube.PlayerActivity");
try{
startActivity(videoClient);
}catch(ActivityNotFoundException excp){
try{
videoClient.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoClient);
}catch(ActivityNotFoundException exc){
exc.printStackTrace();
}
}
String videoUrl = "http://www.youtube.com/watch?v=cxLG2wtE7TM"
//split video url and get value of v ie cxLG2wtE7TM
String videoId = "cxLG2wtE7TM";
String action = Intent.ACTION_VIEW;
Uri uri = Uri.parse("vnd.youtube:" + videoId);
Intent videoIntent = new Intent(action, uri);
startActivity(videoIntent);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("video url"));
VideoActivity.this.startActivity(i);
It is displaying one popup screen with 'Internet' and 'YouTube'
because the ACTION_VIEW intent is written both in default browser and Youtube application. that's why whenever it catches the URL the Browser opens and whenever the Youtube URL is opened Both the browser and Youtube app.
I want to play the video directly in youtube
Take the embed link of Youtube video and set intent it will play the video.
ex:-http://www.youtube.com/embed/srMFb6zpx2Y

Calling YouTube app using ACTION_VIEW intent Failing most of the time

I've written a small app to parse some RSS feeds from YouTube and launch videos selected by the user. To play the video, I'm using an intent:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(videoAddress);
In order to call the YouTube app, if installed on the device.
The problem I'm having is that, of the population of videos I am using in my app, about 90% of them display a 'Cannot play video' error message: "Sorry, this video cannot be played.". A few of them work just fine from my app. The videos that do not work will play fine in the YouTube app if searched for and launched entirely from within the YouTube app.
Has anybody seen this behavior, or does anybody have any ideas for things to try? Obviously the YouTube app launches videos in a slightly different way internally than it does from an Intent request, but I haven't a clue how to get to the bottom of it.
I have the same issue. Are you sure that all of the video play correctly from the youtube app? In my case, on an old G1, the videos I can't play from my app won't play even if searched from within the youtube app.
I think the video encoding is not supported in some case and/or the combination of a slow cpu and slow network make the video not playable.
I've read about people just refreshing many times untill the video starts playing... I guess in thier care it was a network/buffering issue.
More discussion here:
http://www.google.com.tw/support/forum/p/android/thread?tid=3a62cdf7188384af&hl=en
For this reason my App (similar to yours) got a lot of bed comments. I republished it only for Android >=2.1 and I now I have fewer bad feedback.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(YOUTUBE_URL)));
The above line of code works for my App.
What it basically does is lets Android handle the startActivity with available installed software on the device. Android in turn opens the IntentChooser and lets the user decide which appropriate software to use in this case a Browser and Youtube App to open the video.
Try it out and let me knwo if it works for you or f you have any other issues.
The most reliable method I have found for accessing youtube from an application is using the mobile site, try this instead (eg for searching):
String videoUrl = "http://m.youtube.com/#/results?q=ciaconna+bach";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoUrl)));
This solved the "Cannot play video' error message" that I was receiving.
I use this code:
String vid= Uri.parse(urlVideo).getQueryParameter("v");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + vid));
try{
startActivity(intent);
}
catch (ActivityNotFoundException ex){
Log.e(TAG, "Couldn't find activity to view this video");
}
May be works for you.
I have got the same problem only with HTC Hero 2.1. You can force the intent to launch the htc flash player instead of the Youtube app. With the flash player app I have not had any problem:
Uri uri = Uri.parse("vnd.youtube:" + videoUrl);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
String availableFlashPlayer = availableFlashPlayer();
if (availableFlashPlayer != null) {
// launch the intent with the available flash player
intent.setPackage(availableFlashPlayer);
}
startActivity(intent);
The availableFlashPlayer method:
public String availableFlashPlayer() {
String availableFlashPlayer = null;
String FLASH_PLAYER = "com.htc.flash";
PackageManager pm = getPackageManager();
try {
ApplicationInfo ai = pm
.getApplicationInfo(FLASH_PLAYER, 0);
if (ai != null) {
availableFlashPlayer = FLASH_PLAYER;
}
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
return availableFlashPlayer;
}
You can also check the Adobe Flash Player:
String FLASH_PLAYER = "com.adobe.flashplayer";
Alternatively, you can force the intent to launch the Android Browser as follows:
Uri uri = Uri.parse(videoUrl);
String packageName = "com.android.browser";
String className = "com.android.browser.BrowserActivity";
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setClassName(packageName, className);
startActivity(intent);

Categories

Resources