Thanks Massimo, this is working!

What I am not able to get is the time-slider to work in the audio element. 
I guess that since I am streaming the audio file, the browser has no way of 
knowing the size.

Is there a way to solve this problem? Is it possible to send the size of 
the audio file in the response headers? I am dealing with mp3 files mainly. 
I am not sure if it is possible to know beforehand (without 
reading/decoding the full mp3 file) the length of the audio track. I would 
say that the mp3 format (and other audio formats) must have some metadata 
at the beginning of the file specifying things like duration, volume, ... 
but I am not familiar with these details.

And as a more general problem: is it possible at all to randomly access a 
streaming audio file? I would say that this is not possible.

Any ideas / workarounds to get the slider working?

Thanks,
Daniel

On Thursday, August 9, 2012 3:29:25 PM UTC+2, Massimo Di Pierro wrote:
>
> <audio 
> src="{{=URL('getme',args='track06.mp3<http://www.myserver.com/.../track06.mp3>
> ')}}" preload="auto"></audio>
>
> def getme():
>    import urllib
>    response.headers['Content-Type'] = 'audio/mp3'   
>    filename = '....'+request.args(0) # fix this!
>    return response.stream(urllib.urlopen(filename))
>   
>
> On Thursday, 9 August 2012 03:54:43 UTC-5, Daniel Gonzalez wrote:
>>
>> Hello,
>>
>> I have some sound files in a couchdb database (not related to web2py). My 
>> web2py application has access to this database, and I want to stream the 
>> sound files so that they can be listened with the HTML audio tag, like this:
>>
>> <audio src="http://www.myserver.com/.../track06.mp3"; preload="auto"
>> ></audio>
>>
>> I am planning to do this streaming as follows:
>>
>> response.stream(open(filename),chunk_size=4096)
>>
>> But I have some open questions:
>>
>>    1. My "filename" is not in the local filesystem, but in a couchdb 
>>    database, accessible via REST. How can I "open" that?
>>    2. What kind of request will the audio tag send when it is activated, 
>>    GET/POST/...? Can this be handled with web2py?
>>
>> Thanks,
>> Daniel
>>
>

-- 



Reply via email to