具體問題就是秘通,只有聲音,但是沒有畫面敛熬。據(jù)詳細(xì)測(cè)試肺稀,發(fā)現(xiàn)圖像只在父類布局的底部顯示,但是只顯示一半应民,我擦擦话原,瞬間死了的心都有了。Now瑞妇,Copy你的代碼新建Demo稿静,Ok,又沒問題了辕狰,但是項(xiàng)目中就是有問題改备。。蔓倍。
國(guó)內(nèi)論壇千篇一律悬钳,只管BB不講實(shí)際,沒法偶翅,只有上老外的網(wǎng)站默勾,找到應(yīng)該是提問問題質(zhì)量最高的網(wǎng)站-stackoverflow(沒有之一),搜索關(guān)鍵字"videoview only audio"聚谁,出來結(jié)果找到下面的代碼:
videoView.setZOrderOnTop(true);
this will set the videoview to the top layer; In other words: block everything under it.
然后測(cè)試母剥,完美解決。下面還有回答形导,代碼如下:
video_view = (VideoView)findViewById(R.id.video_view);
video_view.setZOrderMediaOverlay(true);
video_view.setVideoPath("/sdcard/myvideo.mp4");
video_view.setMediaController(new MediaController(this));
video_view.start();
video_view.videoView.setZOrderOnTop(true);
核心還是setZOrderMediaOverlay(true)环疼、setZOrderOnTop(true)
SurfaceView的源碼,源碼的這個(gè)方法setZOrderMediaOverlay(boolean isMediaOverlay)朵耕,源碼中對(duì)這個(gè)方法的描述:
Control whether the surface view‘s surface is placed on top of another regular surface view in the window (but still behind the window itself).This is typically used to place overlays on top of an underlying media surface view.
Note that this must be set before the surface view‘s containing window is attached to the window manager.
Calling this overrides any previous call to {@link #setZOrderOnTop}.
大概的意思就是說控制窗口中表面的視圖層是否放置在常規(guī)視圖層的頂部炫隶。
上面說的那么多,意思就是是不是將SurfaceView放在頂部阎曹?畢竟ViewDeoView繼承自SurfaceView伪阶,顯示在頂部沒毛病。具體的可以自行g(shù)oogle处嫌,剩下的也不懂太多了栅贴。