Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in playing mp3 from databse in swf player

 
bikash nayak
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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="clsid27CDB6E-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?
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI bikash,
Please use code tag for code, that will help a lot for reading code,
you can add by using edit button....
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So "Player.swf" is a flash application that can play MP3s? If so, what does its documentation say?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!