Last active
June 7, 2023 13:48
-
-
Save medyo/f226b967213c3b8ec6f6bebb5338a492 to your computer and use it in GitHub Desktop.
Solution: YouTubePlayerSupportFragment that supports androidx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.google.android.youtube.player; | |
/** | |
* Please create this directories schema com.google.android.youtube.player and post the file there | |
*/ | |
import android.os.Bundle; | |
import android.util.AttributeSet; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import androidx.fragment.app.Fragment; | |
import androidx.fragment.app.FragmentActivity; | |
import com.google.android.youtube.player.internal.ab; | |
public class YouTubePlayerSupportFragmentX extends Fragment implements YouTubePlayer.Provider { | |
private final YouTubePlayerSupportFragmentX.a a = new YouTubePlayerSupportFragmentX.a(); | |
private Bundle b; | |
private YouTubePlayerView c; | |
private String d; | |
private YouTubePlayer.OnInitializedListener e; | |
private boolean f; | |
public static YouTubePlayerSupportFragmentX newInstance() { | |
return new YouTubePlayerSupportFragmentX(); | |
} | |
public YouTubePlayerSupportFragmentX() { | |
} | |
public void initialize(String var1, YouTubePlayer.OnInitializedListener var2) { | |
this.d = ab.a(var1, "Developer key cannot be null or empty"); | |
this.e = var2; | |
this.a(); | |
} | |
private void a() { | |
if (this.c != null && this.e != null) { | |
this.c.a(this.f); | |
this.c.a(this.getActivity(), this, this.d, this.e, this.b); | |
this.b = null; | |
this.e = null; | |
} | |
} | |
public void onCreate(Bundle var1) { | |
super.onCreate(var1); | |
this.b = var1 != null ? var1.getBundle("YouTubePlayerSupportFragment.KEY_PLAYER_VIEW_STATE") : null; | |
} | |
public View onCreateView(LayoutInflater var1, ViewGroup var2, Bundle var3) { | |
this.c = new YouTubePlayerView(this.getActivity(), (AttributeSet)null, 0, this.a); | |
this.a(); | |
return this.c; | |
} | |
public void onStart() { | |
super.onStart(); | |
this.c.a(); | |
} | |
public void onResume() { | |
super.onResume(); | |
this.c.b(); | |
} | |
public void onPause() { | |
this.c.c(); | |
super.onPause(); | |
} | |
public void onSaveInstanceState(Bundle var1) { | |
super.onSaveInstanceState(var1); | |
Bundle var2 = this.c != null ? this.c.e() : this.b; | |
var1.putBundle("YouTubePlayerSupportFragment.KEY_PLAYER_VIEW_STATE", var2); | |
} | |
public void onStop() { | |
this.c.d(); | |
super.onStop(); | |
} | |
public void onDestroyView() { | |
this.c.c(this.getActivity().isFinishing()); | |
this.c = null; | |
super.onDestroyView(); | |
} | |
public void onDestroy() { | |
if (this.c != null) { | |
FragmentActivity var1 = this.getActivity(); | |
this.c.b(var1 == null || var1.isFinishing()); | |
} | |
super.onDestroy(); | |
} | |
private final class a implements YouTubePlayerView.b { | |
private a() { | |
} | |
public final void a(YouTubePlayerView var1, String var2, YouTubePlayer.OnInitializedListener var3) { | |
YouTubePlayerSupportFragmentX.this.initialize(var2, YouTubePlayerSupportFragmentX.this.e); | |
} | |
public final void a(YouTubePlayerView var1) { | |
} | |
} | |
} |
when I tried to move com.google.android.youtube.player... to java/main folder, it give me alert that com is already exist
Any Solution for Android 13, as this solution is not working on android 13
Any Solution for Android 13, as this solution is not working on android 13
"An error occurred while initializing the YouTube Player"
Any Solution for Android 13, as this solution is not working on android 13
"An error occurred while initializing the YouTube Player"
Getting above mentioned error on Android 13
Does anybody know removing youtube branding image from the Player?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks buddy!