How can I control the html5 audio which from mongodb?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I control the html5 audio which from mongodb?

xunitc
Hi.

I use html5 audio and mongodb.
here is some sources:

controller:
def audio(String id) {
        GridFSDBFile gfile = gridFSService.find(id);
        if (gfile) {
                response.setHeader("Content-Disposition", "fileName=" + gfile.getFilename());
                response.outputStream << gfile.getInputStream();
                response.contentLength = gfile.length;
                response.contentType = gfile.getContentType();
                return;
        }
}

gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)

<audio src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c" controls="controls">my audio</audio>

Now I can play the wav audio, but I can not forward or backward it.
How can I forward or backward it please?
Xunitc
Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

sergiomichels
You will have to change the source of your audio though javascript. Check an example: http://jonhall.info/examples/html5_audio_playlist_example.html

--
Sérgio Michels


On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
Hi.

I use html5 audio and mongodb.
here is some sources:

controller:
def audio(String id) {
        GridFSDBFile gfile = gridFSService.find(id);
        if (gfile) {
                response.setHeader("Content-Disposition", "fileName=" +
gfile.getFilename());
                response.outputStream << gfile.getInputStream();
                response.contentLength = gfile.length;
                response.contentType = gfile.getContentType();
                return;
        }
}

gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)

<audio
src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
controls="controls">my audio</audio>

Now I can play the wav audio, but I can not forward or backward it.
How can I forward or backward it please?



-----
Xunitc
--
View this message in context: http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

xunitc
Hi.
Thanks for Sérgio Michels.

I see the link, and see the html source.
But I do not know is the mp3 source on disk as a file or in mongodb as a stream?
If it as a file, yes, it works good at me too.

But my *.wav,*.odd, *.mp3 audio in mongodb and get it as a stream and
put to response.outputStream.
In that way, when I play sequentially, it is good too. only forward or
backward, it will touch an exception in server.
It tells me getOutputStream() has already been called.
So, is there a way to play the audio which is response.outputStream?

Some suggestions please?

2013/5/21 Sergio Michels <[hidden email]>:

> You will have to change the source of your audio though javascript. Check an
> example: http://jonhall.info/examples/html5_audio_playlist_example.html
>
> --
> Sérgio Michels
>
>
> On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
>>
>> Hi.
>>
>> I use html5 audio and mongodb.
>> here is some sources:
>>
>> controller:
>> def audio(String id) {
>>         GridFSDBFile gfile = gridFSService.find(id);
>>         if (gfile) {
>>                 response.setHeader("Content-Disposition", "fileName=" +
>> gfile.getFilename());
>>                 response.outputStream << gfile.getInputStream();
>>                 response.contentLength = gfile.length;
>>                 response.contentType = gfile.getContentType();
>>                 return;
>>         }
>> }
>>
>> gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)
>>
>> <audio
>> src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
>> controls="controls">my audio</audio>
>>
>> Now I can play the wav audio, but I can not forward or backward it.
>> How can I forward or backward it please?
>>
>>
>>
>> -----
>> Xunitc
>> --
>> View this message in context:
>> http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
>> Sent from the Grails - user mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Xunitc
Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

sergiomichels
response.outputStream << gfile.getInputStream();

This will write you content in the outputStream and flush, change that to be the last line of your action.

--
Sérgio Michels


On Mon, May 20, 2013 at 7:16 PM, xunitc <[hidden email]> wrote:
Hi.
Thanks for Sérgio Michels.

I see the link, and see the html source.
But I do not know is the mp3 source on disk as a file or in mongodb as a stream?
If it as a file, yes, it works good at me too.

But my *.wav,*.odd, *.mp3 audio in mongodb and get it as a stream and
put to response.outputStream.
In that way, when I play sequentially, it is good too. only forward or
backward, it will touch an exception in server.
It tells me getOutputStream() has already been called.
So, is there a way to play the audio which is response.outputStream?

Some suggestions please?

2013/5/21 Sergio Michels <[hidden email]>:
> You will have to change the source of your audio though javascript. Check an
> example: http://jonhall.info/examples/html5_audio_playlist_example.html
>
> --
> Sérgio Michels
>
>
> On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
>>
>> Hi.
>>
>> I use html5 audio and mongodb.
>> here is some sources:
>>
>> controller:
>> def audio(String id) {
>>         GridFSDBFile gfile = gridFSService.find(id);
>>         if (gfile) {
>>                 response.setHeader("Content-Disposition", "fileName=" +
>> gfile.getFilename());
>>                 response.outputStream << gfile.getInputStream();
>>                 response.contentLength = gfile.length;
>>                 response.contentType = gfile.getContentType();
>>                 return;
>>         }
>> }
>>
>> gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)
>>
>> <audio
>> src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
>> controls="controls">my audio</audio>
>>
>> Now I can play the wav audio, but I can not forward or backward it.
>> How can I forward or backward it please?
>>
>>
>>
>> -----
>> Xunitc
>> --
>> View this message in context:
>> http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
>> Sent from the Grails - user mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

