How can I play YouTube videos in a Windows 8 html/javascript app? I have the clip's id and I just want to play it. Perhaps via html5's video tag?
I've tried the iframe api, but failed to get it to work. I've also made a try on the javascript api, but it failed to load javascript from anther location.
Any help on the subject would be very appreciated!
I developed a YouTube class for Windows Phone which gets the MP4 link of a YouTube movie. Maybe you can use this code and start the video app with the MP4 link or set the source of a media element (if existent in Win8)?
If there's a way to start the video app with a predefined MP4-URL I can rewrite the code for Windows 8.
http://mytoolkit.codeplex.com/wikipage?title=YouTube
UPDATE: I've updated the code. Now simply load the URL with this async method:
var url = await YouTube.GetVideoUriAsync("youtube_id");
myMediaElement.Source = url.Uri;
myMediaElement is a XAML MediaElement control.
Check out the whole library from the project's Subversion repository: http://mytoolkit.codeplex.com
Update: Sorry it's C# only, you have to port it to Javascript...
Related
I want to use video from some live streaming channel i.e. twitch, youtube in my iOS application without using their plugins. How can i do so?
I'm trying to get url of the video so that i can play it via moviePlayer or something else in my application. At the moment, i'm using OBS for uploading the live-stream on twitch.tv
I've found the following link, but again i'm unable to find the url of the video so can't use the solution mentioned How can I use Livestream player in iOS/Android app?
Thanks,
I have solved the issue using webView. For Youtube we've stream id and we put it in url as "https://www.youtube.com/watch?v=videoId".
For ustream i made url as "https://www.ustream.tv/embed/channelId".
If you don't want to use webView then you can use helper libraries for these platforms i.e. YTPlayer, twitch etc.
I work on an automatically music player. To be short, i use the Last.fm api to get a lot of tracks names and tags. Using these tags and some intelligence computing algorithms, once you play a track, the player sets another track (with tags very appropriate to the tags of the track listened before).
I used the youtube API to search for the URL's of the movies, and I managed to make it work. Now I want to make the videos play on my music player. I have tried to place the youtube player on WebView. It works, but not as intended. I want to control that player. I want it to start playing automatically, and I want to get noticed when the video ended so I can start the next one.
Any clues of what should I do to play the videos from youtube based on the search that uses the Youtube API, and to have control over the youtube player that I place on my GUI(make it play and stop from command line)? Or is there any possible way do download the youtube movie and play it using the JavaFX API? I searched google and noticed I cannot download youtube movie into a format that can be played by JavaFX api.
Update Dec 4th, 2015
Some versions of JavaFX 8 are unable to play back youtube video content. Currently, for instance, Java 8u66 cannot playback youtube video content, but Java 8u72 early access release can.
Also note some of the videos referenced in the sample solution are no longer available or are protected from play in embedded video players. So ensure that you perform any tests using available and videos that have not been distribution restricted. Refer to the youtube documentation for information on distribution restriction if need be.
Any clues of what should I do to play the videos from youtube
As a hints to get you started, see code playing YouTube videos in JavaFX and the YouTube HTML5 api.
Here is the sample code I linked running and playing YouTube videos back within a JavaFX WebView with some (very minimal) control over the video playback via interaction with a JavaFX "New Song" button.
Or is there any possible way do download the youtube movie and play it using the JavaFX API? I searched google and noticed I cannot download youtube movie into a format that can be played by JavaFX api.
I think such a usage would violate YouTube's terms of service. I believe YouTube requires you to play the video back using the YouTube video player (let's them insert ads in the video player etc).
5.1 A
you agree not to distribute any part of or parts of the Website or the
Service, including but not limited to any Content, in any medium
without YouTube's prior written authorisation, unless YouTube makes
available the means for such distribution through functionality
offered by the Service (such as the YouTube Player);
5.1 C
you agree not to access Content through any technology
or means other than the video playback pages of the Website itself,
the YouTube Player, or such other means as YouTube may explicitly
designate for this purpose;
I advanced little, but I got stuck to other problems.
First of all, the code from jewelsea was great. Now I could embed the player into a secondary window of my player and it shows the movie based on the URL that i got using the youtube api. But it looks like JavaFX cannot show most of the movies. It shows me the youtube player and an error message saying that I need to install latest version of Adobe Flashplayer. From my research, I noticed that the webView can only show movies with quality set at 240p, not higher.
I have searched a lot on Google how to make my webView to play the 240p quality video. First of all, i tried to set the youtube query parameters (https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#formatsp). I tried all the parameters from there: 1,5 and 6. But yet, I did not get the URL of movie with format that can be viewed on the webView of the JavaFX.
I also tried to embed the video quality in the URL of the movie like this:
http:/www.youtube.com/watch?v=og2YZlLhjKs&vq=small:240p ; but it does not work at all. I also wrote that URL in the browser and it looks like the youtube automatically sets the video to the highest quality, no matter what parameter I write in the URL.
The youtube api code that I used is the same like in this webpage: http://www.javacodegeeks.com/2010/05/getting-started-with-youtube-java-api.html
I just moved the main class code to a method that returns the URL of the first video that is in the list, and I changed the " query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT); "
to " query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);". And this works fine, it shows the url to proper music videos that I search.
I am sorry for not showing the code of my project but it is big and it contains 2-3 api keys, and if you tell me how to change the video URL http:/www.youtube.com/watch?v=og2YZlLhjKs to work on the code from this website: https:/gist.github.com/jewelsea/1437374 , then I will know that to do to make it work on my project as well;
And the thing about YouTube playback API also enlightened me. I see that API has a lot of functions that could help me to play a lot easier with the video content (make it play, make it stop) but the problem is that I do not have knowledge about javascript programming and it is very sad that I do not have those methods in Java API as well. Maybe I will give it a try and insert javascript code into my webview. But, if I edit the webview using javascript... Is it going to play higher quality movies on the JavaFX webView?
I am writing application to show youtube videos.
In WPF on windows 7 I use WebBrowser control and it works fine. But when I use WinRT WebView control to show swf file from youtube - it doesn't work. Only clear white screen.
I use approach like that : http://blog.tedd.no/2010/06/27/embedding-youtube-in-wpf-webbrowser-control/
What shall I do to have an oppotunity to show videos in Metro Style Application?
Thank you
try this one from the mytoolkit library: http://mytoolkit.codeplex.com/wikipage?title=YouTube
The default youtube video player (unless the user has opted into the HTML5 preview) is a Flash video control. Flash is not supported in the Windows Application Store ("Metro") shell version of IE, or in the WebView control.
But what you can do is request youtube to use the HTML5 video player (HTML5 video is supported by the App Store version of IE and WebView). For example, this video does play properly for me:
<WebView Source="http://www.youtube.com/watch?v=cTl3U6aSd2w&html5=True" />
So you should be able to embed a video using a webview, you just have to force the webview to use the HTML5 viewer. This can also be done as a parameter to the embed URL: see Force HTML5 youtube video
However, this setting only says to prefer the HTML5 player. Youtube may still attempt to use the flash player on some videos, which will not work in all cases.
You can alternatively also play the video through "mediaelement" to play youtube video, though you'd have to parse the youtube video stream first. See my W8 app "RedditTV"
I have the url video on youtube and I want to play the video in the youtube default application on the blackberry without invoking the browser to play
enter code here
I've never found a way to do this. The BlackBerry Invoke class does not have a constant defined for the Youtube app, which is what you can use to open other built-in apps.
I know this isn't what you'd prefer to do, but a couple other alternatives are:
open Youtube videos in the Browser, like this:
Browser.getDefaultSession().displayPage("http://www.youtube.com/watch?v=ciB6ExQa5SM");
take a look at the BlackBerry Youtube Client sample, which would allow you to build an embedded Youtube player. A companion blog post can also be found here. Note: the sample probably won't display video in a simulator, as I think you need to have a valid cellular carrier setup (APN settings, etc.) for the network to allow youtube streaming.
I am using a Phonegap plugin for playing a video in my iOS app. I'm able to play a video with the URL format like http://easyhtml5video.com/images/happyfit2.mp4.
How do I play Youtube videos using the phonegap-videoplayer-plugin?
YouTube Terms of Service: "You agree not to access Content
through any technology or means other than the video playback pages of
the Service itself, the Embeddable Player, or other explicitly
authorized means YouTube may designate."
There are some methods that will give you direct link to youtube videos. Use "gdata" option to find all possible video formats.
Then parse the result to get desired link. Hope this might be useful
But everywhere I found the code to be edited in .m and .h files. None have explained how to use it.
That's because you can only directly use MPMoviePlayerController from native apps (written in Objective-C). For any other technology you'll have to have an intermediary layer in between.
From googling, I found this plugin for PhoneGap that claims to integrate with MPMoviePlayerController. I've no idea if it's any good, but it might do as a starting point.
try to give the youtube url in this format.
http://www.youtube.com/embed/jxXukpxNSx4
You will get the desired result. But Autoplay is not enabled, as Apple stopped supporting autoplay to save user's bandwidth