Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio player #43

Closed
psychemedia opened this issue Sep 5, 2018 · 3 comments

Comments

@psychemedia
Copy link

commented Sep 5, 2018

I'm wondering if there's a recognised way of displaying an audio media player as part of cell output in a Jupyter / IRkernel notebook?

What I'd like to be able to do is something like:

display('myFile.wav')
display('myMidi.mid')
display(myAudioObject)

There doesn't seem to be a display function for it - is the best route to try to wrap something as an HTMLwidget and then render that?

@flying-sheep

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2018

jupyterlab/notebook renders it all so you’d need a renderer that accepts an audio mime type on their side: https://github.com/jupyterlab/jupyterlab/blob/v0.34.7/packages/rendermime/src/factories.ts

and a repr::repr_html.audio method on our side (provided the class of the object is “audio”)

so yeah: shiny::tags$audio(src = 'https://...') is probably your best bet, as a repr_html.shiny.tag exists.

@psychemedia

This comment has been minimized.

Copy link
Author

commented Sep 6, 2018

Ah - thanks... shiny::tags looks really handy.

(The tags$audio doesn't seem to work for me atm, though other tags constructions do, eg tags$h1("My header"), so maybe I'm missing some other bit of setup... Ho hum... rabbit holes..)

Works fine, thanks, once fully declared, eg:

library(shiny)
tags$audio(src = 'test.mp3',  type = "audio/mp3", autoplay = NA, controls = NA)

Or without autoplay:

tags$audio(src = 'test.wav', type = "audio/wav", controls = NA)

@psychemedia psychemedia closed this Sep 6, 2018

@flying-sheep

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2018

great 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.