It is impossible to change audioTrack immediately
Created by: matiosfree
Hey all. I have a problem with this player. I need to solve this task. I have a MPD file with video and several audioTracks in the different languages. I want to have an opportunity to change audio language immediately. The problem is that the player loads audiobuffers in advance, and I don't hear new language immediately after changing the audioTrack, only in a few secconds. It's not good for me. Furthermore, if I hear english audioTrack, and I switch to German audioTrack, but then I'll rewind the track I hear English again, bacause in that time I heard English audioTrack. So, I guess, there should be some method to clear audio buffers during the track change.
for now I use something like this:
var tracks = this.player.getTracksFor('audio'), currentTrack = this.player.getCurrentTrackFor('audio'); this.player.setTrackSwitchModeFor('audio', 'alwaysReplace'); this.player.setCurrentTrack(tracks[trackIndex]);
- Dash.js version: 2.6.2
- Browser name/version: Chrome canary 64.0.3242.0, Chrome 61.0.3163.100, Firefox 56.0
- OS name/version: Win7
Console output
[HMR] Waiting for update signal from WDS...
dash.all.min.js:18 [2] [dash.js 2.6.2] MediaPlayer has been initialized
dash.all.min.js:18 [4] No supported version of EME detected on this user agent! - Attempts to play encrypted content will fail!
dash.all.min.js:18 [358] Playback Initialized
dash.all.min.js:18 [379] Parsing complete: ( xml2json: 2.96ms, objectiron: 0.640ms, total: 0.00361s)
dash.all.min.js:18 [384] MediaSource attached to element. Waiting on open...
dash.all.min.js:18 [385] Manifest has been refreshed at Tue Oct 17 2017 15:05:59 GMT+0300 (RTZ 2 (зима))[1508241959.035]
dash.all.min.js:18 [391] MediaSource is open!
dash.all.min.js:18 [391] Duration successfully set to: 74
dash.all.min.js:18 [391] Added 0 inline events
dash.all.min.js:18 [392] video codec: video/mp4;codecs="avc1.4d401f"
dash.all.min.js:18 [399] Perform SIDX load: https://mysite.com/ice_0/ice_3_3.mp4
2dash.all.min.js:18 [400] audio codec: audio/mp4;codecs="mp4a.40.2"
dash.all.min.js:18 [402] Perform SIDX load: https://mysite.com/ice_0/ice.mp4
dash.all.min.js:18 [402] No text data.
dash.all.min.js:18 [403] No fragmentedText data.
dash.all.min.js:18 [403] No embeddedText data.
dash.all.min.js:18 [403] No muxed data.
dash.all.min.js:18 [404] Start Event Controller
dash.all.min.js:18 [406] Parsing segments from SIDX.
dash.all.min.js:18 [407] Parsing segments from SIDX.
dash.all.min.js:18 [408] Schedule controller starting for video
dash.all.min.js:18 [408] Schedule controller starting for audio
dash.all.min.js:18 [410] ScheduleController - getNextFragment
dash.all.min.js:18 [410] ScheduleController - switch track has been asked, get init request for video with representationid = ice_3_3
dash.all.min.js:18 [413] ScheduleController - getNextFragment
dash.all.min.js:18 [413] ScheduleController - switch track has been asked, get init request for audio with representationid = ice
dash.all.min.js:18 [417] Init fragment finished loading saving to video's init cache
dash.all.min.js:18 [418] Init fragment finished loading saving to audio's init cache
dash.all.min.js:18 [421] Native video element event: loadedmetadata
dash.all.min.js:18 [422] Top qualityvideo index has changed from undefined to 0
dash.all.min.js:18 [424] AbrController (video) stay on 0/0 (buffer: 0)
dash.all.min.js:18 [424] ScheduleController - getNextFragment
dash.all.min.js:18 [424] Getting the request for video time : 0
dash.all.min.js:18 [425] SegmentBase: 0.023203125 / 74
dash.all.min.js:18 [425] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [426] Top qualityaudio index has changed from undefined to 0
dash.all.min.js:18 [426] AbrController (audio) stay on 0/0 (buffer: 0)
dash.all.min.js:18 [426] ScheduleController - getNextFragment
dash.all.min.js:18 [427] Getting the request for audio time : 0
dash.all.min.js:18 [427] SegmentBase: 0 / 74
dash.all.min.js:18 [427] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice.mp4
dash.all.min.js:18 [440] Buffered Range for type: audio : 0 - 15.000089
dash.all.min.js:18 [440] AbrController (audio) switching from throughput to buffer occupancy ABR rule (buffer: 15.000).
dash.all.min.js:18 [440] Got enough buffer to start.
dash.all.min.js:18 [442] Buffered Range for type: video : 0 - 4.8
dash.all.min.js:18 [442] Got enough buffer to start.
dash.all.min.js:18 [443] Requesting seek to time: 0
dash.all.min.js:18 [444] BOLA ABR rule invoked for media type 'audio' with only one bitrate.
dash.all.min.js:18 [444] AbrController (audio) stay on 0/0 (buffer: 15)
dash.all.min.js:18 [444] ScheduleController - getNextFragment
dash.all.min.js:18 [444] Getting the request for audio time : 15.000090702947846
dash.all.min.js:18 [445] SegmentBase: 0 / 74
dash.all.min.js:18 [445] Getting the next request at index: 1
dash.all.min.js:18 [445] SegmentBase: 15.000090702947846 / 74
dash.all.min.js:18 [445] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice.mp4
dash.all.min.js:18 [446] ThroughputRule requesting switch to index: 0 type: video Average throughput 265100 kbps
dash.all.min.js:18 [447] AbrController (video) stay on 0/0 (buffer: 4.8)
dash.all.min.js:18 [447] ScheduleController - getNextFragment
dash.all.min.js:18 [447] Getting the request for video time : 4.823203125
dash.all.min.js:18 [447] SegmentBase: 0.023203125 / 74
dash.all.min.js:18 [447] Getting the next request at index: 1
dash.all.min.js:18 [447] SegmentBase: 4.823203125 / 74
dash.all.min.js:18 [448] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [458] Buffered Range for type: audio : 0 - 30.00018
dash.all.min.js:18 [459] Buffered Range for type: video : 0 - 9.6
dash.all.min.js:18 [461] ThroughputRule requesting switch to index: 0 type: video Average throughput 368253 kbps
dash.all.min.js:18 [462] AbrController (video) stay on 0/0 (buffer: 9.6)
dash.all.min.js:18 [462] ScheduleController - getNextFragment
dash.all.min.js:18 [462] Getting the request for video time : 9.623203125
dash.all.min.js:18 [462] Index for video time 9.623203125 is 1
dash.all.min.js:18 [463] SegmentBase: 4.823203125 / 74
dash.all.min.js:18 [463] Getting the next request at index: 2
dash.all.min.js:18 [463] SegmentBase: 9.623203125 / 74
dash.all.min.js:18 [463] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [472] Buffered Range for type: video : 0 - 14.4
dash.all.min.js:18 [472] AbrController (video) switching from throughput to buffer occupancy ABR rule (buffer: 14.400).
dash.all.min.js:18 [474] BOLA ABR rule invoked for media type 'video' with only one bitrate.
dash.all.min.js:18 [474] AbrController (video) stay on 0/0 (buffer: 14.4)
dash.all.min.js:18 [474] ScheduleController - getNextFragment
dash.all.min.js:18 [475] Getting the request for video time : 14.423203125
dash.all.min.js:18 [475] Index for video time 14.423203125 is 2
dash.all.min.js:18 [475] SegmentBase: 9.623203125 / 74
dash.all.min.js:18 [475] Getting the next request at index: 3
dash.all.min.js:18 [475] SegmentBase: 14.423203125 / 74
dash.all.min.js:18 [475] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [481] Buffered Range for type: video : 0 - 19.28
dash.all.min.js:18 [488] BOLA ABR rule invoked for media type 'video' with only one bitrate.
dash.all.min.js:18 [489] AbrController (video) stay on 0/0 (buffer: 19.28)
dash.all.min.js:18 [489] ScheduleController - getNextFragment
dash.all.min.js:18 [489] Getting the request for video time : 19.303203125
dash.all.min.js:18 [489] Index for video time 19.303203125 is 3
dash.all.min.js:18 [489] SegmentBase: 14.423203125 / 74
dash.all.min.js:18 [490] Getting the next request at index: 4
dash.all.min.js:18 [490] SegmentBase: 19.303203125 / 74
dash.all.min.js:18 [490] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [497] Buffered Range for type: video : 0 - 24.08
dash.all.min.js:18 [499] BOLA ABR rule invoked for media type 'video' with only one bitrate.
dash.all.min.js:18 [499] AbrController (video) stay on 0/0 (buffer: 24.08)
dash.all.min.js:18 [500] ScheduleController - getNextFragment
dash.all.min.js:18 [500] Getting the request for video time : 24.103203125
dash.all.min.js:18 [500] Index for video time 24.103203125 is 4
dash.all.min.js:18 [500] SegmentBase: 19.303203125 / 74
dash.all.min.js:18 [500] Getting the next request at index: 5
dash.all.min.js:18 [501] SegmentBase: 24.103203125 / 74
dash.all.min.js:18 [501] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [507] Buffered Range for type: video : 0 - 28.88
dash.all.min.js:18 [509] BOLA ABR rule invoked for media type 'video' with only one bitrate.
dash.all.min.js:18 [509] AbrController (video) stay on 0/0 (buffer: 28.88)
dash.all.min.js:18 [510] ScheduleController - getNextFragment
dash.all.min.js:18 [510] Getting the request for video time : 28.903203125
dash.all.min.js:18 [510] Index for video time 28.903203125 is 5
dash.all.min.js:18 [510] SegmentBase: 24.103203125 / 74
dash.all.min.js:18 [511] Getting the next request at index: 6
dash.all.min.js:18 [511] SegmentBase: 28.903203125 / 74
dash.all.min.js:18 [511] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice_3_3.mp4
dash.all.min.js:18 [518] Buffered Range for type: video : 0 - 33.76
dash.all.min.js:18 [960] BOLA ABR rule invoked for media type 'audio' with only one bitrate.
dash.all.min.js:18 [960] AbrController (audio) stay on 0/0 (buffer: 30)
dash.all.min.js:18 [961] ScheduleController - getNextFragment
dash.all.min.js:18 [961] Getting the request for audio time : 30.00018140589569
dash.all.min.js:18 [961] Index for audio time 30.00018140589569 is 1
dash.all.min.js:18 [961] SegmentBase: 15.000090702947846 / 74
dash.all.min.js:18 [961] Getting the next request at index: 2
dash.all.min.js:18 [961] SegmentBase: 30.00018140589569 / 74
dash.all.min.js:18 [961] ScheduleController - getNextFragment - request is https://mysite.com/ice_0/ice.mp4
dash.all.min.js:18 [968] Buffered Range for type: audio : 0 - 45.000271
CHANGE THE AUDIO TRACK
[26334] Stream - Process track changed at current time 0
dash.all.min.js:18 [26334] Stream - Update stream controller
dash.all.min.js:18 [26334] Schedule controller stopping for audio
dash.all.min.js:18 [26334] Perform SIDX load: https://mysite.com/ice_0/ice_2.mp4
dash.all.min.js:18 [26342] Parsing segments from SIDX.
dash.all.min.js:18 [26342] Schedule controller starting for audio
dash.all.min.js:18 [26344] ScheduleController - getNextFragment
dash.all.min.js:18 [26344] ScheduleController - switch track has been asked, get init request for audio with representationid = ice_2
dash.all.min.js:18 [26346] Init fragment finished loading saving to audio's init cache
dash.all.min.js:18 [26347] Buffered Range for type: audio : 0 - 45.000271