平板电脑上播放视频而不会出现断断续续的情况

平板电脑上播放视频而不会出现断断续续的情况

本文介绍了如何使用 adobe air mobile 在 android 平板电脑上播放视频而不会出现断断续续的情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个可以在 Android 平板电脑上播放视频的应用.该平板电脑是一款运行 Android 4.0.3 版的 Transformer Prime.我正在使用 Flash Builder 4.6 和 Flex 4.6.0.每次我向平板电脑添加视频时,它都非常断断续续和跳动.如果我尝试使用任何不是 flv 的视频,那么该视频将始终发送到所有其他内容后面的背景中,并且不再保留在放置它的容器中.我创建了一个可以向左或向右移动的滑动容器,视频也随之移动,它适用于 flv 文件,但不适用于任何其他文件格式(例如 H.264 和 f4v),它停留在 x = 0 和 y 阶段= 0 不是组 x = 0 和 y = 0 并且不移动.每当播放视频时,总会有一个屏幕闪烁,然后播放视频.Flv 文件总是最不适合播放.抱歉,我不是在胡说八道,我只是想获取导入的信息
这是我创建的视频播放组的代码.

I am trying to build a app that will play videos on a Android tablet. The tablet is a transformer prime running a Android version 4.0.3. I am using flash Builder 4.6 with Flex 4.6.0. Every time i add a video to the tablet, it is very choppy and jumpy. If i try and use any video that is not flv then the video is always sent to the background behind all the other content and no longer stays with the container that it is placed into. I created a sliding containers that can be moved left or right and the video moves with them and it works with flv files but not with any other file formats (such as H.264 and f4v) it stays at the stage x = 0 and y = 0 not the group x = 0 and y = 0 and does not move. When ever a video is played there is always a screen flickers and then the video plays. Flv files are always the worst for playing back. Sorry I'm not trying to ramble I'm just trying to get the imported information
Here is the code for the video playing group that i created.

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
     xmlns:s="library://ns.adobe.com/flex/spark" width="960" height="533" xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
    <![CDATA[
        import mx.events.EffectEvent;
        [Bindable] public var imgSource:String = new String();
        [Bindable] public var isThereAVideo:Boolean = new Boolean()
        public var movieSource:String = new String();
        [Bindable] protected var bytes:uint = new uint();
        [Bindable] protected var bytesTotel:uint = new uint();

        protected function playMovieClick(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            trace ("you clicked")
            var nc:NetConnection = new NetConnection();
            nc.connect(null);
            var ns:NetStream = new NetStream(nc);
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
            ns.client={ onMetaData:function(obj:Object):void{} }
            ns.play(movieSource);
            var myVideo:Video = new Video();
            myVideo.width = 960;
            myVideo.height = 533;
            myVideo.attachNetStream(ns);
            uic.addChild(myVideo);
            ns.addEventListener(NetStatusEvent.NET_STATUS, netstatusHandler);
            quickfade.target = uic;
            quickfade.alphaFrom = 0;
            quickfade.alphaTo = 1;
            quickfade.play();
            ns.soundTransform.volume = 0;


        }


        public function netstatusHandler(evt:NetStatusEvent):void {
            if (evt.info.code == "NetStream.Play.Stop") {
                quickfade.target = uic;
                quickfade.alphaTo = 0;
                quickfade.alphaFrom = 1;
                quickfade.play();
                quickfade.addEventListener(EffectEvent.EFFECT_END, fadeEffectEnd);
            }
        }

        private function fadeEffectEnd(event:EffectEvent):void {
            trace("effect ending");
            uic.visible = false;
            trace("....effect ending");
            quickfade.removeEventListener(EffectEvent.EFFECT_END, fadeEffectEnd);
        }

        public function asyncErrorHandler(event:AsyncErrorEvent):void {
            trace(event.text);
        }
    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <s:Fade id="quickfade" duration="1500" />
</fx:Declarations>
<s:Image width="100%" height="100%" source="{imgSource}"/>
<s:Image width="75" height="75" bottom="5" right="5" source="img/videoIcon.png" click="playMovieClick(event)" visible="{isThereAVideo}" />
<mx:UIComponent x="0" y="0" id="uic" width="960" height="533" alpha="0" />
<s:Label x="10" y="508" text="v0.1"/>

这是我的问题
有没有更好的方法来播放这个视频,让它更流畅?我听说过 stage.stagevideo 但如果我跟踪 stage.stagevideo.length 我总是得到 0?
为什么视频丢失了容器.它与使用舞台宽度设置容器位置有什么关系吗?
有没有办法缓冲视频?

So here is my question questions
Is there a better way to play this video so that it is smoother? I have heard about stage.stagevideo but if i trace stage.stagevideo.length i always get 0?
Why does the video lose the container. Could it have anything to do with having the container location set by using stage width?
Is there a way to buffer the video?

推荐答案

播放视频的最佳方式是使用原生播放器而不是 flex 视频播放器.您仍然需要在 flex 内播放,然后您可以尝试 Stage Video (http://www.adobe.com/devnet/flashplayer/articles/stage_video.html),因为移动设备上的 flex 会跳过视频的帧.

The best way to play video to use native player instead of flex video player. Still you need to play inside the flex then you can try Stage Video (http://www.adobe.com/devnet/flashplayer/articles/stage_video.html) because flex on mobile does skip the frame of the video.

这篇关于如何使用 adobe air mobile 在 android 平板电脑上播放视频而不会出现断断续续的情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 15:01