Note that there are some explanatory texts on larger screens.

plurals
  1. POCan VideoView be detach and reattached without stopping the stream?
    primarykey
    data
    text
    <p>I'm building an app where the user clicks on a button to show a video full screen. Initially the video is attached to a view inside a ViewPager. To be able to show it fullscreen I detach it from its parent and reattach it to the root view. This works fine, except when the video is switched to fullscreen while playing. When I detach a playing VideoView it just stop and I need to restart it. This is not acceptable since the video starts buffering before resume. Here the part of the code where the detach is done:</p> <pre><code> final ViewGroup parent = (ViewGroup) findViewById(R.id.parent); final ViewGroup root = (ViewGroup) findViewById(R.id.root); Button b = (Button) findViewById(R.id.button); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { parent.removeView(mVideoView); LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); root.addView(mVideoView, lp); } }); </code></pre> <p>Depending of the device, I have a different log error. Probably because the actual video player is provided by the manufacturer and not the Android SDK. Here are the error logs for a Nexus 7:</p> <pre><code>10-30 20:26:18.618: D/NvOsDebugPrintf(124): NvMMDecTVMRDestroyParser Begin 10-30 20:26:18.618: D/NvOsDebugPrintf(124): --------- Closing TVMR Frame Delivery Thread ------------- 10-30 20:26:18.678: D/NvOsDebugPrintf(124): ------- NvAvpClose ------- 10-30 20:26:18.678: D/NvOsDebugPrintf(124): NvMMDecTVMRDestroyParser Done 10-30 20:26:18.678: D/NvOsDebugPrintf(124): NvMMLiteTVMRDecPrivateClose Done </code></pre> <p>I haven't been able to detach the video without stopping it. I tried using SurfaceView or TextureView without success. </p> <p>I also tried finding a third party video player. I found a commercial one (<a href="http://www.vitamio.org/" rel="nofollow">http://www.vitamio.org/</a>) that I can't really use for business reason. I found an open source one, that hasn't been updated in the last year (<a href="https://code.google.com/p/dolphin-player/" rel="nofollow">https://code.google.com/p/dolphin-player/</a>).</p> <p>I'm currently targeting Android 4.2 or better on tablet only.</p> <hr> <h2>Note that the ViewPager is not fullscreen. So I can't use LayoutParams to make the video fullscreen. I need to remove the VideoView from the parent in the ViewPager and add it to the root view to be able to show it fullscreen.</h2> <p>The URL I'm testing with: <a href="http://bellvps1.cpl.delvenetworks.com/media/e1b3e24ecb944abd8f4ed823a0b76ddc/68f78d35296243bfb46d2418f03f2fd0/bande-annonce---the-secret-life-of-walter-mitty-1-9efcc5c6e52ac07a3edf84a1b21967995b7796a2.m3u8" rel="nofollow">http://bellvps1.cpl.delvenetworks.com/media/e1b3e24ecb944abd8f4ed823a0b76ddc/68f78d35296243bfb46d2418f03f2fd0/bande-annonce---the-secret-life-of-walter-mitty-1-9efcc5c6e52ac07a3edf84a1b21967995b7796a2.m3u8</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload