Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Unable to load caption ios


I've been trying to load SRT file from within the app by doing so but with no success.

[[JWTrack alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"caption" ofType:@"srt"] label:@"english" isDefault:YES];

However, I'm able to load a SRT file that is hosted online

[[JWTrack alloc] initWithFile:@"http://playertest.longtailvideo.com/caption-files/sintel-en.srt" label:@"english" isDefault:YES];

Am I missing something or loading the SRT from the bundle wrongly?

5 Community Answers

Daniel Berger

JW Player Support Agent  
0 rated :

It is somewhat unorthodox to implement locally saved captions tracks in our SDK. Why are you trying to implement a locally hosted captions track?
Have you explored our documentation: https://developer.jwplayer.com/sdk/ios/docs/developer-guide/embedding/embedding/

config.file = [NSString stringWithFormat:"file://%“,
[[NSBundle mainBundle] pathForResource:@”sintel" ofType:@"mp4"]];

s...

User  
0 rated :

Within my app, it allows user to download videos along with a SRT file. This is to allow users to access to video when they're offline.

I'm still not able to load the SRT file with the following code

[NSString stringWithFormat:"file://%“,
[[NSBundle mainBundle] pathForResource:@”caption" ofType:@"srt"]];

Daniel Berger

JW Player Support Agent  
0 rated :

I understand. Our player isn’t designed to load locally hosted caption files. The only workaround that I can think of is to implement loadConfig (https://developer.jwplayer.com/sdk/ios/reference/Classes/JWPlayerController.html#//api/name/loadConfig:)
with a new captions list. The issue with this approach is that it loads a whole new config. It would not achieve your desired behavior of loading just a new captions list.
The question I have is, when your app goes offline, why are you only trying to load a caption file? Why wouldn’t you load a new video file with embedded captions?

s...

User  
0 rated :

Thanks for the suggestion. During offline mode, I'm trying to load the downloaded video along with the downloaded SRT file, my aim is to have multilingual support for the caption, hence the reason why i'm not embedding the captions into the video as there is no reason for me to download multiple video with different embedded captions.

Daniel Berger

JW Player Support Agent  
0 rated :

I understand. Our player is designed to (at least initially) begin playback with a network connection. Technically, it might be possible to load all your assets from local storage, however (keep in mind I don’t fully understand your whole architecture), it might be better for you to use AVPlayer instead. Our player is designed to provide functionality that is dependent on a network connection (for things like skins, analytics, etc.).

This question has received the maximum number of answers.