Actionscript 3 android videoPlayer set size issues
Copy link to clipboard
Copied
I am creating a Android app prototype on Adobe Animate, I have been able to load a YouTube video using the API and it loads correctly and I have been able to position it as well, however I can't figure out how to set the size of the video. I have used videoPlayer.setSize but this doesn't make a difference when i test it.
This is my code:
var videoPlayer: Object;
var loader: Loader = new Loader();
loader.load(new URLRequest("http://www.youtube.com/v/mJsvmscPY9w?version=3"));
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.x = -200;
loader.y = -430;
function onLoaderInit(e: Event): void {
addChild(loader);
videoPlayer = loader.content;
videoPlayer.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(event: Event): void {
videoPlayer.setSize (200, 100);
}
Any ideas?
Thanks
Jenny
Copy link to clipboard
Copied
so what do i need to do?
Copy link to clipboard
Copied
I think that even if you could load the swf it would fail. That swf is expecting to be playing in a web page, where it can get at the other things it will need. The video file for example.
If the overall goal is to show a YouTube video in your app, look at using the embed system to show the video in a StageWebView. You can set the size of that view so that your other buttons are not obscured. I think that it should even work on iOS, because it would give you the HTML5 compatible version.
See this article on how to get and use the embed code:
Copy link to clipboard
Copied
:
function onLoaderInit(e: Event): void {
addChild(loader);
this.addEventListener(Event.ENTER_FRAME,enterframeF);
}
function enterframeF(e:Event):void{
if(loader.width>0){
loader.width = whatever
loader.height= whateverelse
this.removeEventListener(Event.ENTER_FRAME,enterframeF);
}
}
Copy link to clipboard
Copied
what do you put in the 'enter frame' parts??? as mine is all in the same frame
Copy link to clipboard
Copied
Even while sat on the same frame the enterframe event happens as many times per second as the frame rate you've set for the FLA.
Copy link to clipboard
Copied
so is there no solution?
Copy link to clipboard
Copied
If you mean a solution to getting the size of a loader working, kglad's answer 27 would do. If you mean a solution to how to play YouTube videos in an AIR mobile app, my answer 26 would do.


-
- 1
- 2