状态栏和YoutubeAndroidPlayerAPI

时间:2013-12-03 11:55:00

标签: android youtube android-youtube-api

我将我的应用程序设计为以全屏模式工作。没有状态栏和操作栏可见。这假设是一个问题,因为每次加载来自youtube的视频都会显示YoutubeAndroidPlayerAPI的状态栏。

我在片段中有一个viewpager,可以加载youtube缩略图。每次按下缩略图时,我都会使用以下代码调用youtubePlayerView.initialize:

@Override
    public Object instantiateItem(ViewGroup container, int position) {

        LayoutInflater inflater = (LayoutInflater) container.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.youtubeitem, null);

         ImageView imageView = (ImageView) view.findViewById(R.id.youThumbail);
         imageView.setTag(position);
         imageView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {

                    mContainerThumbs.setVisibility(View.GONE);
                    youtubePlayerView.bringToFront();
                    playerContainer.setVisibility(View.VISIBLE);
                    youtubePlayerView.setTag(campaign.getVideos().get(Integer.parseInt(v.getTag().toString())));
                    youtubePlayerView.initialize(act.getResources().getString(R.string.youKEY), new OnInitializedListener(){

                        @Override
                        public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) {

                            Log.e("fail","fail");
                        }

                        @Override
                        public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1, boolean arg2) {

                            youtubePlayer = arg1;
                            arg1.loadVideo(campaign.getVideos().get(Integer.parseInt(v.getTag().toString())));
                        }
                    });
                }
            });
         imageLoader.displayImage("http://img.youtube.com/vi/"+campaign.getVideos().get(position)+"/hqdefault.jpg", imageView, options, animateFirstListener);

         ((ViewPager) container).addView(view, 0);
         return view;
    }

我之前说过的问题是应用程序以全屏模式显示,但每当我按下一个缩略图(即触发了ImageView的OnClickListener)时,就会显示状态栏。任何帮助将不胜感激。在此先感谢=)

2 个答案:

答案 0 :(得分:2)

好吧,初始化后设置标志YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION似乎解决了问题=)

...
@Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1, boolean arg2) {
    youtubePlayer = arg1;
    youtubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
    arg1.loadVideo(campaign.getVideos().get(Integer.parseInt(v.getTag().toString())));
    ...

答案 1 :(得分:0)

在我的情况下,我必须重置onInitializationSuccess中的所有标志,从不显示状态栏:

player.setFullscreenControlFlags(-1);