localhost = InetAddress.getLocalHost(); AudioChannel audioChannel0 = new AudioChannel(new MediaLocator("javasound://8000"), localhost.getHostAddress(), localhost.getHostAddress(), 7002, 7020, new AudioFormat(AudioFormat.GSM_RTP), null); AudioChannel audioChannel1 = new AudioChannel(new MediaLocator("javasound://8000"), localhost.getHostAddress(), localhost.getHostAddress(), 7020, 7002, new AudioFormat(AudioFormat.GSM_RTP), null);
if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null) return ml; if ((ml = new MediaLocator("file:" + url)) != null) return ml; } else { String file = "file:" + System.getProperty("user.dir") + File.separator + url; if ((ml = new MediaLocator(file)) != null) return ml;
/** * Initialize the Audio Channel to make it able to send and receive audio. */ @Override public void initialize() { String ip; String localIp; int localPort; int remotePort; if (this.getLocal().getSymmetric() != null) { ip = this.getLocal().getIp(); localIp = this.getLocal().getLocalIp(); localPort = getFreePort(); remotePort = this.getLocal().getSymmetric().getPort(); LOGGER.fine(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort); } else { ip = this.getRemote().getIp(); localIp = this.getLocal().getLocalIp(); localPort = this.getLocal().getPort(); remotePort = this.getRemote().getPort(); } audioChannel = new AudioChannel(new MediaLocator(this.getMediaLocator()), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()),this); }
ds = javax.media.Manager.createDataSource(new MediaLocator("javasound://"));
public void Capture() { di = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0"); ml = new MediaLocator("vfw://0"); try { player=Manager.createRealizedPlayer(ml); win.getContentPane().add(player.getVisualComponent(),BorderLayout.CENTER); player.start(); } catch (Exception ex) { } }
MediaLocator ml = new MediaLocator("file:capture.mpg"); datasink = Manager.createDataSink(outputDS, ml);
String theFile = "file:///c:/player/sound.mp3"; MediaLocator mrl = new MediaLocator(theFile);
MediaLocator ml = new MediaLocator("javasound://8000");
URL url = getClass().getResource(filePathInJar); MediaLocator locator = new MediaLocator(url); mediaPlayer = Manager.createRealizedPlayer(locator);
File f = new File ( filename ); MediaLocator locator = new MediaLocator ( f.toURL() ); player = Manager.createPlayer ( locator );
/** * Initializes a new <tt>IVFMediaDevice</tt> instance which will read * the IVF file located at <tt>filename</tt>. * * @param filename the location of the IVF the <tt>IVFStream<tt> * will read. */ public IVFMediaDevice(String filename) { super(new CaptureDeviceInfo( filename, new MediaLocator("ivffile:"+filename), IVFMediaDevice.SUPPORTED_FORMATS), MediaType.VIDEO); } }
new MediaLocator(new File("file:///C:\\full_path_to_the_file\\TheBreach.mp3").toURL())
public class MP3Player { public static void main(String[] args) throws Exception { File file = new File("c:/player/trigger.mpg"); MediaLocator mrl = new MediaLocator(file.toURL()); Player player = Manager.createPlayer(mrl); player.start(); Thread.sleep(1000); } }
public MediaPlayer(URL mediaUrl) throws Exception{ try{ UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel()); }catch (ParseException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } setLayout(new BorderLayout()); try { mediaPlayer=Manager.createRealizedPlayer(new MediaLocator(mediaUrl)); Component video=mediaPlayer.getVisualComponent(); Component control=mediaPlayer.getControlPanelComponent(); if (video!=null) { add(video, BorderLayout.CENTER); // place the video component in the panel } add(control, BorderLayout.SOUTH); // place the control in panel //mediaPlayer.start(); Thread.sleep(1000); } catch (IOException | NoPlayerException | CannotRealizeException | NullPointerException e) { e.printStackTrace(); } } }
CaptureDeviceInfo webcamInfooo = new CaptureDeviceInfo("Camera", new MediaLocator("vfw://0"), null); MediaLocator camDeviceMediaLocator = webcamInfooo.getLocator(); DataSource source = Manager.createDataSource(camDeviceMediaLocator); Processor mediaProcessor = Manager.createRealizedProcessor(new ProcessorModel(source, FORMATS, CONTENT_DESCRIPTOR)); //MediaLocator outputMediaLocator = new MediaLocator("rtp://" + addr.getHostAddress() + ":" + PORT + "/video"); MediaLocator outputMediaLocator = new MediaLocator("rtp://192.168.1.6:20000/video"); DataSink dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(), outputMediaLocator);
File f = new File("D:/Songs/preview.mp3"); MediaLocator ml = new MediaLocator(f.toURL()); Player p = Manager.createPlayer(ml); p.start();
URI uri = new URI("/songs/BrokenAngel.mp3"); URL song1Url = uri.toURL(); MediaLocator ml = new MediaLocator(song1Url); Player p; try { p = Manager.createPlayer(ml); p.start(); } catch (NoPlayerException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
public AudioRTPRecv() { MediaLocator mrl= new MediaLocator("rtp://192.168.1.100:49151/audio/1"); // Create a player for this rtp session try { player = Manager.createPlayer(mrl); } catch (Exception e) { System.err.println("Error:" + e); return; } if (player != null) { player.addControllerListener(this); player.realize(); } } public synchronized void controllerUpdate(ControllerEvent ce) { System.out.println(ce); if(ce instanceof TransitionEvent) { if (((TransitionEvent)ce).getCurrentState() == Processor.Realized) { player.start(); System.out.println("starting player now"); } } }
/** * Initialize the Audio Channel to make it able to send and receive audio */ public void initialize() { String ip; String localIp; int localPort; int remotePort; if (this.getLocal().getSymmetric() != null) { ip = this.getLocal().getIp(); localIp = this.getLocal().getLocalIp(); localPort = getFreePort(); remotePort = this.getLocal().getSymmetric().getPort(); LOGGER.fine(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort); } else { ip = this.getRemote().getIp(); localIp = this.getLocal().getLocalIp(); localPort = this.getLocal().getPort(); remotePort = this.getRemote().getPort(); } audioChannel = new AudioChannel(new MediaLocator(this.getMediaLocator()), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()),this); }
/** * Initialize the Audio Channel to make it able to send and receive audio */ public void initialize() { String ip; String localIp; int localPort; int remotePort; if (this.getLocal().getSymmetric() != null) { ip = this.getLocal().getIp(); localIp = this.getLocal().getLocalIp(); localPort = getFreePort(); remotePort = this.getLocal().getSymmetric().getPort(); LOGGER.debug(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort); } else { ip = this.getRemote().getIp(); localIp = this.getLocal().getLocalIp(); localPort = this.getLocal().getPort(); remotePort = this.getRemote().getPort(); } audioChannel = new AudioChannel(new MediaLocator(this.getMediaLocator()), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()),this); }