Funny Solution to play YouTubePlayerView on Customized Fragment

Why we need

Conclusion and Utils Sample

Code Tracing

YouTubePlayerView(Context var1, AttributeSet var2, int var3, YouTubePlayerView.b var4) { 
super((Context)ab.a(var1, “context cannot be null”), var2, var3);
this.c = (YouTubePlayerView.b)ab.a(var4, “listener cannot be null”);
public class YouTubeBaseActivity extends Activity {                               
private YouTubeBaseActivity.a a;

protected void onStart() {
if (this.b != null) { this.b.a(); }
protected void onResume() {
if (this.b != null) { this.b.b(); }
YouTubePlayerFragment youTubePlayerFragment = getFragmentManager().findFragmentById(;youTubePlayerFragment.initialize(DeveloperKey.DEVELOPER_KEY, this);
if (this.c != null && this.e != null) {
this.c.a(this.getActivity(), this, this.d, this.e, this.b);
final void a(final Activity var1, Provider var2, String var3, OnInitializedListener var4, Bundle var5) { ... }
  1. Activity
  2. Provider: Good luck again, YouTubePlayerView implements Provider
  3. String: this is YouTube Developer Key
  4. OnInitializedListener
  5. Bundle: the YoutubePlayerView’s player view state.
public void onSaveInstanceState(Bundle var1) {
Bundle var2 = this.c != null ? this.c.e() : this.b;
final Bundle e() {
return this.e == null ? this.i : this.e.h();




Lead Android & iOS Mobile Engineer at Yahoo (Verizon Media) Taiwan

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bram Yeh

Bram Yeh

Lead Android & iOS Mobile Engineer at Yahoo (Verizon Media) Taiwan

More from Medium

Kickstarting Ads Kit by integrating Interstitial Ads in Application (Kotlin)

Beginner Overview on Hilt keywords

Android Spotless Easy Setup

Android Service : Bound Service