xunitc
Hi.
Thanks a lot, Sérgio Michels!

With your help, I put the response.outputStream <<
gfile.getInputStream() at the last line.
And I try this: response.setHeader("Accept-Ranges", "bytes");
Now for the ogg file, I can  forward and backward it in Chrome. I will
try other audio types and other browsers.

Thanks again!

2013/5/21 Sergio Michels <[hidden email]>:

> response.outputStream << gfile.getInputStream();
>
> This will write you content in the outputStream and flush, change that to be
> the last line of your action.
>
> --
> Sérgio Michels
>
>
> On Mon, May 20, 2013 at 7:16 PM, xunitc <[hidden email]> wrote:
>>
>> Hi.
>> Thanks for Sérgio Michels.
>>
>> I see the link, and see the html source.
>> But I do not know is the mp3 source on disk as a file or in mongodb as a
>> stream?
>> If it as a file, yes, it works good at me too.
>>
>> But my *.wav,*.odd, *.mp3 audio in mongodb and get it as a stream and
>> put to response.outputStream.
>> In that way, when I play sequentially, it is good too. only forward or
>> backward, it will touch an exception in server.
>> It tells me getOutputStream() has already been called.
>> So, is there a way to play the audio which is response.outputStream?
>>
>> Some suggestions please?
>>
>> 2013/5/21 Sergio Michels <[hidden email]>:
>> > You will have to change the source of your audio though javascript.
>> > Check an
>> > example: http://jonhall.info/examples/html5_audio_playlist_example.html
>> >
>> > --
>> > Sérgio Michels
>> >
>> >
>> > On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
>> >>
>> >> Hi.
>> >>
>> >> I use html5 audio and mongodb.
>> >> here is some sources:
>> >>
>> >> controller:
>> >> def audio(String id) {
>> >>         GridFSDBFile gfile = gridFSService.find(id);
>> >>         if (gfile) {
>> >>                 response.setHeader("Content-Disposition", "fileName=" +
>> >> gfile.getFilename());
>> >>                 response.outputStream << gfile.getInputStream();
>> >>                 response.contentLength = gfile.length;
>> >>                 response.contentType = gfile.getContentType();
>> >>                 return;
>> >>         }
>> >> }
>> >>
>> >> gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)
>> >>
>> >> <audio
>> >> src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
>> >> controls="controls">my audio</audio>
>> >>
>> >> Now I can play the wav audio, but I can not forward or backward it.
>> >> How can I forward or backward it please?
>> >>
>> >>
>> >>
>> >> -----
>> >> Xunitc
>> >> --
>> >> View this message in context:
>> >>
>> >> http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
>> >> Sent from the Grails - user mailing list archive at Nabble.com.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>     http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Xunitc.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Xunitc
Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

sergiomichels
Glad to help! :-)

--
Sérgio Michels


On Tue, May 21, 2013 at 12:50 PM, xunitc <[hidden email]> wrote:
Hi.
Thanks a lot, Sérgio Michels!

With your help, I put the response.outputStream <<
gfile.getInputStream() at the last line.
And I try this: response.setHeader("Accept-Ranges", "bytes");
Now for the ogg file, I can  forward and backward it in Chrome. I will
try other audio types and other browsers.

Thanks again!

2013/5/21 Sergio Michels <[hidden email]>:
> response.outputStream << gfile.getInputStream();
>
> This will write you content in the outputStream and flush, change that to be
> the last line of your action.
>
> --
> Sérgio Michels
>
>
> On Mon, May 20, 2013 at 7:16 PM, xunitc <[hidden email]> wrote:
>>
>> Hi.
>> Thanks for Sérgio Michels.
>>
>> I see the link, and see the html source.
>> But I do not know is the mp3 source on disk as a file or in mongodb as a
>> stream?
>> If it as a file, yes, it works good at me too.
>>
>> But my *.wav,*.odd, *.mp3 audio in mongodb and get it as a stream and
>> put to response.outputStream.
>> In that way, when I play sequentially, it is good too. only forward or
>> backward, it will touch an exception in server.
>> It tells me getOutputStream() has already been called.
>> So, is there a way to play the audio which is response.outputStream?
>>
>> Some suggestions please?
>>
>> 2013/5/21 Sergio Michels <[hidden email]>:
>> > You will have to change the source of your audio though javascript.
>> > Check an
>> > example: http://jonhall.info/examples/html5_audio_playlist_example.html
>> >
>> > --
>> > Sérgio Michels
>> >
>> >
>> > On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
>> >>
>> >> Hi.
>> >>
>> >> I use html5 audio and mongodb.
>> >> here is some sources:
>> >>
>> >> controller:
>> >> def audio(String id) {
>> >>         GridFSDBFile gfile = gridFSService.find(id);
>> >>         if (gfile) {
>> >>                 response.setHeader("Content-Disposition", "fileName=" +
>> >> gfile.getFilename());
>> >>                 response.outputStream << gfile.getInputStream();
>> >>                 response.contentLength = gfile.length;
>> >>                 response.contentType = gfile.getContentType();
>> >>                 return;
>> >>         }
>> >> }
>> >>
>> >> gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)
>> >>
>> >> <audio
>> >> src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
>> >> controls="controls">my audio</audio>
>> >>
>> >> Now I can play the wav audio, but I can not forward or backward it.
>> >> How can I forward or backward it please?
>> >>
>> >>
>> >>
>> >> -----
>> >> Xunitc
>> >> --
>> >> View this message in context:
>> >>
>> >> http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
>> >> Sent from the Grails - user mailing list archive at Nabble.com.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>     http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Xunitc.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: How can I control the html5 audio which from mongodb?

