0

YouTube 播放器可以在没有透明面板的情况下播放视频,也可以全屏播放,透明面板中有一些图像,没什么特别的。如果我取出透明面板,YouTube 播放器会按需要工作,嵌入到应用程序中。如果我将透明面板添加到表单中,这是它不会播放但全屏播放的时候。视频开始,然后立即停止。我认为它与透明面板有关,但我不明白发生了什么。任何帮助或想法都会很棒。我的 java 文件没有改变,除了 initPopup 不存在。下面是缩短的 Java 文件版本。

XML 布局文件如下:

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

        <com.google.android.youtube.player.YouTubePlayerView
            android:id="@+id/youtube_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/spnrPSA" >
        </com.google.android.youtube.player.YouTubePlayerView>
    </RelativeLayout>

<com.TransparentPanel
    android:id="@+id/popup_window"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom"
    android:gravity="left"
    android:orientation="vertical"
    android:padding="1px" >

<com.TransparentPanel>

</RelativeLayout>

JAVA文件如下:

public final class PSA extends YouTubeFailureRecoveryActivity{
   private Animation animShow, animHide;

  private YouTubePlayer player;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.psa);
    initPopup();
    }


   private void initPopup() {

    final TransparentPanel popup = (TransparentPanel) findViewById(R.id.popup_window);

    //  Start out with the popup initially hidden.
    popup.setVisibility(View.GONE);

    if (PubVars.ScreenOrientation==0){
        animShow = AnimationUtils.loadAnimation( this, R.anim.popup_show);
        animHide = AnimationUtils.loadAnimation( this, R.anim.popup_hide);
    }      

     if (PubVars.ScreenOrientation==1){
         animShow = AnimationUtils.loadAnimation( this, R.anim.l_popup_show);
         animHide = AnimationUtils.loadAnimation( this, R.anim.l_popup_hide);
     }
    //animShow = AnimationUtils.loadAnimation( this, R.anim.popup_show);
    //animHide = AnimationUtils.loadAnimation( this, R.anim.popup_hide);

    final ImageView   showButton = (ImageView) findViewById(R.id.show_popup_button);
    final ImageView   hideButton = (ImageView) findViewById(R.id.hide_popup_button);
    showButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            popup.setVisibility(View.VISIBLE);
            popup.startAnimation( animShow );
            showButton.setEnabled(false);
            hideButton.setEnabled(true);
    }});

    hideButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            popup.startAnimation( animHide );
            showButton.setEnabled(true);
            hideButton.setEnabled(false);
            popup.setVisibility(View.GONE);
    }});

     }


 }

我一定错过了一些简单的东西。在此先感谢,我对android还很陌生。

4

2 回答 2

1

Youtube Player View 不授权覆盖。即使它是一个透明的 Layout(Relative, frame, ..)。播放器停止视频并登录到 logcat 一些有用的信息。但这种情况被报道为“youtubeplayer被完全覆盖”。

于 2013-12-09T15:58:08.333 回答
0

此 api 不允许任何人对此进行分层。“布局是问题”我建议您使用层次结构视图在您的布局中查看这一点。我有很多问题,因为我的布局比玩家多一点。

于 2013-12-09T15:58:02.483 回答