mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-08-16 02:56:22 +00:00
19 lines
578 B
JavaScript
19 lines
578 B
JavaScript
"use strict";
|
|
|
|
import { useEffect } from 'react';
|
|
/**
|
|
* Attaches an event listener to a `VideoPlayer` instance for a specified event.
|
|
*
|
|
* @param player - The player to attach the event to
|
|
* @param event - The name of the event to attach the callback to
|
|
* @param callback - The callback for the event
|
|
*/
|
|
export const useEvent = (player, event, callback) => {
|
|
useEffect(() => {
|
|
const subscription = player.addEventListener(event, callback);
|
|
return () => {
|
|
subscription.remove();
|
|
};
|
|
}, [player, event, callback]);
|
|
};
|
|
//# sourceMappingURL=useEvent.js.map
|