Skip to content

Cast Mini Controller #8

@lochstar

Description

@lochstar

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();
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions