caprica/vlcj — Issue #2: crash fatal error problem when play two sounds at the same time !!
Author: Jason4Ever
Created: 2012-02-01 15:08:13+00:00
State: open

Hello ,

i have problem in my application , and i tried many solutions but
it didn't solve any thing ! , so please i need your help :

i have intro consist of JFrame windows including JPanel of intro , and this intro have background music , and 3 buttons ,
and this buttons when hover , it play a wave file, and when clicked ,
its play another wav file ,

the problem is , some times when i run the application and hover in
any button , some vm crash occur and the application stop ! ...

this is my Media Class which i use it to play any media sounds :

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package game.core;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.headless.HeadlessMediaPlayer;

public class Media extends JPanel implements Runnable{

private URL url;

Canvas c = new Canvas();
String[] libvlcArgs = {"--clock-jitter=0","--no-video-title-show","--no-xlib","--no-osd","--no-overlay"};
private MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs);
public EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(null);
private String filename = null;
private Thread runner = null;

public Media(String file){
filename = file;
runner = new Thread(this);
}

// play once time
public void play(){
mediaPlayer.playMedia(filename);
}

// play once time
public synchronized void playVideo(JFrame frame,boolean fullscreen,Color co){

this.setLayout(new GridLayout());
this.setBackground(co);

if(frame.isVisible()){
this.add(c);
}

if(fullscreen){
mediaPlayer.setFullScreen(true);
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
}

frame.setContentPane(this);
frame.setVisible(true);

mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(c));
mediaPlayer.playMedia(filename);

}

public synchronized void stop(){
mediaPlayer.stop();
}

public synchronized void loop(int count){
mediaPlayer.setRepeat(true);
}

@Override
public void run() {
}

}

and this is the buttons actions methods :

@Override
public void mousePressed(MouseEvent e) {
new Media(Base.Audio_Dir+"intro_button_click."+Base.audio_extension).play();
}

@Override
public void mouseEntered(MouseEvent e) {
new Media(Base.Audio_Dir+"intro_button_over."+Base.audio_extension).play();
}

Thank you ..!