Java - Ayuda con Reproductor de video

 
Vista:
sin imagen de perfil

Ayuda con Reproductor de video

Publicado por Jony (5 intervenciones) el 28/09/2016 18:45:32
Buenas estoy teniendo problemas para reproducir un video con Java y necesitaria ayuda.

El reproductor reproduce el video y la barra de tiempo avanza pero no muestra ninguna imagen ni sonido.
He probado varios codigos y en todos he tenido problemas, incluso en los que he buscado por google. Asi que debera de ser algo exento al codigo.

Os dejo el codigo:


Clase mediaTest
------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package pruebaReproductor;
 
import java.net.MalformedURLException;
 
import java.net.URL;
 
import javax.swing.JFileChooser;
 
import javax.swing.JFrame;
 
public class mediatest {
 
 
public static void main (String[] args) {
 
	JFileChooser filechoser=new JFileChooser();
 
	int resul=filechoser.showOpenDialog(null);
 
	if(resul == JFileChooser.APPROVE_OPTION){
 
		URL mediaURL=null;
 
		try{
 
			mediaURL=filechoser.getSelectedFile().toURL();
 
		}catch(MalformedURLException malforme){
 
			System.err.println("");
 
		}
 
		if(mediaURL != null){
 
			JFrame mediaTest=new JFrame("");
 
			mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
			reproductor repo= new reproductor(mediaURL);
 
			mediaTest.add(repo);
 
			mediaTest.setSize(300,300);
 
			mediaTest.setVisible(true); }
 
	}
 
	}
}








Clase reproductor
-----------------------------------

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package pruebaReproductor;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
 
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.swing.JPanel;
 
public class reproductor extends JPanel{
 
	public reproductor(URL mediaURL) {
 
			setLayout(new BorderLayout());
 
			Manager.setHint(Manager.LIGHTWEIGHT_RENDERER,true);
 
 
			try{
 
				Player mediaPlayer=Manager.createRealizedPlayer(mediaURL);
 
				Component video= mediaPlayer.getVisualComponent();
				Component controls=mediaPlayer.getControlPanelComponent();
 
				if(video!= null){ add(video,BorderLayout.CENTER); }
 
				if(controls!=null){ add(controls,BorderLayout.SOUTH); }
 
				mediaPlayer.start();
 
			}catch(NoPlayerException noplayerexception){
 
				System.out.println("No hay archivo"); }
 
			catch(CannotRealizeException noreleace){
 
				System.out.println("Archivo desconocido"); }
 
			catch(IOException es){
 
				System.out.println("Error al leer la fuente");
			}
	}
}






Un saludo.

PD: Decir que llevo poco en esto y soy bastante novato pero todos hemos tenido que empezar alguna vez :)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Ayuda con Reproductor de video

Publicado por Jony (5 intervenciones) el 28/09/2016 19:34:44
Gracias ahora lo pruebo y comento si me soluciono el problema.

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Ayuda con Reproductor de video

Publicado por Jony (5 intervenciones) el 28/09/2016 20:10:01
Siempre me pone este error. En todos los programas que tengo abierto y hechos.

Alguna ayuda porque sale este error siempre?


1
2
3
4
5
6
7
8
9
sep 28, 2016 8:07:23 PM Ventana init
GRAVE: null
javax.media.NoPlayerException: Cannot find a Player for :file:/C:/Users/Jonathan/Desktop/Profe.mp4
	at javax.media.Manager.createPlayerForContent(Manager.java:1412)
	at javax.media.Manager.createPlayer(Manager.java:417)
	at javax.media.Manager.createRealizedPlayer(Manager.java:553)
	at Ventana.init(Ventana.java:49)
	at Ventana.<init>(Ventana.java:32)
	at Main.main(Main.java:9)


Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar