Listening music

We will add an audio player to the page that will stay when page changes. This emphasises the fact that browsing inside an application does not stop the client side code: the music keeps playing when the content of the page and the url change.

We first create the player node at toplevel.

let player =
  Eliom_content.Html5.Id.create_global_elt
    (audio
       ~srcs:(make_uri (Eliom_service.static_dir ())
                  ["music.ogg"],
              [])
       ~a:[a_autoplay (`Autoplay);a_controls (`Controls)]
       [pcdata "Your browser does not support audio element" ])

And we insert the player in the page.

And that's all ! Since the player node is declared unique, no new player is created when the page changed: this is exact same node.

To run this example, you will need to add an ogg file in the static directory. If you can't find one, there is one here: http://www.gnu.org/music/free-software-song.html.