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还很陌生。