Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Carlos Arroyo
Front End Web Development Techdegree Graduate 15,431 PointsCaptions for a video.
I am trying to add captions for a video. I can't figure out what I am doing wrong.
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<video controls>
<source src="video/video.mp4" type="video/mp4">
<source src="video/video.ogg" type="video/ogg">
<track label="English" kind="subtitles" srclang="en" src="video_captions.vtt" default>
</video>
</body>
</html>
I have been getting the following error: Text track from origin 'file://' has been blocked from loading: Not at same origin as the document, and parent of track element does not have a 'crossorigin' attribute. Origin 'null' is therefore not allowed access.
I have found out that the captions work in Firefox but not Google Chrome. Is there a way to make it work in Google Chrome as well.
2 Answers
Adrian Navarro
7,424 Points<video controls>
<source src="video/video.mp4" type="video/mp4">
<source src="video/video.ogg" type="video/ogg">
<track label="English" kind="subtitles" srclang="en" src="captions/vtt/sintel-en.vtt" default>
</video>
I don't see anything wrong with your code, I would suggest checking the caption file source. It's a good practice to create a Folder for captions and type, something like I did on the example.
By the way, are you trying from a local server? Have you tried uploading everything to a WorkSpace and see if you have the same problem?
Adrian Navarro
7,424 PointsTry uploading your videos to vimeo or youtube and use the resource from there. There are many places where you can host your videos.
Carlos Arroyo
Front End Web Development Techdegree Graduate 15,431 PointsI uploaded the video to youtube, and then I added it to my html. The video didn't work in all the browser that I am testing the site in. Safari, firefox, and google chrome.
Carlos Arroyo
Front End Web Development Techdegree Graduate 15,431 PointsCarlos Arroyo
Front End Web Development Techdegree Graduate 15,431 PointsI am using a local server. I have tried to upload it to a workspace, but the videos are too big.