YouTube embed error 153 [AnkiMobile]

I have created a number of YouTube video html embedding which work in desktop and android but not on iPhone 17.

I get the error:

Error 153
Video player configuration error

There seem to be no entries in the forum on this. And nothing comes up on google for Anki. ChatGPT is saying it’s a iOS security thing.

To be useful, I need to have the video display inside the app. Otherwise too much work jumping back and forth between Anki and YouTube.

Any ideas?

The embedding follows this structure:

iframe width=“560” height=“315” src=“youtube link” title=“YouTube video player” frameborder=“0” allow=“accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share” referrerpolicy=“strict-origin-when-cross-origin” allowfullscreen=“”></iframe

Edit: just realized, might be because this is a work phone and I work with high security limitations.

Edit 2: problem now confirmed on my private iPad. Hence, problem is NOT work security related.

I’ve moved this to Anki > Card Design , because if the problem isn’t with YT, I think it could be in your iframe code or in how iframes are handled for security reasons.

It would probably be useful if you pasted that embed code –
```

in a code/preformatted-text block

```
– so folks can see exactly what you’re doing. It’s too hard to tell if things like smart quotes and obviously missing brackets are your errors or things that the forum is doing to your text.

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/hnH3rnLZCKE?si=r7HCYKnQPsgnAHMx" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/0UmvUy1LziE?si=GDaJH3N-rEtfYSyA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

I’ve been running into this too. It used to be (a few weeks/months ago) that I could close and reopen AnkiMobile and it would fix itself, which is annoying, but now a lot of them are having this issue. Working fine on desktop.

The second one is an embed that used to be working on AnkiMobile and now isn’t, the first one is a video I tried to embed just now and ran into this because I haven’t recently tried to review the other cards with embedded youtube videos on them on mobile. The code from the first one was just now copied from youtube’s share → embed, and should show that the code hasn’t changed on youtube’s end.

edit: different app, but perhaps this could be relevant? Reddit - The heart of the internet

YouTube recently made changes to it’s enforcement of minimum supported browser functionality requirements when viewing videos/streams. (See full technical details here: YouTube API Services - Required Minimum Functionality  |  Google for Developers). The tl;dr is that YouTube needs to see some form of referrer value in the http request header before it will serve you the video player.

I don’t know how to tell what it’s sending as the origin in both cases, but I’m guessing it’s different somehow between anki desktop and AnkiMobile.

edit edit: It also still works on ankiweb.

OK I’m not 100% sure I’m doing this right, but I got the referrer property for the iframe.

It looks like on desktop the referrer property is:

http://127.0.0.1:56796/_anki/legacyPageData?id=1790549630864

(the id and port are different after closing and reopening)

On ankiweb it’s this:

https://ankiuser.net/study

On Ankimobile, however, it’s something completely different:

ankifile://reviewer/

I’m guessing this is what Youtube is now rejecting when it wasn’t rejecting before. Why is it not http/https in ankimobile? Any chance this could/will be changed?

I encountered the same issue trying to create a video player using YT Iframe API. The code works without a problem on Anki Desktop and AnkiWeb, but on AnkiMobile, I get the same Error 153.

Is this caused by the “referrer” header, as proposed by @nymvaline and is there any chance for a fix?

My code looks like the following:

        try {
            player = new YT.Player('video-container', {
                videoId: videoId,
                playerVars: { start: startSec, autoplay: 1, controls: 1 },
                events: {
                    onReady: (e) => e.target.playVideo(),
                    onStateChange: onStateChange,
                    onError: onPlayerError
                }
            });
        } catch (e) {
            showError(`Player initialization failed. Video ID: ${videoId}`);
        }

None of my error handling is triggered. I get a dark gray box where the video player should have been that says:

Watch video on YouTube
Error 153
Video player configuration error

Logged –