• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Playing audio file from Servlet in Jsp page.

 
ruba ramesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have audio files stored as blob in MySql DB. I woule like to play the audio files in JSP. To achieve this, song_id is passed as parameter to servlet. Servlet retrieves the blob from DB and writes the blob as bytes in OutputStream of response object of Servlet.


Problem is I am not able to play the song in JSP file.

Tried following ways to do it.

1. Used JPlayer.
2. Embedding audio player pointing to servlet' URL as src.

<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="player" width="200" height="300">
<param name="url" value="<%=request.getContextPath()%>" />
<param name="src" value="GetSongForPlay?song_id=49"/>
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
<embed src="<%=request.getContextPath()%>/GetSongForPlay?song_id=49" width="<%=200%>" height="<%=300%>"></embed>
</object>

3. Used HTML5 audio tag.


But, I am not successful in playing song. Song is of type of mp3 or wav.

Can anybody suggest how to approach this?


Thanks
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ruba ramesh wrote:Hi,
3. Used HTML5 audio tag.
But, I am not successful in playing song. Song is of type of mp3 or wav.


Before using the servlet have you tried to only use local HTML file with the audio tag and load it to see if it is work outside the servlet environment. What browser are you use to run the HTML audio? Please make sure that your browser support the audio format.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Jplayer support such streaming? AFAIK the embedded file must exist somewhere as a complete file, like Flash content. I have never embedded streaming content.
 
ruba ramesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Wayan Saryada wrote:
ruba ramesh wrote:Hi,
3. Used HTML5 audio tag.
But, I am not successful in playing song. Song is of type of mp3 or wav.


Before using the servlet have you tried to only use local HTML file with the audio tag and load it to see if it is work outside the servlet environment. What browser are you use to run the HTML audio? Please make sure that your browser support the audio format.




Hmm.. Good idea. I tried out. HTML 5 is supported by Google chrome. This http://www.w3schools.com/html/html5_audio.asp reveals it's supported in IE9 and Chrome for mp3.

Thanks for the suggestion.

Rupa
 
ruba ramesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit Ghorpade wrote:Does Jplayer support such streaming? AFAIK the embedded file must exist somewhere as a complete file, like Flash content. I have never embedded streaming content.


https://groups.google.com/group/jplayer/tree/browse_frm/month/2010-07/4c49ec0990b48360?rnum=21&_done=/group/jplayer/browse_frm/month/2010-07?&pli=1&auth=DQAAAIIAAACprnU-2LIrrsbGHf2GRZMCzaDNkowdairlcH0RhoAkkm_PyS2AcxJCltRtZeX2367CVZrzcLlxJZ9wLr0HmT06tLZdaHDm5uBMlUQUXWPckF9t5uNd2whcIRaQNEAEpWR_xcvz2M6wXAxlvy668_chBAaOCbic0GVuJFJVY4gvclUN0qyZPFtN8cRXjuh_b7M&authuser=0

says it's possible to have streaming audio.

Thanks

Rupa
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not streaming audio. Whether the data exists as a file on the server, or is delivered by a servlet is moot at the client. The response looks the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic