Commutazione delle tracce audio

  Siamo spiacenti, questa pagina è in attesa di traduzione in italiano

The player supports three options for selecting audio tracks
  1. Inside HLS and DASH (switch just audio)
  2. Switching by sources (switch audio with video)
  3. Natively inside an MP4 container

HLS and DASH

The list of audio tracks for HLS and DASH is automatically generated, if the manifest has a choice, the audio player will display the track names in the options menu. In some cases, the sound and the image may be out of sync.

Switching sources

The source list is passed to the player by the file parameter, the names are enclosed in curly braces, and the options are separated by a symbol ;

{audiotrack}URL1;{audiotrack}URL2;{audiotrack}URL3

Sample

new Playerjs({
  "id":"player",
  "file":"{French}//site.com/video_fr.mp4;{English}//site.com/video_en.mp4"
});

If you need to specify the quality options and audio tracks together, then the quality must be outside

new Playerjs({
  "id":"player",
  "file":"[480p]{French}//site.com/video480_fr.mp4;{English}//site.com/video480_en.mp4,[720p]{French}//site.com/video720_fr.mp4;{English}//site.com/video720_en.mp4"
});

Native MP4 audio tracks

The player (from version 18.11) automatically displays native audio tracks that are embedded in the MP4 video container and are supported by some browsers (only Safari has support by default in 2023). In Chrome support can be enabled in the chrome://flags settings (enable Experimental Web Platform features).

The player will show a selection of audio tracks using information from the video metadata (each audio track has a label and language parameter there). If you want to rename audio track names, use the rename_audio parameter (below is an example of renaming two audio tracks named Track (es) and Track (en).

let player = new Playerjs({id:"player", file:"//site.com/video.mp4", rename_audio:{"Track (es)":"Español","Track (en)":"English"});

You can disable this option in the player settings Sound / Native audio tracks

Audio track by default

The default_audio parameter allows you to enable the desired audio track by specifying its name.

var player = new Playerjs({
  "id":"player",
  "file":"//site.com/video.m3u8",
  "default_audio":"French"
});

Remembering the choice

With PRO you can turn on the Memorizing / Memorize selected audiotrack in the settings - in this case selected audio track will be used as default on the current domain if the player has an audio track with such name.

Renaming

You can rename audio tracks for HLS or DASH with the rename_audio parameter (works from 13.15).

rename_audio:{"es1":"Spanish","track2":"English"}

Since version 17.8, you can use the track sequence number starting from 0

rename_audio:{0:"Spanish", 1:"Japan", 2:"English"}

Switching in playlist

If you switch audio versions of a single file using a playlist, the continuation of time can be enabled by the "start":"continue" parameter for each playlist item. In this case, playback on switching will continue instead of starting over.


19.12.11
2024 © PlayerJS

Iscriviti gratuitamente

Iscriviti
Iscrivendosi, si accettano Termini di servizio
Login se si possiede un account

Ripristino della password

Ripristino
Hai dimenticato l'e-mail? Contattaci