1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00
This commit is contained in:
Daniel Neto 2025-01-12 12:12:49 -03:00
parent ca089ec17e
commit a71f0f4c55
3 changed files with 10 additions and 4 deletions

View file

@ -70,13 +70,19 @@ function sendStreamToServer(stream) {
console.error('MediaRecorder error:', event.error);
};
mediaRecorder.start(1000); // Record and send chunks every second
const chunkSize = isIPhone() ? 250 : 1000; // 250ms for iPhone, 1000ms for others
mediaRecorder.start(chunkSize); // Record and send chunks every second
console.log(`MediaRecorder started`);
} catch (error) {
console.error('Failed to initialize MediaRecorder:', error);
}
}
// Detect if the device is an iPhone
function isIPhone() {
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
}
// Function to stop the MediaRecorder
function stopStreamToServer() {
if (mediaRecorder && mediaRecorder.state !== 'inactive') {