mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: initialize captions lang checking local storage
parent
103ae1fd54
commit
8925d09bd6
|
@ -24,16 +24,19 @@ export class CaptionService {
|
||||||
captionLangObs: Observable<{ name: string; ISO: string }>;
|
captionLangObs: Observable<{ name: string; ISO: string }>;
|
||||||
private _captionLangObs: Subject<{ name: string; ISO: string }> = new Subject();
|
private _captionLangObs: Subject<{ name: string; ISO: string }> = new Subject();
|
||||||
|
|
||||||
|
|
||||||
constructor(private storageService: StorageService) {
|
constructor(private storageService: StorageService) {
|
||||||
|
const iso = this.storageService.getCaptionsLang();
|
||||||
|
if (iso) {
|
||||||
|
this.captionLangSelected = this.langTitles.find((lang) => lang.ISO === iso) || this.langTitles[0];
|
||||||
|
}
|
||||||
this.captionLangObs = this._captionLangObs.asObservable();
|
this.captionLangObs = this._captionLangObs.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
setLanguage(lang: string) {
|
setLanguage(lang: string) {
|
||||||
if (this.langTitles.some((l) => l.ISO === lang)) {
|
if (this.langTitles.some((l) => l.ISO === lang)) {
|
||||||
this.captionLangSelected = this.langTitles.find((l) => l.ISO === lang);
|
this.captionLangSelected = this.langTitles.find((l) => l.ISO === lang);
|
||||||
this._captionLangObs.next(this.captionLangSelected);
|
|
||||||
this.storageService.setCaptionLang(lang);
|
this.storageService.setCaptionLang(lang);
|
||||||
|
this._captionLangObs.next(this.captionLangSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue