Displaying song duration
I've been able to play media with a html5 audio element but the duration of the song never displays correctly, and when it plays the p开发者_运维百科rogress bar just fills up, although it does play fine. This is what I've been doing. I'm using ogg vorbis files.
- Started with jPlayer, had this problem.
- Heard the problem might be related to my Jetty server so I switched to Tomcat, but I still had this problem.
- Tried using the plain html5 audio element and the problem persisted.
- Put a video in my page with an html5 element, and that had the correct duration.
- I imported all my audio from CDs using the same program, so although I can see the duration any number of other ways I thought I might try files from some place else. So far every file I try has the problem.
I've been hearing about an Accept-Ranges header but I don't know how to see if I'm using that header, how I would make sure to use the header, or when I would use the header(do I send it with the html page, do I send with with the audio itself? Can I add a header to a file?)
I'm very new to web programming and figuring out the ropes have been tough. In the end I just added the "Accept-Ranges" : "bytes" to every response my server returned. I thought I would have to be careful what responses I added headers to but this is working out. In clojure with compojure which is the language and framework I'm working in I just use a middleware that adds "Accept-Ranges" : "bytes" to the response map under :headers and it looks like there is a setHeaders function in the response object in Java.
精彩评论