Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
How to let HLS.js fetch data from server side?

I used hls.js to implement my video player,and I have some ts files in https:/// with one m3u8 file.

I readed the m3u8 file with php and sent the content to js (res["manifest"]=the content of m3u8),then put it into hls.loadSource(),as below.

var manifest = res["manifest"];
var blob = new Blob([manifest]);
var hls = new Hls();
var url = URL.createObjectURL(blob);

hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
    video.load();
});

After this,the hls started to get the files listed in m3u8 by

blob:https://<my domain>/<video name>.mp4

Of course,it can't find the files because they are in

https://<my domain>/<video name>.mp4

instead of

blob:https://<my domain>/<video name>.mp4

request log

The url starts with "blob:" is created by URL.createObjectURL in front-end,but now I want that hls sends requests to video.php,then video.php reads the ts files and responses the contents back from server side.

Any method to do this? (modify the source code,change setting,...etc)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I can't believe that I achieved it.

I modified the source code of src/loader/fragment.ts below:

@@ -78,9 +78,7 @@ export class BaseSegment {
 
   get url(): string {
     if (!this._url && this.baseurl && this.relurl) {
-      this._url = buildAbsoluteURL(this.baseurl, this.relurl, {
-        alwaysNormalize: true,
-      });
+      this._url = 'video.php?f=' + this.relurl;
     }
     return this._url || '';
   }

then recompiled with webpack. Now it sends the get request to video.php with query parameter "f=<video name>.mp4",so I can process the request with my video.php.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda