Correct way to download an MP3 file?

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

Correct way to download an MP3 file?

ncrofts
Hi,

I'm using Orbeon 3.9 and from an XForm page need to download an MP3 file via a link (or HTML5 audio tag).
I need to dynamically construct the URL, so I submit the application parameters to an XPL pipeline. I then construct the final URL via XSLT and use the url-generator to load the file before serializing via the http-serializer processor.

Unfortunately this only seems to play back once.

I came across this article http://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not/1995977#1995977 which seems to imply this sort of problem could be caused by incorrect HTTP headers. In particular it refers to the header property "Content-Range".

The MP3 data seems to be generated / serialized but I've tried looking for Content-Range in the headers (via tcpmon) and although I see the "Range" header in the request I can't see "Content-Range" in the response. I'm guessing any headers in the response are auto-generated by the http-serializer processor.

Is it likely that this is indeed the cause of the failure to repeatedly playback? Also, is there a workaround to either generate any missing headers.

Alternatively is the generator/serializer method I'm using simply not the right approach for solving this problem?

Regards,
Neil
 
     <p:processor name="oxf:url-generator">
        <p:input name="config">
                 <config xsl:version="2.0">
                     <url>URL GOES HERE</url>
                     <content-type>audio/mpeg</content-type>
                     <force-content-type>true</force-content-type>
                 </config>
                </p:input>
        <p:output name="data" id="audio-data"/>
     </p:processor>     
       
    <p:processor name="oxf:http-serializer"> 
        <p:input name="config"> 
            <config> 
                <content-type>audio/mpeg</content-type> 
                <force-content-type>true</force-content-type> 
            </config> 
        </p:input> 
        <p:input name="data" href="#audio-data"/> 
    </p:processor>
Reply | Threaded
Open this post in threaded view
|

Re: Correct way to download an MP3 file?

Hank Ratzesberger-3
Hi Neil,

The config allows you to add your own headers, e.g.,:

<header>
  <name>Content-Range</name>
  <value>Bytes....</value>
</header>

but I suspect it is something else .... no clues from tcpmon? the request and 
response look like the first time?

Cheers,
Hank

http://wiki.orbeon.com/forms/doc/developer-guide/processors-http-serializer#TOC-Configuration

On Thu, Nov 3, 2011 at 3:28 PM, ncrofts <[hidden email]> wrote:
Hi,

I'm using Orbeon 3.9 and from an XForm page need to download an MP3 file via
a link (or HTML5 audio tag).
I need to dynamically construct the URL, so I submit the application
parameters to an XPL pipeline. I then construct the final URL via XSLT and
use the url-generator to load the file before serializing via the
http-serializer processor.

Unfortunately this only seems to play back once.

I came across this article
http://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not/1995977#1995977
which seems to imply this sort of problem could be caused by incorrect HTTP
headers. In particular it refers to the header property "Content-Range".

The MP3 data seems to be generated / serialized but I've tried looking for
Content-Range in the headers (via tcpmon) and although I see the "Range"
header in the request I can't see "Content-Range" in the response. I'm
guessing any headers in the response are auto-generated by the
http-serializer processor.

Is it likely that this is indeed the cause of the failure to repeatedly
playback? Also, is there a workaround to either generate any missing
headers.

Alternatively is the generator/serializer method I'm using simply not the
right approach for solving this problem?

Regards,
Neil

    <p:processor name="oxf:url-generator">
       <p:input name="config">
                <config xsl:version="2.0">
                    <url>URL GOES HERE</url>
                    <content-type>audio/mpeg</content-type>
                    <force-content-type>true</force-content-type>
                </config>
               </p:input>
       <p:output name="data" id="audio-data"/>
    </p:processor>

   <p:processor name="oxf:http-serializer">
       <p:input name="config">
           <config>
               <content-type>audio/mpeg</content-type>
               <force-content-type>true</force-content-type>
           </config>
       </p:input>
       <p:input name="data" href="#audio-data"/>
   </p:processor>


--
View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Correct-way-to-download-an-MP3-file-tp3988421p3988421.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Hank Ratzesberger
XMLWerks.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Correct way to download an MP3 file?

ncrofts
Hi Hank,

Thanks for your input. Although it is possible to add in headers in the config I'm not sure what byte range I'd have to set though? In the XPL the output of the url-generator is the binary data representing that document, but I don't think there is a way to determine from this the byte range - for example doing a string-length on the body doesn't correlate with the "Range" byte values shown below. I suspect the point where this information is available is inside the http-serializer. But I'm guessing here.

For what it is worth, the sequence of headers I see in tcpmon for a particular file are:

1. Initial request header:

GET /audio/alpha.mp3 HTTP/1.1
Host: 127.0.0.1:8123
Connection: keep-alive
Referer: http://localhost:8123/audio/alpha.mp3
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=39C14CD7408875D8C727535258BBEED0


