Question

Page changes with TurboLinks get rid of the flash video inserted by SoundManager2, breaking it . When I play something it throws (Chromium 25):

Uncaught TypeError: Object #<HTMLEmbedElement> has no method '_createSound'

I tried calling reboot:

soundManager.reboot() if soundManager.ok()

But then it throws has no method '_destroySound'.

Does anyone have any idea how to fix that?

Was it helpful?

Solution

This code fixed it:

recreateSoundManager = ->
  sm2 = window.soundManager
  if sm2?.ok()
    sm2 = window.soundManager = new SoundManager() 
  sm2

Call this on turbolinks page load before the setup of soundmanager2. Then you can either use the return value or access normally from window.soundManager.

Example with jquery.turbolinks:

jQuery ->
  soundManager = recreateSoundManager()
  soundManager.setup url: '/'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top