简体   繁体   中英

How to force alpha blending on a videoview

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> 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM