Hi,
I think fobs jmf doesn't yet implement playback rates other than 1.0? I would find it very useful. Can we expect that anytime soon?
Also, what's the best way to implement a track position bar. I created a Thread that updates the position of a ProgressBar every 150 ms, but I get the following once every 2 secs or so (I use no synchronization):
I take note of your request for next release. I don't think it will be difficult to implement rates (indeed, I think that JMF should take care of this, as this is a property of a player not of the parser).
About the other issue, I don't understand what's your problem exactly and what you are trying to achieve. Anyway, you can use the bar provided by JMF in any Player. Hope this helps. If not, please be more clear.
Thanks!
Jos San Pedro Wandelmer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I understand correctly, our friend wants to invoke player.setRate(float rate) on his player.
If so, then indeed it can be done with fobs.
For instance, try the following code.
Note the line:
System.out.println("The play rate has been set to: "+videoPlayer.setRate(2.0f));
Where the setRate is applied to the videoPlayer.
Depending on the type of video you play, if the rate is too high you start to skip frames. For a mpeg2 file, I start to loose frames if the rate is faster that 2.0, but that may be system dependent...
void stop() {
if (videoPlayer!=null) {
videoPlayer.stop();
videoPlayer.deallocate();
}
}
public synchronized void controllerUpdate(ControllerEvent event) {
System.out.println(event.toString());
if (event instanceof RealizeCompleteEvent) {
Component comp;
System.out.println("Adding visual component");
if ((comp = videoPlayer.getVisualComponent()) != null)
add ("Center", comp);
System.out.println("Adding control panel");
if ((comp = videoPlayer.getControlPanelComponent()) != null)
add("South", comp);
validate();
System.out.println("The play rate has been set to: "+videoPlayer.setRate(2.0f));
}
}
public static void main(String[] argv) {
JMFSimplePlayer myFrame = new JMFSimplePlayer("Java Media Framework Project");
myFrame.show();
myFrame.setSize(300, 300);
}
public void windowActivated(WindowEvent we) {}
public void windowClosed(WindowEvent we) {}
public void windowClosing(WindowEvent we) {}
public void windowDeactivated(WindowEvent we) {}
public void windowDeiconified(WindowEvent we) {}
public void windowIconified(WindowEvent we) {}
public void windowOpened(WindowEvent we) {}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanx I tried your code but It doesn't work for me I got 1.0 for every file I tried to play including a few .mpeg, .mpg and .wmv. I'm on linux.
I still wonder how the JMF bar is implemented. I used the Player.getMediaTime().getSeconds() on a separate Thread and compared it with the duration of the stream, that gives me Exceptions, but the JMF Bar doesn't have the same problem. I think getMediaTime() calls some seek() method that's trouble.
Anyway is my install wrong, does fobs support playback rates?
Thanx for your help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I think fobs jmf doesn't yet implement playback rates other than 1.0? I would find it very useful. Can we expect that anytime soon?
Also, what's the best way to implement a track position bar. I created a Thread that updates the position of a ProgressBar every 150 ms, but I get the following once every 2 secs or so (I use no synchronization):
204.705First Position: 141, 33 Duration: 204704
Seeking pos: 18423
[mpeg @ 0x46de6adc]read_seek: 0 1568070
[mpeg @ 0x46de6adc]using cached pos_min=0x29000 dts_min=102812
[mpeg @ 0x46de6adc]using cached pos_max=0x21ec000 pos_limit=0x21ec000 dts_max=18430139
[mpeg @ 0x46de6adc]pos_min=0x29000 pos_max=0x21ec000 dts_min=102812 dts_max=18430139
[mpeg @ 0x46de6adc]167936 2998284 35569664 / 102812 1577286 18430139 target:1568070 limit:35569664 start:2998281 noc:0
[mpeg @ 0x46de6adc]pos_min=0x29000 pos_max=0x2dc00c dts_min=102812 dts_max=1577286
[mpeg @ 0x46de6adc]167936 2985996 2998284 / 102812 1568277 1577286 target:1568070 limit:2998280 start:2980589 noc:0
[mpeg @ 0x46de6adc]pos_min=0x29000 pos_max=0x2d900c dts_min=102812 dts_max=1568277
[mpeg @ 0x46de6adc]167936 2985996 2985996 / 102812 1568277 1568277 target:1568070 limit:2980588 start:2980189 noc:1
[mpeg @ 0x46de6adc]pos_min=0x29000 pos_max=0x2d900c dts_min=102812 dts_max=1568277
[mpeg @ 0x46de6adc]167936 1576960 2985996 / 102812 841550 1568277 target:1568070 limit:2980188 start:1574062 noc:0
[mpeg @ 0x46de6adc]pos_min=0x181000 pos_max=0x2d900c dts_min=841550 dts_max=1568277
[mpeg @ 0x46de6adc]1576960 2979852 2985996 / 841550 1565274 1568277 target:1568070 limit:2980188 start:2979786 noc:0
[mpeg @ 0x46de6adc]pos_min=0x2d780c pos_max=0x2d900c dts_min=1565274 dts_max=1568277
[mpeg @ 0x46de6adc]2979852 2985996 2985996 / 1565274 1568277 1568277 target:1568070 limit:2980188 start:2979853 noc:1
[mpeg @ 0x46de6adc]pos=0x2d780c 1565274<=1568070<=1568277
Thanx
Hi,
I take note of your request for next release. I don't think it will be difficult to implement rates (indeed, I think that JMF should take care of this, as this is a property of a player not of the parser).
About the other issue, I don't understand what's your problem exactly and what you are trying to achieve. Anyway, you can use the bar provided by JMF in any Player. Hope this helps. If not, please be more clear.
Thanks!
Jos San Pedro Wandelmer
If I understand correctly, our friend wants to invoke player.setRate(float rate) on his player.
If so, then indeed it can be done with fobs.
For instance, try the following code.
Note the line:
System.out.println("The play rate has been set to: "+videoPlayer.setRate(2.0f));
Where the setRate is applied to the videoPlayer.
Depending on the type of video you play, if the rate is too high you start to skip frames. For a mpeg2 file, I start to loose frames if the rate is faster that 2.0, but that may be system dependent...
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
public class JMFSimplePlayer extends Frame implements ControllerListener,WindowListener {
Player videoPlayer;
DataSource dataSource; //of the capture devices
public JMFSimplePlayer(String title) {
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
dispose();
}
});
play();
}
void play() {
try {
FileDialog fd = new FileDialog(this, "Select File", FileDialog.LOAD);
fd.show();
String filename = fd.getDirectory() + fd.getFile();
System.out.println("Passing MediaLocator the filename: "+filename);
MediaLocator mediaLocator = new MediaLocator("file://" + filename);
//videoPlayer = Manager.createPlayer(mediaLocator);
//DataSource ds = new com.omnividea.media.protocol.file.DataSource(mediaLocator);
DataSource ds = Manager.createDataSource(mediaLocator);
videoPlayer = Manager.createPlayer(ds);
System.out.println("Adding controller listener");
videoPlayer.addControllerListener(this);
System.out.println("Starting player ...");
videoPlayer.start();
}
catch (Exception e) {
System.out.println(e.toString());
}
}
void stop() {
if (videoPlayer!=null) {
videoPlayer.stop();
videoPlayer.deallocate();
}
}
public synchronized void controllerUpdate(ControllerEvent event) {
System.out.println(event.toString());
if (event instanceof RealizeCompleteEvent) {
Component comp;
System.out.println("Adding visual component");
if ((comp = videoPlayer.getVisualComponent()) != null)
add ("Center", comp);
System.out.println("Adding control panel");
if ((comp = videoPlayer.getControlPanelComponent()) != null)
add("South", comp);
validate();
System.out.println("The play rate has been set to: "+videoPlayer.setRate(2.0f));
}
}
public static void main(String[] argv) {
JMFSimplePlayer myFrame = new JMFSimplePlayer("Java Media Framework Project");
myFrame.show();
myFrame.setSize(300, 300);
}
public void windowActivated(WindowEvent we) {}
public void windowClosed(WindowEvent we) {}
public void windowClosing(WindowEvent we) {}
public void windowDeactivated(WindowEvent we) {}
public void windowDeiconified(WindowEvent we) {}
public void windowIconified(WindowEvent we) {}
public void windowOpened(WindowEvent we) {}
}
Thanx I tried your code but It doesn't work for me I got 1.0 for every file I tried to play including a few .mpeg, .mpg and .wmv. I'm on linux.
I still wonder how the JMF bar is implemented. I used the Player.getMediaTime().getSeconds() on a separate Thread and compared it with the duration of the stream, that gives me Exceptions, but the JMF Bar doesn't have the same problem. I think getMediaTime() calls some seek() method that's trouble.
Anyway is my install wrong, does fobs support playback rates?
Thanx for your help!