本文整理了Java中com.flipkart.youtubeview.YouTubePlayerView
类的一些代码示例,展示了YouTubePlayerView
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YouTubePlayerView
类的具体详情如下:
包路径:com.flipkart.youtubeview.YouTubePlayerView
类名称:YouTubePlayerView
暂无
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
private void handleBindPlayer() {
switch (playerType) {
case YouTubePlayerType.WEB_VIEW:
attachPlayer(false);
break;
case YouTubePlayerType.STRICT_NATIVE:
bindPlayer(false);
break;
case YouTubePlayerType.AUTO:
case YouTubePlayerType.INVALID_VIEW:
default:
bindPlayer(true);
break;
}
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
public YouTubePlayerView(Context context) {
super(context);
init(context);
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int newWidth;
int newHeight;
newWidth = getMeasuredWidth();
newHeight = (int) (newWidth * ASPECT_RATIO);
setMeasuredDimension(newWidth, newHeight);
if (playerContainer != null && playerContainer.getMeasuredHeight() != newHeight) {
ViewGroup.LayoutParams layoutParams = playerContainer.getLayoutParams();
layoutParams.height = newHeight;
playerContainer.setLayoutParams(layoutParams);
String url = "https://img.youtube.com/vi/" + videoId + "/0.jpg";
if (null != imageLoader) {
imageLoader.loadImage(thumbnailImageView, url, getMeasuredHeight(), getMeasuredWidth());
}
}
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
private void bindPlayer(boolean auto) {
if (!ServiceUtil.isYouTubeServiceAvailable(getContext())) {
if (!auto && listener != null) {
listener.onNativeNotSupported();
} else {
attachPlayer(false);
}
} else {
attachPlayer(true);
}
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
private void init(@NonNull Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
View itemView = inflater.inflate(R.layout.video_container, this, false);
this.addView(itemView);
playerContainer = itemView.findViewById(R.id.youtubeFragmentContainer);
playerContainer.setId(0);
thumbnailImageView = itemView.findViewById(R.id.video_thumbnail_image);
playIcon = itemView.findViewById(R.id.play_btn);
ProgressBar progressBar = itemView.findViewById(R.id.recycler_progressbar);
// For else case there is a layout defined for v21 and above
if (progressBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
int color;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
color = context.getResources().getColor(R.color.default_progress_bar_color, null);
} else {
color = context.getResources().getColor(R.color.default_progress_bar_color);
}
progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}
setListeners();
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
public void unbindPlayer() {
if (playerContainer.getId() == R.id.youtubeFragmentContainer) {
removeCurrentYouTubeFragment();
}
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
@Override
public void onBindViewHolder(@NonNull final YouTubePlayerViewHolder holder, int position) {
YouTubePlayerView playerView = holder.playerView;
String videoId = videoIds.get(position);
playerView.initPlayer(Constants.API_KEY, videoId, "https://cdn.rawgit.com/flipkart-incubator/inline-youtube-view/60bae1a1/youtube-android/youtube_iframe_player.html", playerType, null, fragment, imageLoader);
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
private void attachPlayer(boolean isNative) {
if (playerContainer.getId() != R.id.youtubeFragmentContainer) {
YouTubeBaseFragment currentYouTubeFragment = removeCurrentYouTubeFragment();
playerContainer.setId(R.id.youtubeFragmentContainer);
YouTubeBaseFragment youtubePlayerFragment;
if (isNative) {
youtubePlayerFragment = YouTubeFragment.newInstance(key, videoId);
} else {
YouTubeWebViewFragment webViewFragment = YouTubeWebViewFragment.newInstance(webViewUrl, videoId);
if (currentYouTubeFragment instanceof YouTubeWebViewFragment) {
webViewFragment.setWebView(((YouTubeWebViewFragment) currentYouTubeFragment).removeWebView());
}
youtubePlayerFragment = webViewFragment;
}
youtubePlayerFragment.setYouTubeEventListener(listener);
this.fragment.getChildFragmentManager().beginTransaction().add(R.id.youtubeFragmentContainer, (Fragment) youtubePlayerFragment, TAG)
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
.commit();
}
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
public YouTubePlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
代码示例来源:origin: flipkart-incubator/android-inline-youtube-view
public YouTubePlayerView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
内容来源于网络,如有侵权,请联系作者删除!