-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix init value for storeLastSettings #4221
Fix init value for storeLastSettings #4221
Conversation
@@ -89,7 +89,7 @@ function MediaController() { | |||
setTrack(selectInitialTrack(type, tracksForType), true); | |||
} else { | |||
if (tracks.length > 1) { | |||
setTrack(selectInitialTrack(type, tracks, !!lastSelectedTracks[type])); | |||
setTrack(selectInitialTrack(type, tracks)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectInitialTrack
has only 2 arguments, maybe it's for other purposes, but it doesn't take any effects at the moment.
@minhui-foxtel i think the idea behind What is the exact order of calls that causes a problem for you here? |
@dsilhavy yep, I'm using multi period MPD, so no proper reason to call [
{ // Period 1
audioTracks: [
{
codec: 'ec-3',
audioChannelConfiguration: [2],
},
{
codec: 'mp4a.40.2',
audioChannelConfiguration: [2],
},
],
},
{ // Period 2
audioTracks: [
{
codec: 'ec-3',
audioChannelConfiguration: ['F801'],
},
{
codec: 'mp4a.40.2',
audioChannelConfiguration: [2],
},
],
},
]; If set audio track with dash.js/src/streaming/controllers/MediaController.js Lines 75 to 86 in 2ed7239
But it will cause playback stall on some CTV devices, e.g. Samsung. It's probably due to incompatible codec, but I'm not very sure so far, I've checked if use the track with the same codec, playback will go well. So I tend to select initial track by myself, setCustomInitialTrackSelectionFunction seems to be a good choice, in order to let dash.js hit the custom function, I have to avoid dash.js to get the value form lastSelectedTracks[type] || getInitialSettings(type) . see dash.js/src/streaming/controllers/MediaController.js Lines 63 to 65 in 2ed7239
To achieve the goal, I disabled function setCurrentTrack(track, noSettingsSave) {
if (!streamingInitialized) {
throw STREAMING_NOT_INITIALIZED_ERROR;
}
mediaController.setTrack(track, noSettingsSave);
} But I think dash.js should have a way to prevent from setting last selected track. Here's my code snippet, const player = dashjs.MediaPlayer().create();
player.initialize(videoElement)
player.attachSource(source, startTime);
player.setCustomInitialTrackSelectionFunction(
myTrackSelectionFunction
);
player.updateSettings({
streaming: {
lastMediaSettingsCachingInfo: {
// dash.js takes `audioChannelConfiguration` into account but doesn't consider codec,
// so disable this and use `setCustomInitialTrackSelectionFunction` instead.
enabled: false,
},
}
});
// Manually trigger this during Period 1, the newTrack will be set to last selected track, I need a way to prevent it.
player.setCurrentTrack(newTrack); |
Thanks for the detailed explanation. I would like to separate the logic for getting media settings from the local storage and saving the settings for a single streaming session.
Does that work for you? |
@dsilhavy Thanks for your help, can you please review the PR again? Here's updates:
|
Thanks your PR looks good to me. Minor comments: Please add the following to
|
Updated |
Hi here,
If
streaming.lastMediaSettingsCachingInfo.enabled
is disabled, from my understanding, dash.js should not take last selected track into account.But from current implementation, if a a track set by
MediaPlayer.setCurrentTrack()
, it will be treated aslastSelectedTrack
, see L209dash.js/src/streaming/controllers/MediaController.js
Line 209 in 2ed7239
then it will affect which track will be selected, see L64
dash.js/src/streaming/controllers/MediaController.js
Lines 63 to 65 in 2ed7239
So need to get a way to avoid to set
lastSelectedTrack
whenstreaming.lastMediaSettingsCachingInfo
is disabled.storeLastSettings
seems to be a proper flag, see L194, butstoreLastSettings
of a track is hardcoded totrue
and never changed. This PR is to respectstreaming.lastMediaSettingsCachingInfo.enabled
and give a reasonable initial value.dash.js/src/streaming/controllers/MediaController.js
Lines 190 to 194 in 2ed7239