i want to store subtitle state on or off for next player launch, so user not require to turn on or off every launch, irrespective of isdefaulttrack flag.
i used method
func onSubtitleChanged(_ event: SubtitleChangedEvent, player: Player)
to check old and new event and old and new language to determine player subtitle status on or off and store it according to userdefault.
it working fine.
but now i got one stream which have no language for the subtitle track and its have isdefaulttrack true for cc, so the above logic not works.
so any advise how can i determine last status for subtitle and store it for subsequent launch.
Thanks
Hi @gauravkumar.t,
Do you only want to store/apply the on/off state or also the language of a subtitle track? I assume the on/off should not be a problem with the approach you follow.
Based on the callback you shared, I assume you are working on an iOS application. The easiest approach would be to store the needed information in UserDefaults
and apply them after loading a Source inside the onReady
event.
I can’t fully follow which problems the mentioned stream with the CC subtitle track brings. Maybe you could elaborate a bit more on this.
yes its iOS Application.
yes i am storing on/off using userdefault. using below switch case.
public func onSubtitleChanged(_ event: SubtitleChangedEvent, player: Player) {
switch (event.subtitleTrackOld, event.subtitleTrackNew) {
case (nil, .some):
flag set true
case (.some, nil):
flag set false
case (.some(let subtitleTrackOld), .some(let subtitleTrackNew)):
switch (subtitleTrackOld.language, subtitleTrackNew.language) {
case (nil, .some):
flag set true
case (.some, nil):
flag set false
default:
break
}
default:
break
}
}
but this works only if we have stream track language for the subtitle, if stream track has not language (means nil) than this logic not works. need solution for stream without nil as language for track.
is there any javascript code(in styleconfig js file) with Bitmovin native UI to find the event on setting the subtitle and pass it to native code?
What should happen on the next load if the language is nil
? Shouldn’t it be fine if, in this case, no subtitle is selected by default?
You could combine the switch with subtitleTrack.label
to detect off
or cc
subtitles. They will not be nil
in this case.
is there any javascript code(in styleconfig js file) with Bitmovin native UI to find the event on setting the subtitle and pass it to native code?
No there is no possibility to do this in our default UI. If you consider creating your own version of it (by forking it) you could utilize our CustomMessageHandlerDelegate for custom messaging between the UI and native application.