@jaydhimar/react-native-pip
Version:
A React Native library for Picture-in-Picture mode with support for both iOS and Android platforms.
29 lines (28 loc) • 887 B
JavaScript
;
import { NativeEventEmitter } from 'react-native';
import NativePip from "./NativePip.js";
const eventEmitter = new NativeEventEmitter(NativePip);
class PictureInPicture {
listeners = [];
async isPipSupported() {
return NativePip.isPipSupported();
}
async enterPictureInPicture(config) {
return NativePip.enterPictureInPicture(config);
}
async exitPictureInPicture() {
return NativePip.exitPictureInPicture();
}
addEventListener(eventType, listener) {
const subscription = eventEmitter.addListener(eventType, listener);
const removeListener = () => subscription.remove();
this.listeners.push(removeListener);
return removeListener;
}
removeAllListeners() {
this.listeners.forEach(removeListener => removeListener());
this.listeners = [];
}
}
export default new PictureInPicture();
//# sourceMappingURL=index.js.map