How can I play video from YouTube channel in Decentraland? - youtube

There is sample code to play video in Decentraland. This link
However, I want to play video from a playlist in YouTube channel. Is there any sample code you can reefer me?

Unfortunately you cannot directly access any Youtube videos due to a CORS policy set on their side. This is not an issue with Decentraland itself, but rather with Youtube and other content providers that have a similar CORS policy.
Youtube and Twitch (for example) have their own javascript players that not only display ads but also gather information about the viewer. Seeing as this is the basis of their income, they do not want people bypassing this and just viewing the video for "free".
You may notice that youtube videos work in CryptoVoxel for some reason. This is due to some trickery that the game is doing, where it is loading in the html/js and placing the video on-top of the game itself. (At least that is what I've heard)
In the meantime I strongly suggest you look into hosting your videos on another platform like Vimeo. You can directly access the video files if you pay for their service. Alternatively, you can host your videos on an Antmedia server through a cloud hosting service like Digital Ocean. Both of these are great options.

Related

youtube related video and on Pause more videos

Dears,
is there anyway to disable the related videos sent by youtube API through any player, as i am using WordPress and h5p for built LMS courses.
i am trying to disable the related videos at the end in the video and also there is more videos when you Pause the video.
hope the disable this as this is LMS and learning portal for users and they are confusing a lot from this videos.
best regards,
H5P needs to use YouTube's API for iframe embeds. That API does not provide an option to disable the related videos, and given that the API uses an iframe to provide the videos, there's no way to modify the video appearance. Guess you cannot get free video hosting and full control at the same time.

How do YouTube downloaders access the videos?

I did find this answer but it uses YouTube's APIv2, and is now outdated as stated in the answer.
YouTube's terms of use state that you can't use another player or download videos, so it makes sense they've excluded it from the API.
Knowing that, how do online YouTube downloaders, or third party Android apps (that allow to turn the screen off while they keep playing music for example) access those videos?
I'm trying to access a video to stream it inside unity for example (by the way there's a couple of unity assets that do it too), and I'd like to learn how they do it.

Using Youtube API to play just audio

We are a couple of software developers and were planning on making some commercial extension or some website through which users, with slow internet connections or limited data could play almost any video through YouTube's API. Although, while going through the API docs, we came through the following section,
Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to:
"separate, isolate, or modify the audio or video components of any YouTube audiovisual content made available through the YouTube API"
-Kuan Yong, YouTube API Team
Is there no such legal way through which we can disable just the video and stream audio, not even with the commercial API?
Hoping for a positive reply.
Playing just audio means isolating audio, which is a clear violation of the terms and conditions of the YouTube API. However, as far as I know, there is no such restriction when not using the YouTube API. For example, youtube-dl, which is a video downloader for YouTube and hundreds of other websites, has the functionality to download just audio.
In fact, in YouTube's format, audio and video are actually stored in separate files on the server. This means you can actually acquire the path to the audio file and stream it to you users. Check out the open-source youtube-dl, specifically the youtube module, for more details.
Edit
The reason I am merely linking to a library is that YouTube continually changes the way they format, store, and stream video. This means that retrieving the direct link to a video's audio component is a task subject to frequent change. If you can link against youtube-dl's python module, you can make use of their updates whenever such changes occur.
Disclaimer
I am not fully sure if this is all legal and whatnot. Hence, I take no responsibility for your decision on what to do, nor do I condone this kind of behavior.

Am I separating, isolating or modifying the audio or video of a Youtube Video in my Android App?

I have a responsive website for kids. Kids can watch selected Youtube Videos in a webbrowser. To make ann Android app, I used an APK creator. This app shows my website in a fullscreen webviewer. I set it up to hide the addressbar, so kids can more safely brows the App (website). On the website are no external links, except the links from the Youtube player. The YouTube video's are loading with a normal Wordpress YouTube plugin. When hitting the YouTube logo or Video URL, the Youtube website wil show.
Now Google Plays said i am violating the rules of the YouTube Api:
"Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to: (8) separate, isolate, or modify the audio or video components of any YouTube audiovisual content made available through the YouTube API;"
This I truely not understand. There is no way I want to violate anything. When I appeal for reinstatement the just saying:
"After further review, we are unable to reinstate your application. You can find out more information under Reason for Suspension in the initial removal notification from Google Play."
The initial removal notification said what I wrote above.

JavaFX project play youtube videos

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?

Resources