nativescript-cast
nativescript-cast copied to clipboard
Cast Mini Controller
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 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 IIRC I never could get this to work on Android. Spent ages trying.
I have someone help me get it working on Android now. Do you have iOS version working by any chance?
Just the code I pasted above.