Created
March 8, 2024 08:17
-
-
Save imneonizer/c0447eba120de4de5bbdb4f0b30ad4e4 to your computer and use it in GitHub Desktop.
Check if the stream served by mediamtx is available (paste it in the console window in browser for that stream)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find the video element that is supposed to play the stream | |
const videoElement = document.querySelector('video'); | |
if (videoElement) { | |
const stream = videoElement.srcObject; | |
// Check if the stream is available and active | |
if (stream instanceof MediaStream && stream.active) { | |
// Get video tracks from the stream | |
const videoTracks = stream.getVideoTracks(); | |
// Check if there are video tracks | |
if (videoTracks.length > 0) { | |
console.log('Video track is available'); | |
} else { | |
console.log('No video track is available in the stream'); | |
} | |
} else { | |
console.log('No active stream is attached to the video element'); | |
} | |
} else { | |
console.log('No video element found'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment