Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
¿Cómo transmitir un video blob en JavaScript?

Tengo un video llamado video.mp4 . Quiero transmitirlo en una etiqueta de video en HTML, probé demasiadas respuestas de otras preguntas y ninguna funcionó.

 var URL = this.window.URL || this.window.webkitURL;
var file = new Blob(["./video.mp4"], {"type": "video\/mp4"});
var value = URL.createObjectURL(file);

console.log(value);
video.src = value;

Cuando probé el código anterior, imprimió una mancha, pero cuando quiero reproducir el video, no funciona y muestra este error en la consola:

Uncaught (in promise) DOMException: The element has no supported sources.

almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

new Blob no se puede usar para leer directamente un archivo. Es posible que necesite algo como crear una instancia de XMLHttpRequest . Consulte también la documentación del elemento <video> :https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video . Debe especificar los elementos <source> con el atributo de type .

almost 4 years ago · Santiago Trujillo Report

0

Podrías hacerlo así:

 var vid= document.createElement("video");
var vidsrc= document.createElement("source");
vidsrc.setAttribute('src','video.mp4');
vidsrc.setAttribute('type','video/mp4');
vid.appendChild(vidsrc);
document.body.appendChild(vid);

Este código simplemente crea un nuevo elemento de video con un elemento fuente y lo agrega al cuerpo del documento.

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!