Creating a python audio player using QWebView and the HTML5 Audio API
Asked Answered
F

1

8

I am seriously new to Python and my first project is quite ambitious :D

I'm trying to create an audio player using a QWebView and the HTML5 Audio API.

I want to use Phonon to actually play the media, but I'd like to be able to use the HTML5 Audio API to make an equalizer, like the one in Winamp.

I can get Phonon to play an audio file no problem, but is there a way to connect the audio output to my JavaScript so that I can play around with the different channels etc.?

Is it even the best way? I mean, would doing it this way limit the formats available to my player to those supported by WebKit, or would I still be able to play any format Phonon is able to play? (I'm assuming here, that Phonon would stream a raw/decoded version of the audio to my JavaScript, which I could then use via the Audio API)

If this isn't possible I could make a simple JavaScript wrapper around a Phonon AudioOutput object I suppose?

Any thoughts?

Finalism answered 17/2, 2012 at 8:1 Comment(1)
If you figured this out on your own, maybe post your solution as an answer? If not, and you still need it, perhaps posting sample code would help?Demonstrator
K
1

I haven't worked with the Qt framework, but peeking at the QWebView docs seems like there's no readily available solution to communicate with the window object.

If you want to work with a familiar protocol, then I suggest you look at the Flask microframework. It's basically a small piece of opinionated code where all the application behavior is provided by functions that receive and then return HTTP request and response objects. Here's the official streaming documentation so you can get an idea how building a response object looks like.

It seems you figured out how to generate the output, this would mean you'd only need to run the built-in Flask server at runtime and transport the audio data to your JavaScript client over HTTP.

Kaule answered 18/11, 2012 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.