How to force alpha blending on a videoview

孤街浪徒 提交于 2019-12-10 16:57:39

问题


I have an android app that displays a VideoView with buttons in front of it. On the target device the buttons display on top properly until the VideoView redraws itself (for instance when returning from another activity). Then the buttons are hidden by the VideoView.

This does not occur on two other devices, and as far as I can tell this is not expected behavior in Android. I believe it has to do with an error I see thrown on the device. The tag is 'TIOverlay' and the text is

'static void overlay_control_context_t::overlay_destroyOverlay( overlay_control_device_t*, overlay_t*) : Lets Switch off Alpha Blending'

Is there any method to force the VideoView to recalculate it's alpha? Since the initial view is correct I assume it's just not taking into account the full layout when redrawing.

This is my VideoView initialization code:

    //set up video
    this.videoView = (VideoView) findViewById(R.id.introVideoView);
    videoView.setZOrderOnTop(false);


    //create intro movie and begin playing
    String uri = "android.resource://"+getPackageName()+"/"+R.raw.movie;
    videoView.setVideoURI(Uri.parse(uri));
    //set to looping
    videoView.setOnPreparedListener(new OnPreparedListener(){

    @Override
    public void onPrepared(MediaPlayer mp)
    {
    mp.setLooping(true);
    }});
    videoView.start();

Edit

The layout I'm using to display the buttons in front of the video view is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainLayout" >

<VideoView
    android:id="@+id/introVideoView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

<ImageButton
    android:id="@+id/exitDemoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:contentDescription="Exit Demo >>"
    android:onClick="exitDemo"
    android:background="#00000000"
    android:src="@drawable/exit_selector" />


<LinearLayout
    android:id="@+id/buttonLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:orientation="horizontal" >
 <ImageButton
        android:id="@+id/resumeVideoButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onResumeClicked"
        android:contentDescription="Resume Video"
        android:background="#00000000"
        android:src="@drawable/resume_selector" />
    <ImageButton
        android:id="@+id/guidedTourButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onTourClicked"
        android:contentDescription="Guided Tour"
        android:background="#00000000"
        android:src="@drawable/tour_selector" />   
</LinearLayout>


回答1:


I did find a solution. It appears because I was switching back into this view from other intents with similar VideoViews I needed to suspend the video using VideoView.suspend() before I switched to another intent or back from that intent to this one. I speculate this is because the hardware only had one good hardware video buffer and it kept the VideoView I had just left in the buffer.



来源:https://stackoverflow.com/questions/9642401/how-to-force-alpha-blending-on-a-videoview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!