html - How to play MP3 from a browser with Java code and JSP? -
what need play mp3 files jsp, have no idea how. code java mp3 player, working fine, problem need play music on browser(something web service)
package reproductor; import java.io.file; import javazoom.jlgui.basicplayer.basicplayer; public class reproductor { public basicplayer player; public reproductor() { player = new basicplayer(); } public void coge(string y){ } public void play() throws exception { player.play(); } public void abrirfichero(string ruta) throws exception { player.open(new file(ruta)); player.play(); } public void pausa() throws exception { player.pause(); } public void continuar() throws exception { player.resume(); } public void stop() throws exception { player.stop(); } public void reproducemp3 () throws exception{ try { reproductor mi_reproductor = new reproductor(); mi_reproductor.abrirfichero("c:/users/welrk/downloads/preview.mp3"); mi_reproductor.play(); } catch (exception ex) { system.out.println("error: " + ex.getmessage()); } } public static void main(string args[]) throws exception{ reproductor y = new reproductor(); y.abrirfichero("c:/users/welrk/downloads/preview.mp3"); y.play(); } }
i tried this, i'm lost, can provide great
<%@page import="java.io.*" %> <%@ page import="reproductor.*" %> <%@ page import="reproductor.main"%> <%@page import="javazoom.jlgui.basicplayer.basicplayer" %> <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>jsp page</title> </head> <body> <% string temp="c:/users/welrk/documents/netbeansprojects/musica/web/preview.mp3"; reproductor object = new reproductor(); object.player.open(new file(temp)); %> </body> </html>
unless requirements different (you forced use jsp player), why don't rely on html5 audio control reference here?
<audio controls> <source src="/pathtoyourfile.mp3" type="audio/mpeg"> </audio>
Comments
Post a Comment