livebook-dev / kino

Client-driven interactive widgets for Livebook
Apache License 2.0
372 stars 65 forks source link

Add play and pause to audio #458

Closed relardev closed 4 months ago

relardev commented 4 months ago

Addresses https://github.com/livebook-dev/kino/issues/457

Adds support for play and pause functions for Kino.Audio.

I have tested it with:

Untitled notebook

Section

req =
  Req.get!(
    "https://file-examples.com/storage/fe9f6f893066954d9aac3a2/2017/11/file_example_MP3_5MG.mp3"
  )

kino = Kino.Audio.new(req.body, :mp3)
for n <- 0..11 do
  case rem(n, 2) do
    0 -> Kino.Audio.play(kino)
    1 -> Kino.Audio.pause(kino)
  end

  :timer.sleep(1000)
end