Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.84k stars 819 forks source link

Texture.fromNetStream for Mobile issues #923

Closed nidiy closed 5 years ago

nidiy commented 7 years ago

In the use of Texture.fromNetStream mobile side to play video, only sound no image, the PC-side play normally. If you use flash.media.Video in the mobile side is also normal

vidClient = new Object();
vidClient.onMetaData = onMetaData;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.client = vidClient;

videoTexture=Texture.fromNetStream(ns,Starling.contentScaleFactor,onTextureComplete)
ns.play("http://192.168.100.49/XWTVIOS/2.flv");

// Play the video on the mobile side, and only the sound has no image
videoImage = new Image(videoTexture)
this.addChild(videoImage)

// If you use flash.media.Video in the mobile end of the normal
/*
var videos:Video = new Video(300, 200);
videos.attachNetStream(ns);
Starling.current.nativeStage.addChild(videos);
*/
nidiy commented 7 years ago

VideoTexture in the use of normal away3d

package away3d.textures 
{
    import away3d.materials.utils.IVideoPlayer;
    import away3d.materials.utils.SimpleVideoPlayer;
    import away3d.textures.Texture2DBase;
    import flash.display3D.Context3D;
    import flash.display3D.textures.TextureBase;
    import flash.display3D.textures.VideoTexture;
    import flash.events.Event;
    import flash.events.VideoTextureEvent;
    import flash.media.VideoStatus;
     public class NativeVideoTexture extends Texture2DBase 
     {
        private var texture:flash.display3D.textures.VideoTexture;
        private var _autoPlay:Boolean;
        private var _player:IVideoPlayer;

        public function NativeVideoTexture(source:String, loop:Boolean = true, autoPlay:Boolean = false, player:IVideoPlayer = null) 
        {
            try
            {
                _player = player || new SimpleVideoPlayer();
                _player.loop = loop;
                if (source != "")
                {
                    _player.source = source;
                }
                _autoPlay = autoPlay;
            }
            catch (e:Error)
            {
                trace(e, e.getStackTrace());
            }
        }
        override protected function uploadContent(texture:TextureBase):void 
        {

        }
        override protected function createTexture(context:Context3D):TextureBase
        {
            try
            {       
                if (!Context3D.supportsVideoTexture)
                {
                    throw new Error("flash.display3D.textures.VideoTexture not supported");
                    return null;
                }           
                texture = context.createVideoTexture();             
                texture.attachNetStream(_player.ns);
                texture.addEventListener(Event.TEXTURE_READY, onTextureReady);
                texture.addEventListener(VideoTextureEvent.RENDER_STATE, onRenderState);                
                if (_autoPlay) _player.play();
            }
            catch (e:Error)
            {
                trace(e, e.getStackTrace());
            }   
            return texture;
        }
        private function onTextureReady(e:Event):void
        {
            this.dispatchEvent(e.clone())
        }         
        private function onRenderState(e:VideoTextureEvent):void
        {
            if (e.status == VideoStatus.SOFTWARE)
            {
                trace("Indicates software video decoding works.")
            }
            if (e.status == VideoStatus.ACCELERATED)
            {
                trace("Indicates hardware-accelerated (GPU) video decoding works.")
            }
            if (e.status == VideoStatus.UNAVAILABLE)
            {
                trace("Indicates Video decoder is not available.")
            }
        }
        override public function dispose():void
        {
            if (_player) _player.dispose()
            if (texture) texture.dispose()
            super.dispose();
        }
        public function get player():IVideoPlayer 
        {
           return _player;
        }
    }
}
PrimaryFeather commented 7 years ago

With the second post, are you suggesting the same video works with Away3D on mobile?

RayGyoe commented 7 years ago

Android devices? AIR SDK videoTexture Fixed Bug,I have tried all versions, a more stable recommendation please air23.221。 Can also try : function onTextureComplete():void{ videoImage = new Image(videoTexture) this.addChild(videoImage) }

nidiy commented 7 years ago

@RayGyoe alright, thanks

varadig commented 7 years ago

I have a same issue, with rtmp vp6 video codec and speex sound codec. This is a live chat, which is worked on desktop (video/audio) but not on mobile (novideo/audio) I miss something, or this is not possible on mobile device?

PrimaryFeather commented 7 years ago

There's unfortunately not much information provided by Adobe about the supported video codecs — at least none that I'm aware of! I brought this topic up once when I talked to them, and was told that on mobile, the codec they recommend is h.264 with AAC audio encoding. That must work — everything else, I don't have confirmation.

PrimaryFeather commented 7 years ago

However, maybe you can ask that question in the Adobe AIR Community forum!

22Round commented 7 years ago

as I know Adobe has been fixed this bug in AIR 24

varadig commented 7 years ago

Can you link the note of this part of the AIR24 beta release? I really want to use stage3d video instead of native flash display list video. This is works with rtmp live stream, or just with stream from local/remote url?

PrimaryFeather commented 7 years ago

@varadig There are a few video-related fixes mentioned in the AIR 24 release notes (look for the changes around Oct 28, 2016). Is that what you meant, @22Round?

@hbinnet is your original question / the reason for opening up this issue now solved?

22Round commented 7 years ago

@PrimaryFeather yes, I read in release not and someone wrote that it fixed, but I haven't tested it yet. unconfirmed info!

bluelemonade commented 7 years ago

I have tis issue also on air 24 on iOS.

denmorgenshtern commented 6 years ago

Can confirm this issue still presents on air 30(!) on mobile.

Gratsonia commented 5 years ago

call videoImage.setRequiresRedraw() on enter frame solves this problem :)

AlexUrrutia commented 5 years ago

This bug is still on AIR 32, @nidiy can you tell me how did you solve it? I can't play live rtmp VP6 videos using Texture, thanks!

I tried setRequiresRedraw() as @Gratsonia suggested, but no luck, only audio plays