當前位置: 首頁>>代碼示例>>Java>>正文


Java YouTubePlayer類代碼示例

本文整理匯總了Java中com.google.android.youtube.player.YouTubePlayer的典型用法代碼示例。如果您正苦於以下問題:Java YouTubePlayer類的具體用法?Java YouTubePlayer怎麽用?Java YouTubePlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


YouTubePlayer類屬於com.google.android.youtube.player包,在下文中一共展示了YouTubePlayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View v = inflater.inflate(R.layout.fragment_ayuda, container, false);

    videoView = (YouTubePlayerFragment) getActivity().getFragmentManager().findFragmentById(R.id.fragment_youtube);

    listener = new YouTubePlayer.OnInitializedListener() {
        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
            youTubePlayer.loadVideo(getString(R.string.fragment_ayuda_link_video));
            youTubePlayer.setShowFullscreenButton(false);
        }

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

        }
    };

    videoView.initialize(getString(R.string.fragment_ayuda_youtubekey), listener);

    return v;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:24,代碼來源:AyudaFragment.java

示例2: hidePresentation

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
/**
 * Hides the Presentation. Some UI components are also updated:
 * the video view is returned to its normal place on the primary display; the YouTube player
 * style is updated to the default; and an action item is updated to indicate the external
 * display is no longer in use.
 */
private void hidePresentation() {
    LOGD(TAG, "Hiding video presentation");
    View presentationView = mPresentation.getYouTubeFragmentView();
    ((ViewGroup) presentationView.getParent()).removeView(presentationView);
    mPlayerContainer.addView(presentationView);
    mPresentationControls.setVisibility(View.GONE);
    updatePresentationMenuItem(false);
    mPresentation.dismiss();
    mPresentation = null;
    if (mYouTubePlayer != null) {
        mYouTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
        mYouTubePlayer.play();
        setFullscreenFlags(false);
    }
}
 
開發者ID:TheDeltaProgram,項目名稱:iosched2013,代碼行數:22,代碼來源:SessionLivestreamActivity.java

示例3: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
                                    YouTubePlayer youTubePlayer, boolean wasRestored) {
    if (!wasRestored) {
        if (LOG) {
            Log.v(TAG, "trailerData " + trailerData);
        }
        if (trailerData != null && !trailerData.isEmpty()) {
            Uri uri = trailerData.get(0).getTrailerUri();

            if (LOG) {
                Log.v(TAG, "trailerData " + trailerData.size());
            }
            String trailerCode = uri.getQueryParameter("v");
            if (trailerCode != null) {
                this.youTubePlayer = youTubePlayer;
                youTubePlayer.cueVideo(trailerCode);
            }
        } else {
            getFragmentManager().beginTransaction().remove(youTubePlayerFragment).commit();
        }
    }
}
 
開發者ID:an-garcia,項目名稱:MovieGuide,代碼行數:24,代碼來源:TVShowActivity.java

示例4: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
    if (!_screenEnabled) {
        return;
    }

    if (!_youTubePlayerIsInitialized) {
        _youtubePlayer = player;

        _youtubePlayer.setPlayerStateChangeListener(_playerStateChangeListener);
        _youtubePlayer.setPlaybackEventListener(_playbackEventListener);

        _youTubePlayerIsInitialized = true;
    }

    if (!wasRestored) {
        startVideo(_youtubeId);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:20,代碼來源:CenterViewController.java

示例5: onStart

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onStart() {
    try {
        super.onStart();
        initializedListener = new YouTubePlayer.OnInitializedListener() {
            @Override
            public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult result) {

            }

            @Override
            public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
                if (!wasRestored && stream_link != null) {
                    player_reference = player;
                    player_reference.cueVideo(stream_link);
                } else if (wasRestored) {
                    player.seekToMillis(play_position);
                }
            }
        };
        init();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:wax911,項目名稱:anitrend-app,代碼行數:26,代碼來源:YoutubeFragment.java

示例6: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
    if (!_screenEnabled) {
        _logger.Debug("Screen is not enabled!");
        return;
    }

    if (!_youTubePlayerIsInitialized) {
        _youtubePlayer = player;

        _youtubePlayer.setPlayerStateChangeListener(_playerStateChangeListener);
        _youtubePlayer.setPlaybackEventListener(_playbackEventListener);

        _youTubePlayerIsInitialized = true;
    }

    if (!wasRestored) {
        startVideo(_youtubeId);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-MediaServer,代碼行數:21,代碼來源:CenterViewController.java

示例7: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
    if (null == player) return;
    mPlayer = player;

    displayCurrentTime();

    // Start buffering
    if (!wasRestored) {
        player.cueVideo(VIDEO_ID);
    }

    player.setPlayerStyle(PlayerStyle.CHROMELESS);
    mPlayButtonLayout.setVisibility(View.VISIBLE);

    // Add listeners to YouTubePlayer instance
    player.setPlayerStateChangeListener(mPlayerStateChangeListener);
    player.setPlaybackEventListener(mPlaybackEventListener);
}
 
開發者ID:StackTipsLab,項目名稱:YouTubePlayerView-Example,代碼行數:20,代碼來源:CustomPlayerControlActivity.java

示例8: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
    youTubePlayer.setOnFullscreenListener(this);
    if (!b) {
        videoId = getArguments().getString("video_id");
        if(skipToMillis==-1) {
            Log.v("LoadingVideo:"," "+videoId);
            youTubePlayer.loadVideo(videoId);
        }else{
            Log.v("CueingVideo:"," "+videoId);
            youTubePlayer.cueVideo(videoId,skipToMillis);
            Log.v("MillisToSeek:", " " + skipToMillis/1000);

        }
        this.youTubePlayer = youTubePlayer;
        youTubePlayer.setShowFullscreenButton(false);
        //youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
    }
}
 
