nativescript-cast icon indicating copy to clipboard operation
nativescript-cast copied to clipboard

Cast Mini Controller

Open lochstar opened this issue 5 years ago • 4 comments

The current iOS work in progress. Visibilty of the Controller needs to be handled. Doesn't work unless added to a layout, which is why I've created a new StackLayout in createNativeView().

export class CastMiniController extends CastMiniControllerBase {
  nativeView: any;

  constructor() {
    super();
  }

  public createNativeView(): Object {
    const stackLayout = new StackLayout();
    return stackLayout.ios;
  }

  /**
   * Initializes properties/listeners of the native view.
   */
  initNativeView(): void {
    // Attach the owner to nativeView.
    // When nativeView is tapped we get the owning JS object through this field.
    (<any>this.nativeView).owner = this;

    super.initNativeView();
  }

  /**
   * Clean up references to the native view and resets nativeView to its original state.
   * If you have changed nativeView in some other way except through setNative callbacks
   * you have a chance here to revert it back to its original state
   * so that it could be reused later.
   */
  disposeNativeView(): void {
    // Remove reference from native listener to this instance.
    (<any>this.nativeView).owner = null;

    // If you want to recycle nativeView and have modified the nativeView
    // without using Property or CssProperty (e.g. outside our property system - 'setNative' callbacks)
    // you have to reset it to its initial state here.
    super.disposeNativeView();
  }

  onLoaded(): void {
    const mCastContext = GCKCastContext.sharedInstance();
    const miniController = mCastContext.createMiniMediaControlsViewController();
    this.nativeView.addSubview(miniController.view);
    super.onLoaded();
  }
}

lochstar avatar May 28 '19 04:05 lochstar

@lochstar did you manage to make the mini controller work? I am using this plugin and hoping to add the mini controller in my app.

promptdigital avatar Mar 09 '24 16:03 promptdigital

@promptdigital IIRC I never could get this to work on Android. Spent ages trying.

lochstar avatar Mar 10 '24 23:03 lochstar

I have someone help me get it working on Android now. Do you have iOS version working by any chance?

promptdigital avatar Mar 11 '24 13:03 promptdigital

Just the code I pasted above.

lochstar avatar Mar 12 '24 00:03 lochstar