This is an old post, but the first one I hit when Googling for Text track from origin 'SITE_HOSTING_TEXT_TRACK' has been blocked from loading: Not at same origin as the document, and parent of track element does not have a 'crossorigin' attribute. Origin 'SITE_HOSTING_PAGE' is therefore not allowed access. Text track from origin 'SITE_HOSTING_TEXT_TRACK' has been blocked from loading: Not at same origin as the document, and parent of track element does not have a 'crossorigin' attribute. Origin 'SITE_HOSTING_PAGE' is therefore not allowed access.
It seems that the problem with this problem occurs locally, and it can fix it by disabling Chrome web security as shown above. But users will more often see this when accessing their text tracks from another domain. To fix this in a working environment for all users, you need to do two things:
- Add the correct CORS headers to the site hosting the VTT file.
- Add the
crossorigin="anonymous" attribute to the site's audio / video element.
If you don’t have access to the site that hosts the video file, you might be stuck. But if you do, you must add the header Access-Control-Allow-Origin:'*' . I process it on a Node / Express server as follows:
var app = express() app.use(function (req, res, next) { res.header('Access-Control-Allow-Origin', '*') res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') next() })
The audio / video element is an easier solution. On the HTML page of your site, add the following attribute.
<audio controls crossorigin="anonymous"> <source src="myaudio.mp3" type="audio/mpeg"> <track kink="caption" src="my_file_hosted_on_a_different_domain.vtt" srclang="en" label="English"> </audio>
I hope this answer helps someone ... It was an unpleasant problem to troubleshoot.
TimHayes
source share