# Audio Issue: Safari and iOS

**URL:** https://discourse.processing.org/t/audio-issue-safari-and-ios/7485
**Category:** Libraries
**Created:** [January 13, 2019, 11:04pm UTC](https://discourse.processing.org/t/audio-issue-safari-and-ios/7485 "2019-01-13T23:04:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![djw](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@djw](https://discourse.processing.org/u/djw)
#### Post date: [January 13, 2019, 11:04pm UTC](https://discourse.processing.org/t/audio-issue-safari-and-ios/7485/1 "2019-01-13T23:04:24Z")

</div>

I’ve just been working on a simple p5.js script and thought it was working well as in Chrome things are fine:

[now.danieljwilson.com](http://now.danieljwilson.com)

However I just get `Loading...` when I try to view it on Safari or on Chrome on my iPad.

I have updated to the latest versions of `p5.js` (v0.7.2) and `p5.sound.js` (v0.3.8).

I am using an ogg audio snippet.

The error is:

```auto
 The error stack trace includes: 
preload@http://now.danieljwilson.com/Schedule_Web.js:15:20

```

Line 15 of the script is:  
`sound = loadSound('assets/Electronic_Chime.ogg');`

And the full script is below. Any ideas greatly appreciated!

```auto
var sched_h = [8, 8, 9, 9,11,11,12,12,15,16,18,18,19,20,21]; //need to add pomodoro breaks
var sched_m = [0,45,30,45,15,30,15,45,45, 0, 0,30,30,30,30];
var sched_event = ["STATS/MATH", "PROGRAMMING","BREAK","WORK 1/WRITE","BREAK","READ","LUNCH","WORK 2", "BREAK", "WORK 3", "COMMUTE", "DINNER", "RESEARCH", "SING/STRETCH"];
var color_array = [0,0,1,0,1,0,1,0,1,0,2,2,2,2];

var sound;
var previous_event = 0;

var myFont;
function preload() {
  myFont = loadFont('assets/Hasklig-ExtraLight.otf');
  sound = loadSound('assets/Electronic_Chime.ogg');
}

function setup() {
  createCanvas(displayWidth, displayHeight);
  noStroke();
  // Set text characteristics
  textFont(myFont);
  textSize(32);
  textAlign(CENTER, CENTER); 
}

function draw() {
  background(204);
  var s = second();
  var m = minute(); // Values from 0 - 59
  var h = hour(); // Values from 0 - 23
  
  for (var i = 0; i<sched_event.length; i = i+1){
    var task_time_start = (sched_h[i] * 60 + sched_m[i]) * 60; // in seconds
    var task_time_end = (sched_h[i+1] * 60 + sched_m[i+1]) * 60; // in seconds

    var current_time = s + 60*(m + 60*h);
    
    if (current_time >= task_time_start && current_time < task_time_end){
      var current_task = sched_event[i];
      var duration = task_time_end - task_time_start;
      var elapsed = current_time - task_time_start;
      var colour = color_array[i];
      var current_event = i;
    }
  }
  print("current_event: " + current_event)
  print("previous_event: " + previous_event)
  if (current_event != previous_event) {
    sound.play();
  }
  previous_event = current_event;

  // color: 0/1/2 -> work/break/self
  if (colour == 0){
    fill(66,158,244, 60);
  }
  if (colour ==1){
    fill(118,219,107, 60);
  }
  if (colour ==2){
    fill(216,168,34, 60);
  }
  
  rect(0,0,width,height);
  rect(0, 0, elapsed * width/duration, height);
  
  textSize(60);
  fill(0);
  text(current_task, width/2, height/2);
 
}

function mousePressed() {
  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
    var fs = fullscreen();
    fullscreen(!fs);
    sound.play();
  }
}

function windowResized() {
  resizeCanvas(displayWidth, displayHeight);
}

```

---

<div class="post-metadata">

### Author: ![fimfin](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fimfin](https://discourse.processing.org/u/fimfin)
#### Post date: [October 3, 2019, 7:01pm UTC](https://discourse.processing.org/t/audio-issue-safari-and-ios/7485/2 "2019-10-03T19:01:49Z")

</div>

Daniel,  
Hi there. Did you ever this to work? I wasn’t sure from the URL. I’m having the exact same issue with an .mp3 audio file. Plays fine in the browser but not in Safari on an iPad.

Also using sound = loadSound();  
Thanks,  
Dermot

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [October 4, 2019, 1:45am UTC](https://discourse.processing.org/t/audio-issue-safari-and-ios/7485/3 "2019-10-04T01:45:28Z")

</div>

i not know how much that little bit ?old? post is still valid,  
-a- you use different file type  
-b- there is a new p5.js version

please test again your 2 browser/devices:  
[https://editor.p5js.org/p5/sketches/Sound:\_Amplitude\_Analysis](https://editor.p5js.org/p5/sketches/Sound:_Amplitude_Analysis)  
as there code and song file is available to all who want help you  
and also test that on their systems.  
( pls can download and check, it uses the latest p5.js 0.9.0, p5.sound.min.js v0.3.11 )

also pls report more exact: systems and version numbers
