问题
I make an application for iOS and Android using ActionScript 3 and Adobe AIR ( 3.7 ) to build the ipa and apk. In this application, I load a Video from an FLV and add it in the scene. The problem is, on the emulator or the Flash view, all is ok, but, on the iPad ( test on iPad 1, 2 and 3 with same results ) the video makes shorts jumps ( like a sudden freeze follow by a short jump into the time-line ) every 2 secondes, approximately.
Of course, I make sure that the video wasn't under other elements or above moving clips. I try to load the video without the rest of the interface : same result. Change the renderMode to "direct" or "gpu", no... Export the video in different quality and assure no redimensionnement ( Even with a dimension in a multiple of 8 ), no again.
I use a similarity of this code to load my video ( It's the test code I use to be sur that the problem wasn't elsewhere in my code )
var myVideo:Video = new Video();
this.addChild(myVideo);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = { onMetaData:ns_onMetaData, NetStatusEvent:ns_onPlayStatus };
myVideo.attachNetStream(ns);
ns.play("myLink.flv");
var ns_onMetaData:* = function(item:Object):void { }
var ns_onPlayStatus:* = function(event:NetStatusEvent):void {}
ns.addEventListener(NetStatusEvent.NET_STATUS, ns_onPlayStatus);
Thanks in advance and sorry for my bad english
回答1:
You should not use FLV on iOS devices. That is my personal guess as to why you are seeing the "jump". FLV is software decoded, so it is relatively slow. My personal guess is you are experiencing dropped frames while the video is being decoded.
On iOS (and all mobile devices, really), you want to use h.264 video with an mp4
extension (m4v
will work on iOS, but not on Android, I believe). For playback, you want to use either StageVideo
or StageWebView
rather than an AS3-based video-player. StageVideo will render using the actual media framework of the device. StageWebView will only work on iOS and certain Android devices, and will render using the actual media player of the device.
The difference between this and Video
or FLVPlayback
(or the Flex or OSMF-based video players) is that the video will be hardware accelerated/decoded. This means that your app's render time (and thus the video render time) will not also be dictated by how fast the video is decoded because a separate chip will be handling it.
Additionally, hardware accelerated video will be much, much better on battery life. I ran a test last year on an iPad 3 and the difference between battery life consumed by software/CPU decoded FLV and hardware decoded h.264 was somewhere in the neighborhood of 30%.
Keep in mind that both of these options do not render in the display list. StageWebView renders above the display list and StageVideo renders below.
I suggest viewing my previous answers on video render in an AIR for Mobile app as well. I have gone into more detail about video in AIR for mobile in the past. I have built three video-on-demand apps using AIR for Mobile now and it is definitely a delicate task.
NetStream http Video not playing on IOS device
Optimizing video playback in AIR for iOS
How to implement stagevideo in adobe air for android?
Hopefully this is of some help to you.
来源:https://stackoverflow.com/questions/18902015/actionscript-3-air-video-make-blink-jump