JavaFX项目播放youtube视频 [英] JavaFX project play youtube videos

查看:293
本文介绍了JavaFX项目播放youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在自动播放音乐播放器。简而言之,我使用Last.fm api来获取大量的曲目名称和标签。使用这些标签和一些智能计算算法,一旦你播放一首曲目,播放器就会设置另一首曲目(标签非常适合之前听过的曲目的标签)。



我使用youtube API搜索电影的网址,我设法让它工作。现在我想让我的音乐播放器播放视频。我试图将youtube播放器放在WebView上。它有效,但不是预期的。我想控制那个球员。我希望它能够自动开始播放,我想在视频结束时注意到这一点,以便开始下一个视频。



根据使用Youtube API的搜索,我应该怎样做才能播放来自youtube的视频,并控制我放置的youtube播放器我的GUI(让它从命令行播放和停止)?或者有没有可能下载youtube电影并使用JavaFX API播放它?我搜索谷歌并注意到我无法将youtube电影下载为可由JavaFX api播放的格式。

解决方案

更新2015年12月4日



某些版本的JavaFX 8无法播放YouTube视频内容。目前,例如,Java 8u66无法播放youtube视频内容,但Java 8u72早期访问版本可以。



另请注意,示例解决方案中引用的一些视频不再在嵌入式视频播放器中可用或受到保护。因此,请确保使用可用的视频和未受分发限制的视频执行任何测试。如果需要,请参阅youtube文档以获取有关分发限制的信息。


我应该怎样做才能播放来自youtube的视频


作为开始提示,请参阅。我相信YouTube要求您使用YouTube视频播放器播放视频(让他们在视频播放器中插入广告等)。


5.1 A



您同意不会在任何媒体中分发本网站的任何部分或部分或
服务,包括但不限于任何内容。没有YouTube事先书面授权的$ b,除非YouTube通过服务提供的功能
(例如YouTube播放器)提供
可用的分发方式;



5.1 C



您同意不通过任何技术访问内容
或网站本身视频播放页面以外的其他方式,
。YouTube播放器或YouTube可能明确指定用于此目的的其他方式
;



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;

这篇关于JavaFX项目播放youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