mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 02:39:46 +02:00
Update
This commit is contained in:
parent
dededfbe31
commit
fc1b1627cc
1 changed files with 24 additions and 2 deletions
|
@ -50,8 +50,22 @@ function stopWebcamLive(rtmpURL) {
|
||||||
// Send media chunks with the associated streamKey
|
// Send media chunks with the associated streamKey
|
||||||
function sendStreamToServer(stream) {
|
function sendStreamToServer(stream) {
|
||||||
try {
|
try {
|
||||||
|
if (!window.MediaRecorder) {
|
||||||
|
console.error('MediaRecorder API is not supported on this device.');
|
||||||
|
avideoToastError('MediaRecorder API is not supported on this device.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const mediaRecorder = new MediaRecorder(stream);
|
const options = {
|
||||||
|
mimeType: 'video/webm; codecs=vp8,opus' // Check for Safari compatibility
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const mediaRecorder = new MediaRecorder(stream, options);
|
||||||
|
console.log('MediaRecorder initialized with options:', options);
|
||||||
|
} catch (error) {
|
||||||
|
avideoTpastErrpr(`Failed to initialize MediaRecorder with options:${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
mediaRecorder.ondataavailable = (event) => {
|
mediaRecorder.ondataavailable = (event) => {
|
||||||
if (event.data.size > 0) {
|
if (event.data.size > 0) {
|
||||||
|
@ -142,7 +156,15 @@ async function startWebRTC({ videoDeviceId = null, audioDeviceId = null, useScre
|
||||||
// Start or update the media stream
|
// Start or update the media stream
|
||||||
const newStream = useScreen
|
const newStream = useScreen
|
||||||
? await navigator.mediaDevices.getDisplayMedia(constraints)
|
? await navigator.mediaDevices.getDisplayMedia(constraints)
|
||||||
: await navigator.mediaDevices.getUserMedia(constraints);
|
: await navigator.mediaDevices.getUserMedia(constraints)
|
||||||
|
.then((stream) => {
|
||||||
|
console.log('Media stream obtained:', stream);
|
||||||
|
sendStreamToServer(stream);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
avideoToastError(`Error accessing media devices: ${error}`);
|
||||||
|
console.error('Error accessing media devices:', error);
|
||||||
|
});
|
||||||
|
|
||||||
// Stop existing tracks before replacing them
|
// Stop existing tracks before replacing them
|
||||||
if (localStream) {
|
if (localStream) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue