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

tracks - captions - "default": true not working


I'm trying to set the default captions display to true but unable to get it to work... the only way I can get my captions to show is by clicking the CC button. Normally this is what I like, however I have a project that requires captions be turned on initially.

<script type='text/javascript'>
var jwvideo = jwplayer('my-video').setup({
primary: 'flash',
skin: '../jwplayer6/skins/sprint/sprint.xml',
playlist: [{
file: "privacy.mp4",
image: "privacy.png",
tracks: [{
file: "privacy.srt",
type: "captions",
label: "English",
"default": true
}]
}],
width: '100%',
aspectratio: '16:9'
});


</script>

here is a link to my page...

http://dev.sprintu.com/jwplayer6/bootstrap.html

18 Community Answers

MisterNeutron

User  
0 rated :

The closed captions appear automatically for me, in every browser (Win7, Chrome, FF, and IE11).

eric.madsen

User  
0 rated :

MisterNeutron - is it possible that the CC is turned on from a previous JW Player view. Not exactly sure how JW Player saves preferences like volume and captions, but if the CC was on then the page is reloaded it remains on. If it was off and the page is reloaded it remains off.

This is the behavior I see in all browsers I've tested in and both Mac and PC.

eric.madsen

User  
0 rated :

What I'm wondering is if the on/off preference is stored in a cookie...? either way it appears that the page is not showing captions upon visiting unless a previous video or the page was viewed with captions turned on.

MisterNeutron

User  
0 rated :

I see the captions, despite the fact that I have never visited the page before. Of course, if I visit the page, start the video, turn CC off, leave the page, then come back, the CC is still off. That's exactly what you'd want to have happen. And of course it doesn't matter what some other visitor might have done - upon a first visit by a new visitor, the CC is on.

eric.madsen

User  
0 rated :

The behavior is that if you go to any JW Player 6 page and turn of captions then go to a page with "default": true, the captions still do not show. This is not just an issue with the same page, it's any page.

Here is a duplicate page for reviewing...

http://dev.sprintu.com/jwplayer6/bootstrap2.html

to test first go to this page and make sure the captions are off...

http://dev.sprintu.com/jwplayer6/bootstrap.html

then go here..

http://dev.sprintu.com/jwplayer6/bootstrap2.html

You will see that the captions are off even though you have never visited this page before.

If the point of having an attribute that can be set to show/hide captions through the JW Player API is to be able to control the presentation.

In most cases I'm all for user control, but in this case my client is requiring captions be visible for users because the player will be used for audio playback. With the audio playback there is no indication that anything is happening and the JW Player 6 hides the controls after a couple seconds... so a black box with no controls and no captions.

We really just want to make sure for these audio only situations that we display captions. I'd even be up for removing the CC button altogether.

MisterNeutron

User  
0 rated :

Your demo pages are all on the same domain, so naturally any cookie is going to apply.

Your remark about audio is a complete puzzle to me. In its audio mode, JW Player does not hide the control bar - the control bar is, in fact, the only thing being displayed. And there are no captions even possible in audio mode.

http://misterneutron.com/JW6audio/

If you wanted a still image shown with the audio player, you'd do it with a separate <div> containing your image, rather than trying to do it within JW Player.

eric.madsen

User  
0 rated :

I've not had much experience using JW Player 6 with audio files. I didn't realize that the controls stayed up when playing audio files - my mistake.

Captions with audio in the JW Player 6 are possible. Here's an example of a captions (vtt file - I also tested a srt file) file working with an MP3 audio file.

You can also use the image: parameter to add a static image.

audio + captions file
http://dev.sprintu.com/jwplayer6/bootstrap3.html

audio + with image
http://dev.sprintu.com/jwplayer6/bootstrap3.html

BTW-

I figured out a way to force the captions on at start.

jwplayer('my-video').onPlaylistItem(function() {
jwplayer('my-video').setCurrentCaptions(1);
});

Now I just need to figure out why my captions aren't showing at all on iOS devices.

eric.madsen

User  
0 rated :

Oops... copy/paste error

audio + with image
http://dev.sprintu.com/jwplayer6/bootstrap4.html

eric.madsen

User  
0 rated :

It appears captions only work with audio files in Flash mode.

MisterNeutron

User  
0 rated :

"It appears captions only work with audio files in Flash mode."

...which explains why they don't show up on a mobile. Frankly, I wasn't aware they worked with audio files under any circumstances. The only browser that can't handle MP3's natively is IE8, so Flash playback of MP3's is rapidly disappearing.

eric.madsen

User  
0 rated :

IE8 is a huge part of my world unfortunately and probably not going away anytime too soon. Making sure the audio is accessible is also a requirement.

Looks like my best option may be to convert audio files to MP4 files.

jherrieven

User  
0 rated :

This has highlighted a number of inconsistencies between HTML5 and Flash modes when playing MP3 + the inclusion of captions - hopefully someone from JW will pick this up.

First thing to note is that when an MP3 is used, the control bar is always visible - regardless of the player height. This means you can set the background image to a static image of any size to complement the space needed to contain the captions... However, when in "MP3 state", captions are not honoured in HTML5 mode - though they are in Flash mode and will appear above the control bar.

The hack-around for HTML5 mode is to explicitly set the "type" parameter for the MP3 to "mp4". This makes the player switch to "video state" and the captions will be displayed. However... the control bar will now hide/show based on the mouse rollover, and this will obscure the captions at certain times. This configuration also causes an error in Flash mode as the player is expecting MP4 but gets MP3.