開發者ID:muddassir235,項目名稱:Pop-Movies-Android-App,代碼行數:20,代碼來源:YoutubeTrailerFragment.java

示例9: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer player, boolean restored) {
    LogHelper.logMessage("onInitializationSuccess: " + restored + " videoId: " + videoId);
    this.player = player;
    player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
    player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
    player.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {

        @Override
        public void onFullscreen(boolean fullscreen) {
            YoutubeOverlayFragment.this.fullscreen = fullscreen;
        }
    });
    if (!restored && videoId != null) {
        player.loadVideo(videoId);
    }
}
 
開發者ID:jszczygiel,項目名稱:AndroidYoutubeOverlay,代碼行數:18,代碼來源:YoutubeOverlayFragment.java

示例10: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
    this.player = youTubePlayer;
    player.setOnFullscreenListener(this);
    player.setPlayerStateChangeListener(this);
    player.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION
            | YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI
            | YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE
            | YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);

    player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);

    if (!b)
        player.loadVideo(videoId);

}
 
開發者ID:slartus,項目名稱:4pdaClient-plus,代碼行數:17,代碼來源:YoutubeActivity.java

示例11: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored)
{
    if (Configuration.ORIENTATION_PORTRAIT == getResources().getConfiguration().orientation) {
        this.youTubePlayer = youTubePlayer;
        youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
        youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
        youTubePlayer.setShowFullscreenButton(false);
        youTubePlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener()
        {
            @Override
            public void onFullscreen(boolean b)
            {
                isFullscreen = b;
            }
        });
        if (mVideoId != null && !wasRestored) {
            youTubePlayer.loadVideo(mVideoId);
        }
        if (wasRestored) {
            youTubePlayer.seekToMillis(millis);
        }
    }
}
 
開發者ID:mcruncher,項目名稱:worshipsongs-android,代碼行數:25,代碼來源:CustomYoutubeBoxActivity.java

示例12: setupFullscreenListener

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
private void setupFullscreenListener() {
  if (mPlayer == null) {
    DUtils.log("mPlayer is null inside: " + DUtils.currentMethod());
    return;
  }

  mPlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {
    public void onFullscreen(boolean isFullscreen) {
      DUtils.log("setOnFullscreenListener: " + (isFullscreen ? "yes" : "no"));
      VideoPlayerFragment.this.mFullscreen = isFullscreen;

      mFragmentListener.onFullScreen(isFullscreen);
    }

  });
}
 
開發者ID:sgehrman,項目名稱:UTubeTV,代碼行數:17,代碼來源:VideoPlayerFragment.java

示例13: onCheckedChanged

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  int controlFlags = player.getFullscreenControlFlags();
  if (isChecked) {
    // If you use the FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE, your activity's normal UI
    // should never be laid out in landscape mode (since the video will be fullscreen whenever the
    // activity is in landscape orientation). Therefore you should set the activity's requested
    // orientation to portrait. Typically you would do this in your AndroidManifest.xml, we do it
    // programmatically here since this activity demos fullscreen behavior both with and without
    // this flag).
    setRequestedOrientation(PORTRAIT_ORIENTATION);
    controlFlags |= YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
  } else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    controlFlags &= ~YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
  }
  player.setFullscreenControlFlags(controlFlags);
}
 
開發者ID:youtube,項目名稱:yt-android-player,代碼行數:19,代碼來源:FullscreenDemoActivity.java

示例14: onError

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
	Log.e(LOG_TAG, "player error: " + errorReason);
	if (highlightImageView.getVisibility()==View.VISIBLE) {
		highlightImageView.startAnimation(fadeOutSlow);
	}
	currentVideoId = null;
	if (errorReason == YouTubePlayer.ErrorReason.UNEXPECTED_SERVICE_DISCONNECTION) {
		// player has encountered an unrecoverable error - stop the demo
		flipDelayHandler.removeCallbacksAndMessages(null);
		state = State.UNINITIALIZED;
		thumbnailLoader.release();
		thumbnailLoader = null;
		player = null;
	} else {
		state = State.VIDEO_ENDED;
	}
}
 
開發者ID:entertailion,項目名稱:Video-Wall,代碼行數:19,代碼來源:VideoWallActivity.java

示例15: onInitializationSuccess

import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
    player = youTubePlayer;
    youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
    youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
    youTubePlayer.setOnFullscreenListener(b -> isFullScreen = b);

    if (videoId != null && !wasRestored) {
        youTubePlayer.loadVideo(videoId);
    }

    if (wasRestored) {
        youTubePlayer.seekToMillis(videoTime);
    }
}
 
開發者ID:prakh25,項目名稱:MovieApp,代碼行數:16,代碼來源:TrailerActivity.java


注:本文中的com.google.android.youtube.player.YouTubePlayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。