如何强制alpha混合在videoviewalpha、videoview

2023-09-07 11:33:26 作者:我病态见不得别人恩爱

我有一个Android应用程序,显示在它前面按钮的VideoView。在目标设备上的按钮在上面正常显示,直到(从另一项活动返回时为实例)的VideoView重绘自己。然后将按钮由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.

这不会发生在其他两个设备,而据我可以告诉在Android的这不是预期的行为。我相信这是与我看到抛出的设备上的错误。该标记是TIOverlay和文字

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'

有没有方法强制VideoView重新计算它的阿尔法?由于最初的观点是正确的我假设它重画只是没有考虑到的完整布局。

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.

这是我VideoView初始化code:

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();

修改

我使用的显示按钮在视频查看前面的布局是:

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>

推荐答案

我没有找到一个解决方案。看来,因为我切换回这个观点从其他意图相似VideoViews我需要使用暂停视频 VideoView.suspend()之前,我切换到另一个意图或回程从该意图这一个。我推测,这是因为硬件只有一个良好的硬件视频缓冲器,它保持了 VideoView 我刚刚留在缓冲区中。

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.