Playing an Audio widget programmatically?
See original GitHub issueI tried to play an Audio widget programmatically, but I don’t see a play()
-like method to do that, like:
from ipywidgets import Audio
w = Audio.from_file("audio/a.mp3", autoplay=False, loop=False)
w.play()
# AttributeError: 'Audio' object has no attribute 'play'
Is it possible?
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
How to make an audio player widget in android - Stack Overflow
I want to make an audio player widget in which I have added there buttons for play , next and previous.Widget should show...
Read more >How to Play Audio from URL in Android? - GeeksforGeeks
How to Play Audio from URL in Android? · Step 1: Create a New Project · Step 2: Working with the activity_main.xml file...
Read more >MediaPlayer overview - Android Developers
This class is the primary API for playing sound and video. AudioManager: This class manages audio sources and audio output on a device....
Read more >Playing Audio in android Example - Javatpoint
package com.example.audiomediaplayer1; · import android.media.MediaPlayer; · import android.net.Uri; · import android.os.Bundle; · import android.app.Activity; ...
Read more >Build Full Music Player App in iOS & Swift Programmatically
Visit us at https://www.devtechie.com Downloadable content and source code(for new videos): https://www.patreon.com/DevTechieInc Spotify ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
tl;dr: I support adding a playing attribute to the audio/video widgets, and would support adding a volume attribute as well.
Currently the audio and video widgets have the following attributes exposed from the HTML media element:
autoplay
- start playing immediately on displayloop
- loop the audiocontrols
- boolean saying whether the browser should display controls.I think it makes sense to expose others that help in managing the media element. From https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement, for example, we could expose:
volume
(there is an event for volumechange we can use to notify the python side)playing
attribute that uses the.play()
and.pause()
methods to control the playback, and there are play/pause events we can use to notify the python sideThere are some other attributes we could expose like
muted
andplaybackRate
, but it’s not clear (a) how useful it would be and (b) what events could be used to send notification back to python if they changed from user interaction.My autoplay method is clunky and won’t give the kind of control that lets you stop playback, but it would work to trigger playback programmatically if you didn’t mind the side effects.
Generally speaking though a better solution (eg with widget code /use of web audio API as you mention) seems the smarter way to go, but I don’t know if there’s any progress there