播放视频可在模拟器上运行,但不适用于ipad(2)

时间:2011-07-23 10:29:51

标签: flex ipad video air flex-mobile

我一直在尝试播放使用http://www.mirovideoconverter.com/转换为mp4文件的视频,它在模拟器上很好,但在ipad上我看不到视频。

我该如何解决?

附加视频代码:

    package com.view.generic
{


import com.constants.Dimentions;

    import com.view.AbstractScreen;
    import com.view.IScreen;
    import com.view.gui.Btn;

    import flash.errors.IOError;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.events.NetStatusEvent;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;

    import org.osflash.signals.natives.NativeSignal;

    public class VideoMode extends AbstractScreen implements IScreen
    {
        private var _player:Video;
        private var _stream:NetStream;
        public function VideoMode()
        {

        }
        override public function start():void{
            super.start();
            var conn:NetConnection = new NetConnection();
            conn.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler)
            conn.addEventListener(IOErrorEvent.NETWORK_ERROR, netStatusError)
            conn.connect(null);
            layoutPlayer();
            layoutMenu();

        }

        override public function stop():void{
            _stream.pause();
        }



        private function layoutMenu():void{
            var playBtn:Btn = new Btn("video_play_button.png");
            addChild(playBtn);
            playBtn.x = (Dimentions.HEIGHT -playBtn.width)/2;
            playBtn.y = _player.y+_player.height+20;
            var clickSignal:NativeSignal = new NativeSignal(playBtn,MouseEvent.CLICK);
            clickSignal.add(play);

            var fullScrBtn:Btn = new Btn("full_screen.png");
            addChild(fullScrBtn);
            fullScrBtn.x = _player.width -fullScrBtn.width+_player.x;;
            fullScrBtn.y = _player.y+_player.height+20;
            var fullScrSignal:NativeSignal = new NativeSignal(fullScrBtn,MouseEvent.CLICK);
            fullScrSignal.add(goFullScreen);
        }

        private function layoutPlayer():void{
            _player.width = 400;
            _player.height = 300;
            _player.x = (Dimentions.HEIGHT -_player.width)/2;
            _player.y = 200;
            _stream.play("../../../assets/drum_ny.flv");
            _stream.pause();

        }

        private function goFullScreen(e:MouseEvent):void{
            if(_player.x == 0){
                layoutPlayer()
            }else{
                _player.x = 0;
                _player.y = 0;
                _player.width = stage.fullScreenWidth;
                _player.height = stage.fullScreenHeight;
            }

        }
        private function play(e:MouseEvent):void{
            _stream.resume()
        }

        private function netStatusHandler(e:NetStatusEvent):void{
            if(e.info.code=="NetConnection.Connect.Success"){
                _stream = new NetStream(NetConnection(e.target));
                _stream.client = this;
                _player = new Video();
                addChild(_player);

                _player.attachNetStream(_stream)

            }
        }
        private function netStatusError(e:IOError):void{
            trace(e)
        }

        override public function destroy():void{

        }
        public function onMetaData(info:Object):void {

        }

    }
}

谢谢!

2 个答案:

答案 0 :(得分:2)

这可能是你的问题:

 _stream.play("../../../assets/drum_ny.flv");

将应用程序编译为.ipa文件后,该文件不存在。尝试将其更改为您可以上传到的某个地方的网址,如果有效,那就是您的问题。

答案 1 :(得分:-2)

通过替换FLV文件解决了这个问题,但是我仍然不确定为什么一个flv文件有效而另一个没有。

如果遇到这样的问题(视频在模拟器上运行但在设备上没有),您的第一个赌注应该是替换视频源。