Taxel
Taxel

Reputation: 4207

Meteor: Youtube videos don't show on iOS and Android in production

In my meteor-react app I have embedded some YouTube videos. These work fine on all devices in debug mode but in production (where I can't use Chrome Inspect to debug it) the videos just don't show up on mobile devices. In the browser it always works perfectly.

In my implementation I first used a simple iframe to embed the video. This didn't work so I tried using the react-youtube package, which accesses the videos via the Youtube-API. This yielded the exact same behavior.

How can I fix this?

It might be a CORS error but adding

App.accessRule('youtube.com');
App.accessRule('http://*');
App.accessRule('https://*');

to my mobile-config.js did not help. I then tried adding the browser-policy package to my project and fixing all the errors it threw in the browser by adding

BrowserPolicy.content.allowOriginForAll("www.youtube.com"); //the www. was important
BrowserPolicy.content.allowOriginForAll("s.ytimg.com");
BrowserPolicy.content.allowMediaDataUrl();

to the Meteor.startup() function but this also had no results on mobile platforms.

Upvotes: 1

Views: 217

Answers (1)

Ruben
Ruben

Reputation: 836

You must allow specific access to resources outside your server's URL.

Add the following rule in your mobile-config.js file (this file should be in your root project directory):

App.accessRule('youtube.com');

Upvotes: 0

Related Questions