problem playing mp3 from database in jsp page
Hi,
I have searched a lot and at last found this forum,and i think i can find my solutions here......
Q->I have stored all my songs in my oracle database my db table is like this...CREATE TABLE SONGS_TABLE(title varchar2(20),songs BLOB); .
Creating an admin page in jsp (insertSongs.jsp) i have inserted my data into the songs_table .And then in another jsp page (i.e songsList.jsp)
i have query for displaying only songs list from db code below............................................. ......................
String QueryString = "SELECT title from mysong";
rs = statement.executeQuery(QueryString);
%>
<%
while (rs.next()) {
String arr[]= new String [rs.getString("title").split("\\,").length];
int i;
for(i=0;i<arr.length;i++)
{
arr = rs.getString("title").split("\\,");
%>
<a href="Player.jsp?sid=<%=rs.getString("title")%>" ><input TYPE=checkbox NAME="chkSample" VALUE="<%=rs.getString("title")%>" ><%=rs.getString("title")%></a><BR>
<% } } %>
<%
// close all the connections.
rs.close();
statement.close();
connection.close();
} catch (Exception ex) {
%>
.................................................. .....................
Now My Problem is that how to play that songs or a list of songs on clicking on it to a swf player ie in my Player.jsp page.............................................. .....................................
String QueryString = "SELECT * from mysong where title='"+request.getParameter("sid")+"'";
rs = statement.executeQuery(QueryString);
%>
<%
while (rs.next()) {
byte[] bytearray = new byte[10240];
int size=0;
InputStream songs;
//response.addHeader("Content-Disposition","filename=getsongs.mp3");
response.reset();
response.setContentType("audio/mpeg");
songs=rs.getBinaryStream(2);
while((size=songs.read(bytearray))!= -1)
{
response.getOutputStream().write(bytearray,0,size) ;
}
//response.flushBuffer();
%>
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="160" height="160">
<param name="movie" value="Player.swf">
<param name="src" value="<%=%>" >
<param name="quality" value="High">
<embed src="Player.swf" SRC="<%=%>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="160" height="160">
</object>
<%songs.close(); %>
<% } %>
<%
// close all the connections.
rs.close();
statement.close();
connection.close();
} catch (Exception ex) {
%>
.................................................. ........................
My exact problem is that how to feed the songs or songs list to a swf player from database directly?
have i to create any dynamic .xml file or else for songs list to a swf player? if so how?
|