log优化
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { createParticipantTile, getParticipantTile } from './renderer-participant-grid.js';
|
||||
import { createLogger } from './logger.js';
|
||||
|
||||
const logger = createLogger('renderer-media');
|
||||
|
||||
export function getVideoResolution(track) {
|
||||
if (track && track.getSettings) {
|
||||
@@ -47,18 +50,18 @@ export function renderParticipantStreamMedia({
|
||||
if (!tile) {
|
||||
tile = createParticipantTile(connectionId, displayName);
|
||||
grid.appendChild(tile);
|
||||
console.log(`Created participant video tile for ${connectionId}`);
|
||||
logger.debug(`Created participant video tile for ${connectionId}`);
|
||||
}
|
||||
|
||||
const video = tile.querySelector('video');
|
||||
if (video && stream) {
|
||||
if (video.srcObject === stream) {
|
||||
console.log(`Same stream for participant ${connectionId}, ensuring playback`);
|
||||
video.play().catch(error => console.log('Auto-play prevented:', error.message));
|
||||
logger.debug(`Same stream for participant ${connectionId}, ensuring playback`);
|
||||
video.play().catch(error => logger.debug('Auto-play prevented:', error.message));
|
||||
} else {
|
||||
video.srcObject = stream;
|
||||
video.play().catch(error => console.log('Auto-play prevented:', error.message));
|
||||
console.log(`Set remote stream for participant tile ${connectionId}`);
|
||||
video.play().catch(error => logger.debug('Auto-play prevented:', error.message));
|
||||
logger.debug(`Set remote stream for participant tile ${connectionId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,15 +89,15 @@ export function renderSingleRemoteStreamMedia({
|
||||
connectingOverlay
|
||||
}) {
|
||||
if (!remoteVideo || !stream) {
|
||||
console.error('Either remoteVideo element or stream is missing');
|
||||
logger.error('Either remoteVideo element or stream is missing');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Rendering remote stream:', stream, 'tracks:', stream.getTracks().map(track => `${track.kind}(${track.readyState})`));
|
||||
logger.debug('Rendering remote stream:', stream, 'tracks:', stream.getTracks().map(track => `${track.kind}(${track.readyState})`));
|
||||
|
||||
if (remoteVideo.srcObject === stream) {
|
||||
console.log('Same stream object, track added - ensuring playback');
|
||||
remoteVideo.play().catch(error => console.log('Auto-play prevented:', error.message));
|
||||
logger.debug('Same stream object, track added - ensuring playback');
|
||||
remoteVideo.play().catch(error => logger.debug('Auto-play prevented:', error.message));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +106,7 @@ export function renderSingleRemoteStreamMedia({
|
||||
remoteVideo.playsinline = true;
|
||||
remoteVideo.muted = false;
|
||||
remoteVideo.play().catch(error => {
|
||||
console.log('Auto-play prevented, will retry on interaction:', error.message);
|
||||
logger.debug('Auto-play prevented, will retry on interaction:', error.message);
|
||||
});
|
||||
|
||||
if (disconnectedOverlay) {
|
||||
@@ -112,10 +115,10 @@ export function renderSingleRemoteStreamMedia({
|
||||
|
||||
const videoTracks = stream.getVideoTracks();
|
||||
const audioTracks = stream.getAudioTracks();
|
||||
console.log(`Stream has ${videoTracks.length} video tracks, ${audioTracks.length} audio tracks`);
|
||||
logger.debug(`Stream has ${videoTracks.length} video tracks, ${audioTracks.length} audio tracks`);
|
||||
|
||||
if (videoTracks.length === 0) {
|
||||
console.log('Audio-only stream, waiting for video track...');
|
||||
logger.debug('Audio-only stream, waiting for video track...');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,7 +168,7 @@ export function removeParticipantTile({
|
||||
video.srcObject = null;
|
||||
}
|
||||
tile.remove();
|
||||
console.log(`Removed participant video tile for ${connectionId}`);
|
||||
logger.debug(`Removed participant video tile for ${connectionId}`);
|
||||
}
|
||||
|
||||
const remainingTiles = grid.querySelectorAll('[data-participant-id]');
|
||||
|
||||
Reference in New Issue
Block a user