2. Initial response header:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma:
Cache-Control: private, max-age=0
Expires: Fri, 04 Nov 2011 09:30:55 GMT
Last-Modified: Mon, 12 Sep 2011 22:23:59 GMT
Content-Type: audio/mpeg
Transfer-Encoding: chunked
Date: Fri, 04 Nov 2011 09:30:55 GMT
...plus binary data...


3. Next request header:

GET /audio/alpha.mp3 HTTP/1.1
Host: localhost:8123
Connection: keep-alive
Referer: http://localhost:8123/audio/alpha.mp3
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=39C14CD7408875D8C727535258BBEED0
Range: bytes=0-9215
If-Modified-Since: Mon, 12 Sep 2011 22:23:59 GMT


4. Final response header:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma:
Cache-Control: private, max-age=0
Expires: Fri, 04 Nov 2011 09:30:55 GMT
Last-Modified: Mon, 12 Sep 2011 22:23:59 GMT
Content-Type: audio/mpeg
Transfer-Encoding: chunked
Date: Fri, 04 Nov 2011 09:30:55 GMT
...binary data


I'm rapidly running out of ideas on how to solve this. I must be missing something as surely it can't be this difficult just to download a file in a way that most browsers understand?

Regards,
Neil
Reply | Threaded
Open this post in threaded view
|

Re: Re: Correct way to download an MP3 file?

Erik Bruchez
Administrator
Neil,

I am not clear whether your mp3 is served via
oxf:url-generator/oxf:http-serializer or via oxf:resource-server. The
latter would be the case if the resource is served by the PFC.

Either way, neither processor is able to serve Content-Range. So if
the issue is due to the Content-Range header being missing, the
solution is either to:

1) Improve oxf:resource-server or oxf:http-serializer (which is harder
because it doesn't have random access to its input in fact neither
does oxf:resource-server but it might be more efficient for it to get
random access).

2) Serve the file via other means (maybe the servlet container can serve it?).

-Erik

On Fri, Nov 4, 2011 at 3:33 AM, ncrofts <[hidden email]> wrote:

> Hi Hank,
>
> Thanks for your input. Although it is possible to add in headers in the
> config I'm not sure what byte range I'd have to set though? In the XPL the
> output of the url-generator is the binary data representing that document,
> but I don't think there is a way to determine from this the byte range - for
> example doing a string-length on the body doesn't correlate with the "Range"
> byte values shown below. I suspect the point where this information is
> available is inside the http-serializer. But I'm guessing here.
>
> For what it is worth, the sequence of headers I see in tcpmon for a
> particular file are:
>
> 1. Initial request header:
>
> GET /audio/alpha.mp3 HTTP/1.1
> Host: 127.0.0.1:8123
> Connection: keep-alive
> Referer: http://localhost:8123/audio/alpha.mp3
> User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like
> Gecko) Chrome/12.0.742.91 Safari/534.30
> Accept: */*
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: en-US,en;q=0.8
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
> Cookie: JSESSIONID=39C14CD7408875D8C727535258BBEED0
>
>
> 2. Initial response header:
>
> HTTP/1.1 200 OK
> Server: Apache-Coyote/1.1
> Pragma:
> Cache-Control: private, max-age=0
> Expires: Fri, 04 Nov 2011 09:30:55 GMT
> Last-Modified: Mon, 12 Sep 2011 22:23:59 GMT
> Content-Type: audio/mpeg
> Transfer-Encoding: chunked
> Date: Fri, 04 Nov 2011 09:30:55 GMT
> ...plus binary data...
>
>
> 3. Next request header:
>
> GET /audio/alpha.mp3 HTTP/1.1
> Host: localhost:8123
> Connection: keep-alive
> Referer: http://localhost:8123/audio/alpha.mp3
> User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like
> Gecko) Chrome/12.0.742.91 Safari/534.30
> Accept: */*
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: en-US,en;q=0.8
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
> Cookie: JSESSIONID=39C14CD7408875D8C727535258BBEED0
> Range: bytes=0-9215
> If-Modified-Since: Mon, 12 Sep 2011 22:23:59 GMT
>
>
> 4. Final response header:
>
> HTTP/1.1 200 OK
> Server: Apache-Coyote/1.1
> Pragma:
> Cache-Control: private, max-age=0
> Expires: Fri, 04 Nov 2011 09:30:55 GMT
> Last-Modified: Mon, 12 Sep 2011 22:23:59 GMT
> Content-Type: audio/mpeg
> Transfer-Encoding: chunked
> Date: Fri, 04 Nov 2011 09:30:55 GMT
> ...binary data
>
>
> I'm rapidly running out of ideas on how to solve this. I must be missing
> something as surely it can't be this difficult just to download a file in a
> way that most browsers understand?
>
> Regards,
> Neil
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Correct-way-to-download-an-MP3-file-tp3988421p3989617.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Correct way to download an MP3 file?

ncrofts
Erik,

We were trying to use the oxf:url-generator/oxf:http-serializer to serve the file. It does appear to transfer the file to the client, but from the information we have it seem it requires the additional header information to satisfy the browser. Thanks for clarifying the options. I think we will need to pursue the external option to make this work.

Regards,
Neil