lavva.exalushome
Version:
Library implementing communication and abstraction layers for ExalusHome system
29 lines • 1.18 kB
JavaScript
import { Event } from "../Event";
export class PictureInPictureService {
constructor() {
var _a, _b;
this.OnEnteredPictureInPicture = new Event();
this.OnExitedPictureInPicture = new Event();
this._nativeApi = null;
if (this.IsSupported()) {
this._nativeApi = navigator.pip;
(_a = this._nativeApi) === null || _a === void 0 ? void 0 : _a.OnEnteredPictureInPicture.Subscribe(() => this.OnEnteredPictureInPicture.Invoke());
(_b = this._nativeApi) === null || _b === void 0 ? void 0 : _b.OnExitedPictureInPicture.Subscribe(() => this.OnExitedPictureInPicture.Invoke());
}
else
navigator.pip = null;
}
IsSupported() {
return navigator.pip !== undefined && navigator.pip !== null;
}
RequestPictureInPictureAsync() {
if (!this.IsSupported())
return Promise.resolve(false);
return this._nativeApi.RequestPictureInPictureAsync();
}
GetServiceName() {
return PictureInPictureService.ServiceName;
}
}
PictureInPictureService.ServiceName = "PictureInPictureService";
//# sourceMappingURL=PictureInPicture.js.map