livebook-dev / kino

Client-driven interactive widgets for Livebook
Apache License 2.0
361 stars 60 forks source link

Add play and pause to audio #458

Closed relardev closed 1 month ago

relardev commented 1 month 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