ios-inline-media-controls.js [plain text]
class IOSInlineMediaControls extends MediaControls
{
constructor(options = {})
{
options.layoutTraits = LayoutTraits.iOS;
super(options);
this.element.classList.add("ios");
this.element.classList.add("inline");
this._leftContainer = new ButtonsContainer({
buttons: [this.playPauseButton, this.skipBackButton],
cssClassName: "left",
padding: 24,
margin: 24,
});
this._rightContainer = new ButtonsContainer({
buttons: [this.airplayButton, this.pipButton, this.fullscreenButton],
cssClassName: "right",
padding: 24,
margin: 24
});
this.controlsBar.children = [this._leftContainer, this._rightContainer];
this._pinchGestureRecognizer = new PinchGestureRecognizer(this.element, this);
}
gestureRecognizerStateDidChange(recognizer)
{
if (this._pinchGestureRecognizer !== recognizer)
return;
if (recognizer.state !== GestureRecognizer.States.Ended && recognizer.state !== GestureRecognizer.States.Changed)
return;
if (recognizer.scale > IOSInlineMediaControls.MinimumScaleToEnterFullscreen && this.delegate && typeof this.delegate.iOSInlineMediaControlsRecognizedPinchInGesture === "function")
this.delegate.iOSInlineMediaControlsRecognizedPinchInGesture();
}
layout()
{
super.layout();
for (let button of this._rightContainer.buttons)
delete button.dropped;
this._leftContainer.layout();
this._rightContainer.layout();
this.timeControl.width = this.width - this._leftContainer.width - this._rightContainer.width;
if (this.timeControl.isSufficientlyWide) {
this.controlsBar.insertBefore(this.timeControl, this._rightContainer);
this.timeControl.x = this._leftContainer.width;
} else {
this.timeControl.remove();
for (let control of [this.airplayButton, this.pipButton, this.skipBackButton, this.fullscreenButton]) {
if (this._leftContainer.width + this._rightContainer.width < this.width)
break;
if (!control.visible)
continue;
control.dropped = true;
this._leftContainer.layout();
this._rightContainer.layout();
}
}
}
}
IOSInlineMediaControls.MinimumScaleToEnterFullscreen = 1.5;