actionscript 3 - How do I load a YouTube video in Flash Builder? -
I am trying to play a YouTube video in Flash Builder. Every time I run the file I get an error message:
SecurityError: Error # 2121: Security Sandbox Violation: Loader.content: https://www.youtube.com/v/ FGtTEmBR7Sk can not access http: //s.ytimg.com/yts/swfbin/player-vflQiDuyQ/watch_as3.swf. It can be worked around in the name of security. On Flash.display: Content on Loader / com.google.youtube.application (): SwfProxy / onRequestParameters () flash.events::EventDispatcher/dispatchEvent at flash.events::EventDispatcher/dispatchEventFunction () () YouTubeEnvironment () :: WatchPageVideoApplication / createYouTubeEnvironment () at com.google.youtube.application at com.google.youtube.application :: VideoApplication / onLoaderInfoInit () I have tried to use the suggested work below (see below), but whatever I do will stop the error message. I have tried to download and use many sample files from the web, but every time I get an error message.
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Mx: application xmlns: mx = "http://www.adobe.com/2006/mxml" layout = "full" minWidth = "955" minHeight = "600" creationComplete = "init ()" & gt; & Lt; Mx: script & gt; & Lt ;! [CDATA [[Bindabal] Private war video URL: string; Private function videoToPlay (): Zero {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"; }] & Gt; & Lt; / Mx: script & gt; & Lt; Mx: button label = click "play" = "use video play ()" handcurs = "true" buttonmod = "true" /> & lt; Mx: canvas & gt; & Lt; Mx: SWFLoader id = "swfLoader" source = "{videoUrl}" width = "640" height = "387" /> & Lt; / Mx: canvas & gt; & Lt; / Mx: Applications & gt; Can anyone tell me what is wrong with my code or for example an example that works for me, how to embed a YouTube file in Flash Builder?
-
You've got a security error because # 2121 You are using one but when using a "normal" version you will not get anything (as you said) and your player will load YouTube content as any other player without problems. The debug version of the Flash Player is intended for developers for debug and testing purposes, so do not care about these security alerts if your content loads normally with the "normal" version which is used by all non-Developer users
-
Security error is removed when try youtube.com to watch_as3.swf s.ytimg.com , here you can I can not avoid that error because Security.allowDomain can not be used in my SWF file that is maintained by Google for my information;)
-
The function is used like this:
// We do not use only the domain name, all file URL security allowDomain ('example. Com '); // or http://example.com // or IP address security Oodomain ('10.10.10.10 '); // or http://10.10.10.10 // or wildcard "*" to protect all domains. Hope that can help.
Comments
Post a Comment