编辑2011年3月22日:由于Youtube现在提供HTTPS访问,因此该问题不再具有相关性:http://apiblog.youtube.com/2011/02/https-support-for-youtube-embeds.html
我们的应用程序通过HTTPS运行,很少给我们带来任何问题.然而,当谈到youtube时,他们没有通过SSL连接呈现任何内容这一事实让我们在尝试嵌入剪辑时感到头痛.主要是因为Internet Explorers着名的小警告信息:
"您是否只想查看安全传送的网页内容?此页面包含无法使用安全HTTPS等提供的内容"
我试图通过几种方式解决这个问题.最有希望的是使用Apache中的ProxyPass功能映射到YouTube.
像这样:
ProxyPass: /youtube/ http://www.youtube.com
ProxyPassReverse: /youtube/ http://www.youtube.com
Run Code Online (Sandbox Code Playgroud)
这摆脱了恼人的警告.但是,youtube SWF无法启动流式传输我设法加载到浏览器中的SWF只是声明:"发生错误,请稍后再试".
可能的解决方案可能是
3月10日更新:我尝试使用Googles Youtube API for ActionScript加载播放器.它起初看起来很有希望,我能够通过我的https://代理加载播放器.但是,加载的SWF包含对不同非ssl URL的显式调用的大量内容,以便为FLV流创建身份验证链接以及加载不同的跨域策略.
看起来我们似乎不应该直接访问flv-streams.这使得很难绕过Internet Explorer警告,而不是从youtube中删除FLV:s并将其提供给您自己的域.
有解决方案可以下载你的FLV:s.但这不符合Youtube的使用条款,对我们来说真的不是一个选择.
我想使用以下load()
方法接受五个参数,以便我可以从较大的视频加载一个小的"摘录":
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/VideoPlayer.html#load()
特别是,startTime
和duration
参数似乎是我需要的,但我得到的错误似乎表明我没有正确的对象/版本的东西,即使Adobe文档说它应该工作.这是我的步骤:
创建一个新图层并在第1帧中添加Actionscript:
import fl.video.*;
var innerPlayer = vPlayer.getVideoPlayer(vPlayer.activeVideoPlayerIndex);
trace(innerPlayer); // "[object VideoPlayer]" appears in Output window
innerPlayer.load(
"RTMP://..."
, 0 // totalTime
, false // isLive
, 60 // startTime
, 10 // duration
);
Run Code Online (Sandbox Code Playgroud)这应该给我从一分钟标记开始的十秒钟剪辑,但我不断收到错误 ArgumentError: Error #1063: Argument count mismatch on fl.video::VideoPlayer/load(). Expected 1, got 5.
我也尝试将innerPlayer转换为fl.video.VideoPlayer,但这不起作用.
我究竟做错了什么?
编辑:即使我在CS4/AS3和文档声称适用于CS4/AS3,我的"组件源"文件夹中的类文件似乎与文档不匹配.我也在CS6中尝试了这个,我得到了"1137:参数数量不正确.预计不超过3".
@SunilD.- 对于CS4: FLVPlayback.VERSION
= 2.1.0.19,我的目标是Flash Player 10(最新的)+ AS3.对于CS6,FLVPlayback.VERSION
= 2.5.0.26,我的目标是Flash Player 11.4.
在CS4和CS6中,错误表明VideoPlayer load()
只需要一个参数(有两个可选参数),并且play() …
如果您在Flash中加载FLVPlayback组件或在Flex中加载VideoDisplay并尝试搜索特定位置或将playheadTime设置为特定位置,则电影总是向上或向下舍入非常大的数量
在Flash中,将FLVPlayback组件拖到舞台并将源设置为http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/examples/assets/phone.flv 然后尝试video.seek (6)或video.playheadTime = 6;
它只会转到10.同样,如果你使用他们的内置洗涤器,唯一的间隔是0,5或10.所以最多你看到的擦洗框架是3
以下是具有相同结果的flex示例.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:media="com.synapsegroup.media.*">
<mx:Script>
<![CDATA[
import mx.events.MetadataEvent;
import mx.events.SliderEvent;
import mx.events.VideoEvent;
protected function scrubber_changeHandler(event:SliderEvent):void
{
trace(event.value);
video.playheadTime = event.value;
}
protected function video_playheadUpdateHandler(event:mx.events.VideoEvent):void
{
//scrubber.value = event.playheadTime;
//http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/examples/assets/phone.flv
}
]]>
</mx:Script>
<mx:Panel>
<mx:VideoDisplay id="video" source="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/examples/assets/phone.flv" minWidth="200" minHeight="200"
autoPlay="false"
/>
<mx:ControlBar>
<mx:Button label="Play" click="video.play();"/>
<mx:Button label="Stop" click="video.pause();"/>
<mx:HSlider liveDragging="true" id="scrubber" minimum="0" maximum="11.5" change="scrubber_changeHandler(event)" thumbPress="video.pause();"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,如果您足够快地单击播放/暂停,您可以更精细地暂停各个帧,但这不是一个好的用户体验
有什么我缺少以编程方式执行此操作吗?
我还要说间隔根据视频长度而变化,3分钟长的间隔有10秒的间隔
首先:这是我的第一个问题,我不是一个熟练的Flash开发人员.
我有一个FLVPLAYBACK组件(Player
)的电影.我设置了一个外部源(Player.source = "http://example.com/movie.mp4
)并完全缓冲它(使用Player.addEventListener(VideoProgressEvent.PROGRESS, bufferVideo)
).电影播放得很好.问题是:我需要能够在一秒钟内寻找指定时间甚至几乎没有时间.我有一个循环检查某些条件并启动Seek方法(Player.seek(TIME)
).它有效,但寻求之间存在明显的滞后.有可能.Seek()
立即吗?我在HTML5中使用过这样的东西,但是我无法在所有浏览器上实现正确的电影缓冲.
我不想共享完整的代码,因为它在这个问题的各个部分之间有很多不相关的部分.
更新我尝试了FLV(不知何故似乎寻求更慢)和F4V(看起来更快,但仍有可见滞后)/
我目前在舞台上有FLVplayback组件,但是,我将autoPlay设置为False.这是一个问题,因为我希望流只在用户按下播放时开始下载.
此外,当我点击带有视频的页面时,我希望能够停止下载流.
提前致谢.
string host = "http://youtube.com/v/";
string end = ".flv";
WebClient Client = new WebClient ();
StreamReader sr = new StreamReader(@"ids.txt");
string line;
do
{
line = sr.ReadLine();
Client.DownloadFile(host+line+end,line+end);
}
while (line !=null);
sr.Close();
Run Code Online (Sandbox Code Playgroud)
工作正常但晚于我将运行flv /视频,这给了我这个错误>
An error occurred when the file plays in Windows Media Player
Run Code Online (Sandbox Code Playgroud)
为什么,我做错了什么?
我正在尝试为iPad创建一个简单的应用程序,当您单击按钮时播放FLV.我使用http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#VIDEO-USE_THE_MEDIA_PLAYER_FRAMEWORK_FOR_VIDEO_PLAYBACK中的代码作为参考.这是我的点击事件的代码
-(IBAction) btnPlayVideoClick:(id) sender {
NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"flv"];
MPMoviePlayerController* myMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
// Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
[myMovie play];
}
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
// Release the movie instance created in playMovieAtURL
[theMovie release];
}
Run Code Online (Sandbox Code Playgroud)
我能够成功编译并运行应用程序,但是当我单击按钮时,应用程序只退出时没有任何错误消息或任何活动.有什么东西我做错了,或者是否有某些原因我无法使用模拟器播放FLV.我还无法在真实设备上进行测试,因为我正在等待批准获得我的开发许可证.
谢谢,
麦克风
flvplayback ×7
flash ×4
flv ×2
youtube ×2
actionscript ×1
apache-flex ×1
c# ×1
https ×1
ipad ×1
iphone ×1
ssl ×1
video-player ×1
videodisplay ×1