【问题标题】:Playing media with gwt使用 gwt 播放媒体
【发布时间】:2012-03-16 11:26:07
【问题描述】:
我有一个使用 G.W.T 开发的简单邮件系统,如果有视频或音频文件作为附件,我正在尝试添加一个播放音频和视频文件的功能。
我一直在尝试使用 bst 播放器和 HTML 视频标签来工作,但我无法播放某些视频格式,例如 .avi、.mpeg、.mpg 等。
还有什么方法可以播放这些视频格式?
另一方面,我正在考虑在 java servlet 中转换视频文件,然后将该 url 提供给播放器,但我不知道这是否有意义。应该这样吗?
最后一件事是;是否存在首先必须将视频文件转换成的通用格式(可能是 .flv?),以便 VlcPlayerPlugin 或其他视频播放器可以播放它?任何其他提示都会有所帮助。
感谢您的帮助。
【问题讨论】:
标签:
gwt
servlets
video
html5-video
vlc
【解决方案1】:
html5 video 标签只能播放某些格式。您可以在此处找到支持的浏览器格式列表。
【解决方案2】:
我在使用 BST 播放器时也遇到了一些问题,但至少它适用于以下代码:
public YoutubeVideoPopup( String youtubeUrl )
{
// PopupPanel's constructor takes 'auto-hide' as its boolean parameter.
// If this is set, the panel closes itself automatically when the user
// clicks outside of it.
super( true );
this.setAnimationEnabled( true );
Widget player = null;
try
{
player = new YouTubePlayer( youtubeUrl, "500", "375" );
player.setStyleName( "player" );
}
catch ( PluginVersionException e )
{
// catch plugin version exception and alert user to download plugin first.
// An option is to use the utility method in PlayerUtil class.
player = PlayerUtil.getMissingPluginNotice( Plugin.Auto, "Missing Plugin",
"You have to install a flash plaxer first!",
false );
}
catch ( PluginNotFoundException e )
{
// catch PluginNotFoundException and tell user to download plugin, possibly providing
// a link to the plugin download page.
player = new HTML( "You have to install a flash plaxer first!" );
}
setWidget( player );
}
如您所见,我们在这里使用了 youtube 播放器,它的积极作用是可以将视频放置在 youtube 上,并且每次重新部署 GWT 应用程序时都不能将其投递到服务器。
您也可以播放其他格式的 flash,只需在 try 块中使用正确的 Player 类即可;闪存示例:
player = new com.bramosystems.oss.player.core.client.ui.FlashMediaPlayer( GWT.getHostPageBaseURL( ) +
f4vFileName, true, "375", "500" );
player.setWidth( 500 + "px" );
player.setHeight( "100%" );
【解决方案3】:
抱歉耽搁了,没有机会回复。由于 VlcPlayer 的行为很奇怪,并且在 Ubuntu 和 Windows 上显示不同的控制按钮,我决定使用 BstPlayer 的 FlashPlayerPlugin。我首先使用 @987654321 将文件转换为 flv @在文档中有描述,然后它将转换后的视频提供给FlashPlayer,现在可以正常工作了,谢谢大家的帮助。