Videos
The following example code will open the Youtube link in the Youtube app if this one is available, otherwise it will open it in a browser:
public static void watchYoutubeVideo(String id) {
Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id));
Intent webIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=" + id));
try {
startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
startActivity(webIntent);
}
}
EDIT: To answer your second requirement. Each time you call a new Intent with this code. It will open the application or browser for this video and it wont show the previous video loaded.
Kotlin version to open Youtube video
fun openYoutubeLink(youtubeID: String) {
val intentApp = Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + youtubeID))
val intentBrowser = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + youtubeID))
try {
this.startActivity(intentApp)
} catch (ex: ActivityNotFoundException) {
this.startActivity(intentBrowser)
}
}
Just call
this.openYoutubeLink("Q-dNnMlaGNg")
Edit: This looks to be fixed for me as of the latest YouTube app update on 11/17. So far so good!
Using an iPhone 16 pro max on the latest iOS. Somehow the YouTube app has broken within the past few weeks. Now when I try to open any link on the phone outside of the app (like in messenger or in safari) it’ll open the app but it won’t go to the video. Instead it just goes to the Home Screen.
I’ve cleared my safari browser files, reinstalled the YouTube app, restarted the phone etc. I’m not sure what else to try but it sucks. Anyone have any suggestions that don’t involve factory resetting my phone?
Hey everyone! I opened my youtube app on my Samsung phone today, and it immediately started playing a video. I checked that autoplay was disabled and restarted the app, and that didnt fix anything. I've re-enabled and disabled autoplay, restarted my device, and disabled and re-enabled the app (because I cant delete it). I've googled all day researching possible solutions but I'm out of ideas. Suggestions? Please!
Another possibility is: ext-youtube Firefox addon:
Play Youtube videos in external application.
You can use Minitube, SMPlayer or any other application that can play Youtube videos given the link.
https://addons.mozilla.org/en-US/firefox/addon/no-flash this will do exactly the job in firefox but it may be annoying if you're just browsing through youtube videos.
*In my case the extension redirects the youtube links right to my Minitube so you may need to install it, too. http://www.omgubuntu.co.uk/2012/01/minor-new-features-adds-to-linux-youtube-app-minitube/
Summary:
-
For YouTube.com links offer an easy way to open the video in the YouTube app via native deep links.
Context:
-
For some YouTube videos I want to open them in the YouTube app, because ot gives me benefits like being able to keep listening in the background or with with the screen off, using picture-in-picture, subscribing to the creators channel, or interacting with the comments using the native app.
-
I have cookies off for links I open in narwhal because I don't trust most sites, but that means I'm always signed out of youtube when I do "open in browser" so getting to the app requires two clicks
-
I like using the built in player most of the time, and wouldn't want to open YouTube for every video, just for some (like 1hr long interviews, live streams, etc)
-
while you can't implement handlers for every domain, YouTube is a bit of an 800lb gorilla. A significant amount of content on reddit is links to YT, and that is unlikely to change any time soon. Also as a large company their deep-links API is probably relatively stable and unlikely to represent a serious incremental cost in maintenance.
Possible implementations:
-
A button on the video player UI like the mute/unmute button
-
an option in the menu similar to "Open in Browser"