I am trying to connect the HTML iframe element to my database on the dynamic page. I have looked at earlier solutions in the discussions, but have run into a new problem that I cannot find the answer to.
This is what I have so far. All of the text and buttons are connected to the Composers database. I have found some code that seems to work for the #html1 element:
Right now, the soundcloud url is https:// soundcloud. com/ brendan jacklin/hbeart-niloufar-nourbakhsh, drawing from the recording field in the database (set to url) and I have no idea why it is showing that.
If it is not possible to work with urls, is there a way to do it directly from the embed code on the Soundcloud player?
If the URL isn’t working you should be able to use the embed code instead but you will have to use the postMessage() function as the src value will only allow URLs.
You should find the following article helpful, skip down to the messaging section.
Thanks for the link. I did try to get the postMessage() to work, but I’m pretty sure I did something wrong.
I tried to get the embed code from the dynamicDatabase on the page and I changed the click event to a viewport enter event, but right now it is just not displaying anything.
Currently I have this for my Wix code:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#html1").onMessage( (event) => {
console.log(`Message received by page code: ${event.data}`);
} );
} );
export function html1_viewportEnter(event) {
$w("#html1").postMessage($w("#dynamicDataset").getCurrentItem("embed"));
}
where embed is the name of the field with the embed codes in my database.
I have tried changing various things, but cannot get it to work.
It’s not that your code is wrong, Sound Cloud simply does not allow embedding via URL. They want you to use their source code because they collect data for analytical purposes.
Unfortunately, you cannot change the iFrame code dynamically. You would have to physically embed each iFrame individually and/or embed the playlist individually.