Hi there,
I am running in to some issues with audio on iOS - basically I have a scene set up with the default hotspots tutorial and wanted to play a sound on each hotspot selected - so I added a sound component to each with a slot titled ‘string’ - it’s working perfectly on desktop but doesn’t work at all on iOS - I’ve looked everywhere and am really stuck with it. I read that there needs to be a user interaction to begin a sound on mobile but thought this should count?
Any help would be very much appreciated.
Many thanks!
var Pulse = pc.createScript('pulse');
Pulse.attributes.add("pulseTimeSecs", {type: "number", default: 2, title: "Pulse Time Secs"});
// initialize code called once per entity
Pulse.prototype.initialize = function() {
this.secsSinceStart = this.pulseTimeSecs + 1;
this.entity.on("pulse:start", this.onStartEvent, this);
};
// update code called every frame
Pulse.prototype.update = function(dt) {
this.secsSinceStart += dt;
if (this.secsSinceStart <= this.pulseTimeSecs) {
var normalisedTime = this.secsSinceStart / this.pulseTimeSecs;
var pingPongTime = Math.abs(normalisedTime -0.5) * 2;
var scale = (0.3 * pingPongTime) + 0.7;
var localScale = this.entity.getLocalScale();
localScale.set(scale, scale, scale);
this.entity.setLocalScale(localScale);
}
};
Pulse.prototype.onStartEvent = function() {
this.secsSinceStart = 0;
this.entity.sound.play('string');
};