Copy link to clipboard
Copied
Hi,
I'm trying to embed video on the timeline to do a short intro to a game app. The video is an FLV in the library and I have it embeded in the timeline. Published at 500kbs I get so much studder on the iPhone 4.. even when I publish it at half size frame.
Any chance with running full frame hd video through flash? any suggestions?
Thanks,
Dani
Copy link to clipboard
Copied
The FLV performance in the timeline may need to wait for an AIR update before that works well.
If you want to do full screen HD video, that is easier, strangely enough! Search around for how to use StageWebView to show HTML with embedded video, using AIR 2.6. Once you have that working you'll get native performance playing of H.264 movies, and you can even have it go full screen at full frame rate.
Here's some info to get you started:
http://www.adobe.com/devnet/air/quick_start_as/quickstarts/qs_using_stage_web_view.html
I think though that you'll only be able to try this out using either Flash Builder 4.5 or Flash CS5.5.
Copy link to clipboard
Copied
That would be the best but, the StageWebView show content from the web and I don't think it would work for my game intro. The content has to be in the library to have a quick access, unless I'm missing something and you can make that connection...
Copy link to clipboard
Copied
The content wouldn't be on the web, it would be local files that you included in the package.
Copy link to clipboard
Copied
Oh, I was hoping you would say that. I can't find anything about this on the web.. so the code would look something like this:
webView.loadURL("Sequence 01.mp4");
And I'll have to include the Sequence 01.mp4 video in publish settings?
Copy link to clipboard
Copied
Yes, try that, or at worse case have the html wrapper for it too.
Copy link to clipboard
Copied
My code looks like that:
import flash.media.StageWebView;
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
webView.loadURL("Sequence 01.mp4");
And I'm getting this error:
Error #2044: Unhandled ErrorEvent:. text=Load error.
How would you write this with the HTML wrapper?
Thanks for the quick help
Copy link to clipboard
Copied
I may find time to do a test, to then show you what I did, but can you first try a file that doesn't have a space in its name?
Copy link to clipboard
Copied
Good point! I did a test though and got the same error.In general, is it ok to use the loadURL for local files?
Thanks again!
Copy link to clipboard
Copied
OK.. so I think I made some progress. Checking this link http://sonnati.wordpress.com/2011/04/26/air-2-6-for-ios-and-video-playback/ I came up with the code below:
import flash.media.StageWebView;
import flash.filesystem.File;
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
var filePath:String = new File(new File("app:/Sequence01.mp4").nativePath).url;
webView.loadURL(filePath);
So now there are no errors. But the stage turns white and nothing is playing, any sugestions?
Copy link to clipboard
Copied
..and also this link: http://forums.adobe.com/thread/827505?decorator=print&displayFullThread=true
It shows the way to use the StageWebView for a local file.
Copy link to clipboard
Copied
It seems I was figuring it out at the same time! The key bit you missed is that it won't work in Test Movie, because the native path you get is to the original file on your computer. When you try it on a device it works ok.
Copy link to clipboard
Copied
Wow!! good timimg..
Right after I posted I sent it out to the device just incase it's not working on the test movie.. yes, it works!
Copy link to clipboard
Copied
So to build on that, how do I listen to the end of the movie so I can go back to flash timline?
Copy link to clipboard
Copied
There isn't much you can do to communicate with StageWebView, but what is your example usage case? For example, if you want a Flash experience where one element is a video to watch, then just make the StageWebView as big as the video should be at its smaller size. If the user touches the full screen button while playing, it will automatically shrink to the smaller size when the video ends, or when the Done button is touched. That's normal behavior for iOS video.
Copy link to clipboard
Copied
I'll be using it as an into movie for the game. When ever a new game sarts I'll have it go to full screen video with sound and text that will give the idea of the game scenario. At the end of the movie the video fades to black and in the Flash timeline I will have the first screen fade from black and the game begins. So any way to have the movie push something to flash to go to next frame will suffice.
I think it might be posible with javascript as in the end of this post: http://forums.adobe.com/thread/827505?decorator=print&displayFullThread=true
So I'll need to create an html page for this. Come to think of it it might have already worked in my previous tests but didn't show on the player. I'll give it another go.
Copy link to clipboard
Copied
Did you ever get it completely working? I am in the exact same scenario.
thanks,
Copy link to clipboard
Copied
No yet. I had to go back to other parts of my project and this took too much time as it is. Sorry..
I got the video to work through this code: (frkin full hd on the iPhone through Flash.. after all those experiments and stadder it was such a beauty )
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
var filePath:String = new File(new File("app:/myMovie.mp4").nativePath).url;
webView.loadURL(filePath);
The next thing would be to use this line instead to call the HTML and embed the movie there. From there you can code the page to notify when it done through javascript(like is the link I posted). And if you listen to this in Flash you can take it from there once the event happened.
I'm still in the search for the final solution so if yop get there ahead of me please drop a line.
Dani
Copy link to clipboard
Copied
Colin Holgate had a great idea. Set up a timer to close down the StageWebView and then carry on with the timeline after the intro plays. Been playing with this idea because it seems to be the best solution. Just haven't got it completely working yet.
Copy link to clipboard
Copied
Did you try the HTML code with Java? It must work.
Can you post a direct link to Colin Holgate post about this?
Copy link to clipboard
Copied
We have talked further about this, and in addition to what I wrote about using stagewebview to play a video file, we also worked out how to shut it down after a given time. In addition to what was written down here:
http://forums.adobe.com/thread/849395?tstart=0
you need to set the web view to null when you're done with it.
Copy link to clipboard
Copied
I believe you've linked us to this post.. after some time I noticed that I'm going in a loop..
Copy link to clipboard
Copied
Sorry, I though I was replying to a question about "recursion"...
Copy link to clipboard
Copied
This is where I am at now. It seems to be working. My intro movie is 30 secs.
Movie Frame code:
stop();
var myTimer:Timer = new Timer(30000);
myTimer.addEventListener(TimerEvent.TIMER, thirtySec);
myTimer.start();
function thirtySec(event:TimerEvent):void
{
this.nextFrame();
}
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.filesystem.File;
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
var fPath:String = new File(new File("app:/chapter-1---000.mp4").nativePath).url;
webView.loadURL( fPath );
Copy link to clipboard
Copied
That's great! Works perfect. Few things: