Display subtitles in Chromecast on Android

Hi Nicolas,
in order to be able to view side loaded subtitle tracks on Chromecast the URL needs to be provided with the according CORS headers.

You can verify that this is the problem by using one of the free online CORS proxy like https://allorigins.win/:

ArrayList<SubtitleTrack> subtitles = new ArrayList<SubtitleTrack>();
subtitles.add(new SubtitleTrack("https://api.allorigins.win/raw?url=https://downtown.homologacao.attri.com.br/storage/legendas/1614372023010463b5d01de0310.vtt", null, "pt-br", "1", true, "pt-br"));

 sourceItem.setSubtitleTracks(subtitles);

E.g. the following headers should do the trick:

Referrer Policy: strict-origin-when-cross-origin
access-control-allow-credentials: true
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Content-Encoding, Accept
access-control-allow-methods: OPTIONS, GET, POST, PATCH, PUT, DELETE
access-control-allow-origin: *

For more details on how to debug such an issue on the cast receiver see this article and this community discussion.

Also see the official documentation on CORS requirements for media tracks used on Chromecast.