如何加载YouTube视频在Flash Builder? [英] How do I load a YouTube video in Flash Builder?

查看:296
本文介绍了如何加载YouTube视频在Flash Builder?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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?

推荐答案

  • 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 ;)

    的<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Security.html#allowDomain%28%29"相对=nofollow> 的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.

    这篇关于如何加载YouTube视频在Flash Builder?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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