html5
  • html5-video
  • subtitle
  • 2016-04-25 1 views 1 likes 
    1

    J'ai le code suivant pour lire une vidéo et afficher sa piste de sous-titres.Afficher les sous-titres dans un autre élément HTML5

    <video id="vTest" class="playr_video" controls preload="metadata"> 
         <source src='upc-tobymanley.theora.ogg' type='video/ogg'> 
         <source src='upc-tobymanley.mp4' type='video/mp4'> 
         <track label="English subtitles" kind="subtitles" srclang="en" src="upc-video-subtitles-en.vtt" default> 
        </video> 
    <div id="subtitle"> </div> 
    

    Est-il possible de montrer les sous-titres dans <div id="subtitle"> </div> au lieu du joueur?

    Répondre

    0

    Ajouter ce javaScript après <video> élément

    <script> 
    
    loadTextTrack({videoId:'vTest', // the ID of the video tag 
           kind:'subtitles', // the kind of track 
           srclang:'en', // the language of the source file (optional) 
           targetId:'subtitle'}); // the ID of the element into which to insert the timed text 
    </script> 
    

    Définir code CSS

    <style type="text/css"> 
    
    #subtitle{width: 480px; position: absolute; top: 280px;padding: 3px 10px; text-align: center; color:#fff;background-color:#000; font-family: Helvetica,Arial,sans-serif; font-size: 0.9em; font-weight: bold;min-height:3.6em;} 
    
    </style> 
    
    +0

    Testé, plaids une erreur "ReferenceError: loadTextTrack n'est pas défini" – Shin

    +0

    Ajoutez ces deux lignes à la section .. ... Dimppy

    +0

    Uncaught Erreur: erreur de syntaxe, expression non reconnue: track [type = sous-titres] [srclang = opt ['srclang']] Je reçois cette erreur, pourquoi? – Shin

     Questions connexes

    • Aucun problème connexe^_^