1

The question is similar to Automatically play sound in IPython notebook - the diffrence is I need to play the sound several times. At the browser side - not the server.

The most naive approach:

IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)
time.sleep(10)
IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)

does not work as it plays the sound once. Moreover, it seems that it is necessary for IPython.display.Audio object to be the output of the cell, as:

IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)
None

plays no sound.

Splitting the code into several cells is not an option.

abukaj
  • 2,582
  • 1
  • 22
  • 45

1 Answers1

1

I have figured it out (and cleaned my code a bit):

horse = IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg",
                              autoplay=True)
IPython.display.display(horse)
time.sleep(10)
IPython.display.display(horse)
abukaj
  • 2,582
  • 1
  • 22
  • 45