Однако зарегистрированный мной обработчик действий, похоже, не работает:
Код: Выделить всё
useEffect(() => {
const requestPermissions = async () => {
try {
const mediaStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: true,
});
if (videoRef) {
videoRef.current.srcObject = mediaStream;
}
navigator.mediaSession.setActionHandler("enterpictureinpicture", () => {
videoRef.current.requestPictureInPicture();
});
} catch (err) {
console.error(err);
}
};
requestPermissions();
}, []);
Подробнее здесь: https://stackoverflow.com/questions/798 ... -in-chrome
Мобильная версия