xunitc
I test some audios and videos.
In different browsers they are so different:

        Firefox(xub)   IE-10   Chrome(win7)   Chromium(xub)
audio:
mp3     No             Exp     Yes            No
ogg      No             No       Yes            Yes
wav      Exp           Exp      Yes            Exp
video:
mp4     No             Exp     Yes            Yes

xub = XUbuntu 12.04
No = maybe it can not support this type.
Yes = everything is good.
Exp = Throw an exception at server side. Nevertheless, it still can be
played correctly.

2013/5/22 Sergio Michels <[hidden email]>:

> Glad to help! :-)
>
> --
> Sérgio Michels
>
>
> On Tue, May 21, 2013 at 12:50 PM, xunitc <[hidden email]> wrote:
>>
>> Hi.
>> Thanks a lot, Sérgio Michels!
>>
>> With your help, I put the response.outputStream <<
>> gfile.getInputStream() at the last line.
>> And I try this: response.setHeader("Accept-Ranges", "bytes");
>> Now for the ogg file, I can  forward and backward it in Chrome. I will
>> try other audio types and other browsers.
>>
>> Thanks again!
>>
>> 2013/5/21 Sergio Michels <[hidden email]>:
>> > response.outputStream << gfile.getInputStream();
>> >
>> > This will write you content in the outputStream and flush, change that
>> > to be
>> > the last line of your action.
>> >
>> > --
>> > Sérgio Michels
>> >
>> >
>> > On Mon, May 20, 2013 at 7:16 PM, xunitc <[hidden email]> wrote:
>> >>
>> >> Hi.
>> >> Thanks for Sérgio Michels.
>> >>
>> >> I see the link, and see the html source.
>> >> But I do not know is the mp3 source on disk as a file or in mongodb as
>> >> a
>> >> stream?
>> >> If it as a file, yes, it works good at me too.
>> >>
>> >> But my *.wav,*.odd, *.mp3 audio in mongodb and get it as a stream and
>> >> put to response.outputStream.
>> >> In that way, when I play sequentially, it is good too. only forward or
>> >> backward, it will touch an exception in server.
>> >> It tells me getOutputStream() has already been called.
>> >> So, is there a way to play the audio which is response.outputStream?
>> >>
>> >> Some suggestions please?
>> >>
>> >> 2013/5/21 Sergio Michels <[hidden email]>:
>> >> > You will have to change the source of your audio though javascript.
>> >> > Check an
>> >> > example:
>> >> > http://jonhall.info/examples/html5_audio_playlist_example.html
>> >> >
>> >> > --
>> >> > Sérgio Michels
>> >> >
>> >> >
>> >> > On Mon, May 20, 2013 at 8:26 AM, xunitc <[hidden email]> wrote:
>> >> >>
>> >> >> Hi.
>> >> >>
>> >> >> I use html5 audio and mongodb.
>> >> >> here is some sources:
>> >> >>
>> >> >> controller:
>> >> >> def audio(String id) {
>> >> >>         GridFSDBFile gfile = gridFSService.find(id);
>> >> >>         if (gfile) {
>> >> >>                 response.setHeader("Content-Disposition",
>> >> >> "fileName=" +
>> >> >> gfile.getFilename());
>> >> >>                 response.outputStream << gfile.getInputStream();
>> >> >>                 response.contentLength = gfile.length;
>> >> >>                 response.contentType = gfile.getContentType();
>> >> >>                 return;
>> >> >>         }
>> >> >> }
>> >> >>
>> >> >> gsp:(5199eb08e4b0b10d4004904c is the id in mongodb)
>> >> >>
>> >> >> <audio
>> >> >>
>> >> >> src="http://localhost:8080/mycontroller/audio/5199eb08e4b0b10d4004904c"
>> >> >> controls="controls">my audio</audio>
>> >> >>
>> >> >> Now I can play the wav audio, but I can not forward or backward it.
>> >> >> How can I forward or backward it please?
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Xunitc
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >> >>
>> >> >> http://grails.1312388.n4.nabble.com/How-can-I-control-the-html5-audio-which-from-mongodb-tp4644944.html
>> >> >> Sent from the Grails - user mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe from this list, please visit:
>> >> >>
>> >> >>     http://xircles.codehaus.org/manage_email
>> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Xunitc.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>     http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Xunitc.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Xunitc