如何加载YouTube视频在Flash Builder?加载、视频、Builder、YouTube

2023-09-09 21:49:45 作者:入骨相思

我想在Flash Builder播放YouTube视频。每次我播放的文件,我得到一个错误信息:

I'm trying to play a Youtube video in Flash Builder. Each time I play the file I get an error message:

SecurityError: Error #2121: Security sandbox violation: Loader.content:     https://www.youtube.com/v/FGtTEmBR7Sk cannot access https://s.ytimg.com/yts/swfbin/player-vflQiDuyQ/watch_as3.swf. This may be worked around by calling Security.allowDomain.
at flash.display::Loader/get content()
at com.google.youtube.application::SwfProxy/onRequestParameters()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.google.youtube.model::YouTubeEnvironment()
at com.google.youtube.application::WatchPageVideoApplication/createYouTubeEnvironment()
at com.google.youtube.application::VideoApplication/onLoaderInfoInit()

我试图围绕使用推荐工作(见下文),但我做什么都不会停止的错误消息。我也下载并尝试了从Web几个示例文件,但每次我得到一个错误信息。

I have tried to use the recommended work around (see below) but nothing I do will stop the error message. I've also downloaded and tried out several sample files from the web, but each time I get an error message.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" creationComplete="init()">
<mx:Script>
    <![CDATA[
        [Bindable] private var videoUrl:String;         
        private function videoToPlay():void{
            Security.allowDomain("http://www.youtube.com/v/FGtTEmBR7Sk");
            Security.allowDomain("https://s.ytimg.com");
            Security.allowDomain("https://s.ytimg.com/yts/swfbin/player-vflQiDuyQ/watch_as3.swf");
            Security.allowDomain("*");
            videoUrl = "http://www.youtube.com/v/FGtTEmBR7Sk";  
        }

    ]]>
</mx:Script>
<mx:Button    label="Play"  click="videoToPlay()"  useHandCursor="true" buttonMode="true" />

<mx:Canvas>
    <mx:SWFLoader id="swfLoader" source="{videoUrl}"  width="640"   height="387" />
</mx:Canvas>
</mx:Application>

谁能告诉我什么是错我的code或指向我一个工作的例子,说明如何嵌入在Flash Builder YouTube的文件?

Can anyone tell me what is wrong with my code or point me to a working example that shows how to embed a youtube file in Flash Builder?

推荐答案

您有(锯)的#2121,因为你正在使用的 Flash播放器的调试版本但使用时,正常的版本,你将得到什么(如你所说,虽然)和您的播放器将加载YouTube的内容与任何其他玩家没有问题。 Flash播放器的调试版本是面向开发人员的调试和测试的目的,因此不关心这些安全警告,如果通常装有这是由所有非开发用户的正常的版本内容。

You got ( saw ) the #2121 security error because you are using a Flash Player debug version but when using a "normal" version you will get nothing ( as you said although ) and your player will load the youtube content as any other player without problems. The debug version of Flash Player is intended for developers for debug and test purposes, so don't care about these security alert if your content is loaded normally with the "normal" version which is used by all non-developer users.

安全错误被触发时的 youtube.com 的尝试访问 watch_as3.swf 从文件的秒。 ytimg.com 的,所以在这里你可以做什么,以避免这种错误,因为的Security.allowDomain 应在由谷歌,以保持该SWF文件中使用我的知识;)

The security error is fired when youtube.com try to access to the watch_as3.swf file from s.ytimg.com, so here you can do nothing to avoid that error because the Security.allowDomain should be used in that swf file which is maintained by google to my knowledge ;)

的Security.allowDomain 功能用于这样的:

The Security.allowDomain function is used like this:

    // we use only the domain name not all the file url
    Security.allowDomain('example.com');       // or http://example.com

    // or the ip address 
    Security.allowDomain('10.10.10.10');       // or http://10.10.10.10

    // or a wildcard "*" to allow all domains
    Security.allowDomain('*');

希望能有所帮助。

Hope that can help.