Your approach looks good! (I’d just rename the fn parameter in your JS to url to make things less confusing.)
The error you’ve encountered does not seem to have anything to do with audio, though!
If the compiler does not detect any ports being used in your program at all, it won’t even define .ports on your app. So when you try to call app.ports.play.subscribe() on page load, it fails to read .play because app.ports does not exist.
Now, it sounds like you do have defined and used a port, but it’s hard to tell what’s actually going on without seeing the full picture.
I have defined type Msg = NoOp | ChangeName | Play, but the compiled JS for the update function doesn’t seem to include the Play msg, and I have no idea how to add it in.
var $author$project$Main$update = F2(
function (msg, model) {
switch (msg.$) {
case 'NoOp':
return model;
case 'ChangeToName':
var s = msg.a;
return _Utils_update(
model,
{
currentItem: A2($author$project$Kontent$findItemFromTitle, s, model.kontent)
});
default:
return model;
}
});