Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imneonizer/c0447eba120de4de5bbdb4f0b30ad4e4 to your computer and use it in GitHub Desktop.
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)
// 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