问题描述
我尝试播放iPad上的视频,我的code是如下:
I am trying to play a video on iPad, my code is below :
public function init_RTMP():void
{
videoURL = "http://rest************_iphone_high.mp4";
vid = new Video();
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectionStatus);
nc.connect(null);
}
private function onConnectionStatus(e:NetStatusEvent):void
{
if (e.info.code == "NetConnection.Connect.Success")
{
trace("Creating NetStream");
netStreamObj = new NetStream(nc);
metaListener = new Object();
metaListener.onMetaData = received_Meta;
netStreamObj.client = metaListener;
netStreamObj.play(videoURL);
vid.attachNetStream(netStreamObj);
addChild(vid);
}
}
当我玩我的系统上它工作正常,但是当我创造它的iOS应用程序并安装在设备上,它显示了白色的空白屏幕。
when i play it on my system it is working fine, but when i create a IOS app of it and installs on device, it shows white blank screen.
如果有人有相同的问题或任何想法,请与我分享。
If anyone have same problem or any idea please share with me.
推荐答案
由于VC.One指出,AIR为iOS不玩了大多数(但不是全部,它有时会起到非常具体的连接code型) H.264连接codeD的视频。有三种解决方法:
As VC.One pointed out, AIR for iOS does not play most (but not all, it will occasionally play a very specific encode type) h.264 encoded videos. There are three solutions:
- 作为VC.One说,你恩code为FLV。这样做是不好的,我不会推荐它。 FLV是不是硬件加速(除非事情最近改变了,我还没有看到更新),将运行完全脱离CPU意味着你的应用程序将运行缓慢和应用程序会吃电池比正常快多了。
- 使用
的StageWebView
,在这种情况下,您只需插入的URL的视频,它会使用原生视频播放器播放视频。这有不利的一面在于你无法自己囊中羞涩的球员,你无法控制它。一旦开始玩,你有没有对其进行控制,除了卸载页面。这个作品非常好,但是,是相当容易实现,但该视频将出现在舞台之上(这是不可以的显示列表
)。 - 在最后一个选项是使用
的StageVideo
。这将播放使用本机架构的视频,让您可以轻松播放H.264的和的将是硬件加速。此外,这只是一个NetStream的球员,所以你有完全的控制权。而最重要的是,它没有镀铬,因此您可以围绕在视频屏幕上播放。然而,像的StageWebView,是的StageVideo的不可以的显示列表
。但不同于的StageWebView,它直接呈现在舞台上,的在的一切。因此,应用程序本身将涵盖视频。你可以解决这个问题通过创建一个类来掩盖周围的视频你的应用程序,但它是非常困难的适当拉断。我花了大约12个小时就修复问题与遮蔽级以后创建我的StageVideo播放器和屏蔽类,加上又是半天以及如何处理DPI改变(提示:不要设置applicationDPI
如果你正在使用Flex)
- As VC.One said, you encode as FLV. Doing this is not good and I would not recommend it. FLV is not hardware accelerated (unless things have changed recently and I have not seen the updates) and will run entirely off the CPU meaning your app will run slowly and the app will eat battery much quicker than normal.
- Use
StageWebView
, in which case you just plug in the URL to the video and it will play the video using the native video player. This has the down side in that you cannot skint he player and you cannot control it. Once it begins playing, you have no control over it except for unloading the page. This works very well, however, and is fairly easy to implement, though the video will appear on top of the stage (it is not in theDisplay List
). - The last option is to use
StageVideo
. This will play videos using the native framework, so you can easily play h.264 and it will be hardware accelerated. Additionally, this is just a NetStream player so you have full control over it. And best yet, it has no chrome so you can build a player around the video screen. However, like StageWebView, StageVideo is not in theDisplay List
. But unlike StageWebView, it is rendered directly on the stage, below everything else. So the app itself will cover the video. You can get around this by creating a class to mask your app around the video, but it is incredibly difficult to properly pull off. It took me about 12 hours to create my StageVideo player and the masking class, plus another half day later on fixing issues with the masking class and how it handles DPI changes (hint: do NOT setapplicationDPI
if you are using Flex)
与往常一样,请确保您的AIR SDK是最新的也是如此。 3.5-3.7都加入了大量的新功能和错误修复iOS的应用程序,以便更新到AIR 3.7实际上可能解决或提出问题,您的问题更小(我不认为这会,但它始终是值得一试,对不对?)
As always, make sure your AIR SDK is up to date as well. 3.5-3.7 have all added a ton of new features and bug fixes for iOS applications so updating to AIR 3.7 might actually solve or make your issue less of a problem (I don't think it will, but it is always worth a shot, right?)
这篇关于NetStream的HTTP视频没有播放iOS设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!