Switching your MP3's to MP4's will allow a consistent approach with HTML5/Flash + captions, but the control bar will hide/show and obsure the captions as described above.

If you don't wish to convert your files, you could implement a setup where you force Flash with true MP3 on IE8 (with captions above an always visible control bar), and then use the "MP3 pretending to be MP4" approach on all other browser/devices (with a hidey/showey control bar).

James Herrieven

MisterNeutron

User  
0 rated :

Just a random thought, but if you're feeding just audio, why use captions at all? That's like showing a movie in English, and with English subtitles - more of a distraction than a help to the site visitor.

If you're concerned about providing site support for the deaf, I suspect they'd prefer a simple block of readable text, rather than visible text that "paces" itself to the time of the speaker in the audio file, a speaker they can't hear, anyway.

So, I think I'd approach this differently - a basic, 30px tall audio player, a static image in its own nieghboring <div>, and a "transcript" link that reveals the text.

eric.madsen

User  
0 rated :

MisterNeutron, these files are part of training curriculum and there are a couple scenarios where captions are important.

First accessibility for hearing impaired employees. While a small number, this is a commitment we make to them to ensure an experience that is as close to what other employees get as possible.

The other scenario is no sound or unable to use sound in a location/situation - this is surprisingly common in our diverse corporate and vended environment.

I've been considering ways to display the text in a modal window or a hidden div. However it's currently part of my team's workflow to make the SRT files and soon we'll have speech to text technology that will kick out these for us. Also the tool used to make the training doesn't allow for a lot of freedom and the developers are less web savvy and more subject matter experts. They actually use an iframe to embed the JW Player into the course. Calling something like a modal window from an embedded iframe is doable, but complicated.

jherrieven, yeah - using JW Player with audio is pretty new to me and I've been surprised and a little disappointed by the inconsistencies with accessibility features. First the idea that the developer can't really override the "default" display in either video or audio is not great. Then the differences between Flash and HTML5 modes... again, not good. One more thing I noticed... even though in iOS the captions do not work and do not show, there is still a caption button. This would be a big usability problem. I would only want that button to show if there were in fact functioning captions.

We actually force Flash mode on all desktop browsers using the primary: 'flash' method. We do this because some implementations of Citrix play MP4 files without sound. In the past we also had issues with IE9 in HTML5 mode (although I've read that has been addressed in more recent releases of the player). Running in Flash mode fixes the Citrix issues.

You propose some interesting ideas which I might try working with, although I'm weary of creating a player for audio files that is overly complex and relies on detection. I just need to give this more thought.

I totally agree about hoping for JW to pick this up. If the player was more consistent in it's playback across players (flash / html) and between audio and video then we wouldn't be having this conversation and my stuff would just work.

Randy

JW Player Support Agent  
0 rated :

Hello,

You guys may have figured this out already but wanted to know if the following code worked for you:

jwplayer(“myVideo”).setup({
file:‘http://content.jwplatform.com/videos/3XnJSIm4-kNspJqnJ.mp4’,
image: ‘http://content.jwplatform.com/thumbs/q1fx20VZ-640.jpg’,
height: ‘270’,
tracks: [{
file: “http://bob.jwplayer.com/~randy/caption.vtt”,
label: “English”,
kind: “captions”,
“default”: true
}]
});
jwplayer().onReady(function(){
jwplayer().setCurrentCaptions(“true”);
});
</script>

This will set the captions to true all the time.

Randy

carl.eriksson

User  
0 rated :

I cannot understand this. I pasted in your code in my view Randy and it worked. But whenever i try to do it with my own, which retrieves captions from youtube it doesnt work anymore.

my code looks like this btw:

jwplayer('<%# container.ClientID %>').setup({
file: '<%# VideoUrl %>',
image: '<%# PreviewImageUrl %>',
width: '100%',
primary: "html5",
tracks: [{
<%-- file: '<%# CaptionUrl %>',--%>
file: 'http://video.google.com/timedtext?lang=sv&v=jFRj5uH3Jhc&fmt=vtt',
label: "Svenska",
kind: "captions",
"default": true
}],
<%= CurrentBlock.TransparentBackground ? "wmode: 'transparent'" : string.Empty %>

});

One more thing: Your code displays as a HTML5 player while mine is displayed as flash, wtf? Am I missing something here or what?

Randy

JW Player Support Agent  
0 rated :

Hello Carl,

YouTube is quite restrictive of their content and may limit how it is retrieved or implemented. This may explain why your code is not working unfortunately. If you reference the URL directly does it work for you then?

Randy

eric.madsen

User  
0 rated :

Randy - yes and no. The code -

jwplayer().onReady(function(){
jwplayer().setCurrentCaptions("true");
});

does turn on captions. Unfortunately I started down this research in order to use JW Player for audio playback - my apologies for the original code which shows a video. The captions only show in Flash mode.

Our solution might be to make mp4 audio only files, but then we lose the play controls being always on.

I do miss the ability to leave the play controls on. Also the "default": "true" has spotty behavior based on the cookie. As a developer I sometimes want to force a behavior. There is the code you list above, but it seems like if the default method overrode the cookie it would be more intuitive.

Thanks,
Eric

This question has received the maximum number of answers.