Manually changing <video src="..."> works. Programmatically it does not :(

The title already explains my problem. I can manually change the src="…" of a video element in the Firefox Inspector, by double clicking on the src="…" and editing it. The player shows the video (actually the same video, just a higher resolution) and I can start it.

When I try to do this programmatically it fails: “The media could not be loaded, either because the server or network failed or because the format is not supported”.

var video = document.getElementById(“video_html5_api”);
var str = video.src.replace(“720p.mp4”, “1080.mp4”);
video.src = str;

Any idea how I can fix this problem? What is the manual way doing differently?

I should add, I did a lot of debugging and I am sure the value for src changed in the programmatic approach. It should be identical to the manual edit. Still the outcome is different.

How do I write my code that the outcome is identical to the manual edit?

Probably too late by now, but one thing I’d suggest - if possible - is to start with the 1080.mp4 and then try switching to the 720p.mp4 and see if you get the same behavior. If the problem really is related to switching the .src it will still show up; if it’s a different issue that manifests itself in this way the behavior might change and give a clue.
Also, did you do any debugging around type/canPlayType? Might be one more thing to check.