Estoy usando Node/Express para enviar un video mp4 a la interfaz para la que estoy usando angular. El video se está enviando sin problemas y todo funciona perfectamente. Ahora quiero enviar el archivo VTT que contiene los subtítulos, junto con el mp4. ¿No se como hacer eso? Intenté buscar pero no pude encontrar ninguna ayuda. Aquí está mi código:
Nodo/Expreso
router.get('/playVideo', (req, res) => { const path = "videos/testVideo.mp4"; const pathSubtitle = "videos/testsub.vtt"; const stat = fs.statSync(path); const fileSize = stat.size; const head = { 'Content-Length': fileSize, 'Accept-Ranges' : 'bytes', 'Content-Type': 'video/mp4' } res.writeHead(200, head); fs.createReadStream(path).pipe(res); });Angular
<div class="container-fluid"> <br> <div class="jumbotron-fluid"> <video id = "videoPlayer" controls preload = "metadata" style = "width: 65%; position: fixed; border: 2px solid #7c2c6c;"> <source src="http://localhost:3000/playVideo" autoplay type = "video/mp4"> </video> </div> </div>¿Cómo puedo adjuntar el archivo de subtítulos con la respuesta en video? O, ¿enlace a cualquier otra documentación que lo explique en detalle?
Sirva el archivo vtt en una URL diferente (por ejemplo, /playVideo.vtt) y luego use el elemento de pista para mostrarlo:*
<video id = "videoPlayer" controls preload = "metadata" style = "width: 65%; position: fixed; border: 2px solid #7c2c6c;"> <source src="http://localhost:3000/playVideo" autoplay type = "video/mp4"> <track default src="http://localhost:3000/playVideo.vtt"> </video>Puede leer más aquí: https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API#within_site_css y aquí:https://developer.mozilla.org/en-US/docs/Web/ HTML/Elemento/pista
*el código aún no ha sido probado