Note: This bug was fixed and the API now works as advertised.
I can change with code page backgrounds with images but not with videos using $w(Document).background.src
I’m talking about changing between stock Wix background videos in the Wix video manager, not external videos.
So with the API one can obtain the URLs for images and videos and they look like these:
wix:image://v1/8034aa3291a54c489a7b7a3121d994f9.png/Bananas.png#originWidth=1177&originHeight=1200
wix:video://v1/11062b_03c50f8fe4a34cc297a984e483a282ef/_#posterUri=/11062b_03c50f8fe4a34cc297a984e483a282eff000.jpg&posterWidth=1920&posterHeight=1080
I store the URL in session storage and then reload the page.
Then I can change the page background with this code inside the onReady():
$w("Document").background.src = "wix:image:// ...";
$w("Document").background.src = "wix:video:// ...";
Works for images, fails for videos.
Chrome just fails with this:
This lead me to believe that the URL for the video was bad.
I spent too much time looking, testing and looking some more for an answer.
Finally, using MS Edge, I got two different error messages that were helpful:
and occasionally:
Plugging one of the Wix video URLs into Chrome gives this 403 error:
So I have to conclude that Wix/Corvid is not allowing my Wix pages to access stock Wix videos in the Wix video manager - which should be an error on the Wix/Corvid end, not a feature.
Here is a test page so you can see the error messages when requesting a change of video background:
(use Chrome or MS Edge and look at console - FireFox has an error message that blocks the other messages)
https://www.ualmatrix.com/clock-minimal-image
After initial load click the “Show URL” button first so you can confirm the current video URL.Then select backgrounds from the “Theme” dropdown list.
Note that the images work (page reloads and changes background image inside the onReady() ), and the videos have various failures:
Sometimes they fail with a 403 message and no backup image, and others show the backup image without an error message.
Occasionally a CORS error pops up too.
Full URL for Wix video background “Ocean”
wix:video://v1/11062b_95d34f15761e4114a57b17823228948e/_#posterUri=11062b_95d34f15761e4114a57b17823228948ef000.jpg&posterWidth=1920&posterHeight=1080
Apparently, that gets converted internally by the Wix server to:
https://video.wixstatic.com:443/11062b_95d34f15761e4114a57b17823228948e/1080p/mp4/file.mp4
And since Wix thinks thinks my Wix page should not have access to that URL, it loads the poster instead (some files do and some don’t):
_#posterUri=11062b_95d34f15761e4114a57b17823228948ef000.jpg&posterWidth=1920&posterHeight=1080
To summarize the dilemma:
If my Wix/Corvid pages can change stock Wix background images, then the same should also apply to stock Wix background videos. Instead, the video URLs are blocked, resulting in a 403/CORS error.
Since videos are bandwidth intensive, I can see why Corvid would be careful with them, but it seems they went a bridge too far when a Wix/Corvid page cannot access Wix/Corvid stock videos.
Maybe I’m overlooking something I can do on my end, but this looks very much like a problem on the Wix end of things.
Wix/Corvid has server settings that allow page background image changes in the onReady() part of pages. But, it prohibits page background videos to be changed the same way as the images.
Looks like a Wix/Corvid system error to me (or a flawed policy), not a feature.
Since this is a suspected bug, I sent it to tech support.
They told me to place the concern in the forums - the usual circular reference games.
Any assistance with this matter is greatly appreciated.