在YouTube活动中显示操作栏

时间:2016-04-18 10:42:13

标签: android youtube android-youtube-api

我使用youtube api并使用xml

中的以下标记播放youtube视频
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.aspire.urdu.toddlers.poems.VideoListingActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/action_bar" />
 <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtubeplayerview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:hardwareAccelerated="true" />
</LinearLayout>

我在活动中使用此代码。

public class VideoPlayerActivity extends YouTubeBaseActivity{

    YouTubePlayer YTplayer;
    YouTubePlayerView youTubePlayerView;
    private String videoLink = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_player);

        videoLink = getIntent().getStringExtra("link");
        youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);
        youTubePlayerView.initialize(getResources().getString(R.string.you_tube_api_key), new YouTubePlayer.OnInitializedListener() {
            @Override
            public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                YTplayer = youTubePlayer;
                YTplayer.setShowFullscreenButton(false);
                YTplayer.loadVideo(videoLink);
            }

            @Override
            public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

                Toast.makeText(getApplicationContext(), ""+youTubeInitializationResult.name(), Toast.LENGTH_LONG).show();
            }
        });
    }
}

但是当视频播放时,它会全屏显示..

我需要什么

我只需要启用后退按钮显示操作谢谢。

0 个答案:

没有答案