JMediaPlayer - get media duration, current playback time ... etc

Hello everybody,
I can't seem to find API calls for the following purposes:
- get media duration
- get current playback time
- set current playback time
Does anybody know how to get/set those values?
By the way, I'm embedding the JMediaPlayer within a Swing application, not developing a classic FX tool.
Thank you in advance,
r.

To best learn JavaFX and its API and class of what it can do or not do, do learn to decompile the code into Java. You will find most of your answer there (though you may find it limit in understanding Java class compiled from JavaFX Script source)
First of all, the decompiled JMediaPlayer show the following code
package com.sun.media.jmc;
import com.sun.media.jmcimpl.PlayerControlPanel;
import java.awt.BorderLayout;
import java.net.URI;
import javax.swing.JComponent;
// Referenced classes of package com.sun.media.jmc:
// JMediaPane, MediaUnavailableException, MediaUnsupportedException, MediaCorruptedException,
// MediaInaccessibleException
public class JMediaPlayer extends JComponent
public JMediaPlayer()
mediaPane = new JMediaPane();
setLayout(new BorderLayout());
add(mediaPane, "Center");
add(controlPanel = new PlayerControlPanel(mediaPane), "South");
controlPanel.setPlayEnabled(false);
public JMediaPlayer(URI uri)
throws MediaUnavailableException, MediaUnsupportedException, MediaCorruptedException, MediaInaccessibleException
mediaPane = new JMediaPane(uri);
setLayout(new BorderLayout());
add(mediaPane, "Center");
add(new PlayerControlPanel(mediaPane), "South");
public void play()
mediaPane.play();
public void stop()
mediaPane.stop();
public void pause()
mediaPane.pause();
public void setSource(URI uri)
throws MediaUnsupportedException, MediaUnavailableException, MediaCorruptedException, MediaInaccessibleException
if(mediaPane != null)
mediaPane.setSource(uri);
if(controlPanel != null)
controlPanel.setPlayEnabled(true);
public URI getSource()
return mediaPane.getSource();
public float setVolume(float f)
return mediaPane.setVolume(f);
public float getVolume()
return mediaPane.getVolume();
public void setMute(boolean flag)
mediaPane.setMute(flag);
public boolean isMute()
return mediaPane.isMute();
public void setRepeating(boolean flag)
if(mediaPane != null)
mediaPane.setRepeating(flag);
public boolean isRepeating()
if(mediaPane != null)
return mediaPane.isRepeating();
else
return false;
public void setAutoPlay(boolean flag)
mediaPane.setAutoPlay(flag);
public boolean isAutoPlay()
return mediaPane.isAutoPlay();
private JMediaPane mediaPane;
private PlayerControlPanel controlPanel;
The core object is JMediaPane with API to do what you want.
mediaPane.setMediaTime(_timeSec); // Set media time
mediaPane.getDuration(); // Get duration
mediaPane.getMediaTime(); // Get current playback time
Unfortunately, you cannot simply retrieve JMediaPane reference from JMediaPlayer because it has a private access modifier. Hence the only way is to create your own Player from the reference code above.

Similar Messages

  • Trouble with current playback time on progress bar

    First, some terminology.
    As Adobe Flash Player is preparing to play a video, it displays a spinning icon in the center of the video window.  I have seen web pages which refer to this as the spinning beach ball.  I will refer to this simply as the "spinning icon".
    While Adobe Flash Player is playing a video, when one hovers the cursor over the video window (or moves the cursor while playing the video in full screen mode), one sees a progress bar at the bottom of the window.  To the left of the progress bar is a pause button.
    The progress bar has a pointer representing the current playback time within the video.  The progress bar also has a display of the current playback time and length of the video (eg, 40:37 / 01:12:35, meaning that play back is at 40 minutes and 37 seconds within a video which is 72 minutes and 35 seconds long).
    On my Windows XP system, when Flash Player V10.0.32.18 is playing a streaming video, the video pauses when bandwidth is momentarily insufficient to deliver the video bit stream.  The spinning icon appears in the center of the video window.  The current playback time on the progress bar also pauses, as it should.  But when the video resumes, the current playback time does not begin incrementing again.  It remains stalled at the time the pause occurred, which is irritating because it is no longer possible to tell how much time remains in the video.
    It took me a very long time to discover that once the current playback time has stalled, pressing the pause button will cause the current playback time to refresh to the correct playback time and begin incrementing again.  Yaaayyyyyy!
    Now, perhaps someone can help me with a challenge I have been unable to solve.
    On occasion, I want to back up a few seconds within a video.  But if I use my mouse to grab the pointer within the progress bar and move it backward, moving the pointer only a few seconds is a huge challenge.  Even a slight movement of my mouse moves the pointer back a minute or two.
    Is there a way to move the pointer using a key (eg, an arrow key) so that each key press moves the pointer back only a second or two?
    And how about being able to key in a time and press enter, thereby causing the pointer to move to the specified time? Any way to do that?

    Hi OSW, Thanks, now if the NPSWF (FF) files listed are 10.0.32.18 which I'm sure they are, then your FF Flash files are correct. You can right click on each of those and click Properties to confirm the version numbers. Then you have the SWF that is correct. So you have FF Flash files and the SWF, so you are ok on FF.
    IE is a different story. That FIDbg10c.ocx should not be there, it should be Flash10c.ocx to match the FlashUtil10c.ocx.
    Now as far as doing what you suggested, in a word NO. First of all the plug-in is normally used as referring to FF or other browsers than IE. ActiveX is used for IE. If you ran the uninstall_plug-in.exe, you would be removing your FF add on, so don't do that since all of your related Flash files for FF are intact. (Do not disturb:-)
    Now the proper way to Uninstall is to use the Adobe Uninstaller that is downloaded to your Desktop. Then the IE Flash Player Installer is likewise downloaded to the Desktop. Then the FF Installer is downloaded to your Desktop. That way it seems to work better. Also the following must be taken into consideration. Any Anti-Virus/Spyware/Firewall can block
    the install of the ActiveX Control for IE. You must run in the Administrative mode or be the Administrator to install the
    ActiveX and write to the Windows Registry, which Flash Player does on the Install.
    Keep in mind that an Uninstall will remove Flash Player files and the SWF and the SWO for ALL browsers. Then the IE Installer is used to Install FP and the SWO for IE. Then the FF Installer is used to Install the FP & SWF for FF.
    Trying to update or download the Flash Player latest version does not remove the old versions as some software installs do. The old versions must be removed by the Adobe FP Uninstaller prior to any download of the new version.
    I have to be offline for a time. Will check back in later. Just wanted to give you some info on this. There are a couple of things that can be done, and will explain later. If you are satisfied with FF & IE with how Flash Player is working, you don't have to do anything. Again, the update may not accomplish the progress bar issue either. So it is something to think about.
    Thanks,
    eidnolb

  • How to get Client(browser) current date/time in BIP report

    Hi,
    I need to display report generated date in BIP report and this should be client(browser) current date/time. I tried the following things.
    1. have used MS Word Native Date/time using Insert->Date/Time. And we have chosen the M/d/yyyy h:mm:ss am/pm format. but it is printing BIp server date/time, not client date/time.
    2. <?xdofx:sysdate?>, <?xdoxslt:sysdate_as_xsdformat()?> and <?format-date:xdoxslt:sysdate_as_xsdformat();'SHORT_TIME'?> are giving GMT Date/Time, but we need client Date/Time.
    3.<?xdoxslt:sysdate('DD-MON-YYYY HH12:mi:ss')?> is giving the system date/time of the machine where BIP server is installed.
    Could you provide some help in this??
    Thanks
    Hari

    Hello, Hari,
    what would return something like this:
    Execution date:
    <?xdoxslt:current_date('ja-JP', 'Asia/Tokyo')?>
    <?xdoxslt:current_time('ja-JP', 'Asia/Tokyo')?>
    @Vetsrini,
    for my opinion,
    in the countries where time is switching (winter/summer) using the hard coded time zones in the format-date() cause a problem:
    for example:
    if we enter the date in date prompt in summer it will return PM_DT = 2010-07-20T00:00:00.000+04:00
    in winter 2010-07-20T00:00:00.000+03:00, so,
    using <?format-date:PM_DT;'DD.MM.YYYY';'GMT+3'?> return 2010-07-20 in winter and 2010-07-19 in summer.
    regards,
    Eldar A.

  • Missing option when getting media in organiser

    Hi again.
    I have noticed several times that the option the "get media from files and folders" option dissappears from the list of scources after having already performed this operation. Is this a bug?
    Thanks
    Jim

    This is an amusing one Steve!
    It appears that whether or not the option to get media fromfiles/folders (and, incidentally a webcam or WDM device) is shown is dependant on the position of the scroll-bar of the window, the last time that I closed it!
    If when I came out of the "get  media window" the previous time and the scroll-bar was in the bottom position then the next time I open the window the position of the icons is such that the last two are below the window but the scroll bar is already down at its lowest point so they cannot be seen.
    If I then put the scroll bar to the top, come out of the window and then open it again the last two icons cannot be seen but I can move the scroll bar down to reveal them.
    It seems that if the window is opened with the scroll bar down, the program is placing the icons in the position they would be in if the scroll bar was up!!
    I hope I haven't confused you too much! I am using a wide-screen monitior, this and the space I am allowing for the scene window may be a partial cause of the effect!
    Thanks
    Jim

  • Difference between Media duration and Video duration

    What is a difference because MEDIA DURATION value then VIDEO DURATION? I see no difference. I thought that MEDIA DURATION is all time of video from start to the end and a VIDEO DURATION is a total sum of this one video in my timeline. Added to each other.
    I don't know... what is a difference?

    So what is wrong in my video? I made this video to show how I do this. And like you see, numbers are the same.
    What is wrong, tell me...
    Nothing is "wrong" except your assumption in your original post.
    In your examples, the media and video durations ARE the same, and that is why the numbers are the same. The numbers will be different only if you set an in and out point. The example Joe gave you illustrated that the numbers are different only when an in and/or out point is set that is less than the total length of the media.
    Your assumption in the original post (that "MEDIA DURATION is all time of video from start to the end and a VIDEO DURATION is a total sum of this one video in my timeline. Added to each other.") is not correct - unless by video duration you mean the length of one clip from in to out point.

  • Attempt to get media from DV Camcorder crashes every time.

    Dell E6500 Laptop
    Intel Core Duo CPU   P8600 @ 2.40GHZ  2.40GHz
    4GB of RAM (3.45 GB usable)
    Windows 7 Professsional SP1 32bit
    Travelstar 7K500 7200rpm SATA II Main Drive
    The following error occurs every single time I try to load a movie off of my DV Camera via USB.  Windows Movie stuff workes fine.  Other software can access it fine.  Any ideas on how to resolve this?
    Premiere Elements 9.0, Ninja
    Open a new project.  Settings NTSC-DV-Widescreen 48kHz
    DV Cam is connected and powered on and connected via USB 2.0
    Choose Get Media
    Choose DV Camcorder
    New window opens the a dialog opens with the name "Premiere Elements Debug Event"
    Contains the text:
    Premiere Elements has encountered an error.
    [..\..\Src\Static.cpp-88]
    with the only option available continue
    Dialog goes away, new dialog displays:
    Premiere Elements
    Sorry, a serious error has occurred that requires Adobe Premiere Elements to shut down.  We will attempt to save your current project.
    Click o.k. and then the windows message that Adobe Premiere Elements 9 has stopped working with the option to Debug or Close program.

    Also, for Win7 read...
    Legacy Driver and Capture http://forums.adobe.com/thread/869277?tstart=0
    - And a Picture http://forums.adobe.com/thread/727755?tstart=0

  • How to get the most current file based on date and time stamp using SSIS?

    Hello,
    Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
    Thanks
    thx regards dinesh vv

    hi simon
    i excuted this script it is giving error..
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            The execution engine calls this method when the task executes.
            To access the object model, use the Dts property. Connections, variables, events,
            and logging features are available as members of the Dts property as shown in the following examples.
            To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
            To post a log entry, call Dts.Log("This is my log text", 999, null);
            To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
            To use the connections collection use something like the following:
            ConnectionManager cm = Dts.Connections.Add("OLEDB");
            cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
            Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            To open Help, press F1.
            public void Main()
                string file = Dts.Variables["User::FolderName"].Value.ToString();
                string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
                System.IO.FileInfo finf;
                DateTime currentDate = new DateTime();
                string lastFile = string.Empty;
                foreach (string f in files)
                    finf = new System.IO.FileInfo(f);
                    if (finf.CreationTime >= currentDate)
                        currentDate = finf.CreationTime;
                        lastFile = f;
                Dts.Variables["User::LastFile"].Value = lastFile;
                Dts.TaskResult = (int)ScriptResults.Success;
    thx regards dinesh vv

  • How to get the current GMT time in java

    Hi,
    How to get the current GMT time in java
    Thanks

    System.getCurrentTimeMillis() or new Date().
    [url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
    [url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format

  • How to Get Duration, Start/Stop Time of Each Instance (Run)

    Can someone tell me how to get the Duration, as well as Execution Start/Stop times for a given run (Instance) of a Report, stored in History?
    For example, on the BO Server in InfoView, I can browse the History of each report, and for each run, I can click the details and view the Duration and Start/Stop times for that run. How do I get that information in Java via the SDK?
    Neither IProcessInfo nor ISchedulingInfo seems to have this information.
    For example, ISchedulingInfo's Start/Stop Times are for general scheduling (when the report will stop being scheduled). That is not what I want.
    I need specific data for a given completed Run, namely its duration and time endpoints. Thanks a lot.

    Hi,
    fetch the instance of the run like this
    IInfoObjects list = infoStore.query(
    "select SI_STARTTIME , SI_ENDTIME From CI_INFOOBJECTS Where SI_ID=<instanceIDtoMeasure>"
    IInfoObject element = list.get(0);
    Date startTime = element.properties().getDate("SI_STARTTIME");
    System.out.println("Beginn "+ startTime);
    Date endTime = element.properties().getDate("SI_ENDTIME" );
    System.out.println("End " + endTime);
    long time = ((endTime.getTime() - startTime.getTime()) / 1000);
    System.out..println("Runtime " + time + " sec");
    You can get the nstanceIDtoMeasure form your Report with getInstances
    Enjoy
    johannes

  • How cost;ly it is to get the current system time

    I am using this call "System.currentTimeMillis()" to get the current system time. I need to now how costly it is to get the current system time.

    Why don't you time it -:) Run it 10000 times and print the first and last result. The difference is the time it took.

  • Can't get access in Time Machine to certain folders for any date earlier than current date/time.

    Can't get access in Time Machine to certain folders for any date earlier than current date/time, even when entering as Admin. Why do certain folders have small red "-" badge in lower right corner of folder icon?  Here's a picture of the dilemma:
    I've tried monkeying with priveleges using Command I, and changing users, but to no avail.  Can anyone help?

    Right.  Here's what the permissions look like from the Finder Command I:
    I'm not sure what "Custom" means, but when I then try to change it to "Read & Write", it doesn't take.... just comes back as Custom. Interesting to note that not only am I logged into Joan's account where the data folder and file lives) to do this, but when I do it from my own account  as Admin (dunc...mpster) I get the same result.

  • Get the session information like time left to session expiry or logoff etc

    Hi Experts,
    In webdynpro ABAP I would like to get the session information like time left to session expiry or logoff etc. Please suggest me whether ther are any clasess or code available to get the info.
    Advance Thanks,
    Thanks,
    AMS

    Hi,
    What do you want to do with that information ?
    Regards

  • I am having a difficult time getting the duration of multiple selected clips. The duration display only will display the time for one clip.  Yes, I know I can add them up myself, but why?  :-)

    I am having a difficult time getting the duration of multiple selected clips. The duration display will only display the time for one clip not multiple clips.  Yes, I know I can add them up myself, but why?  :-)
    I am using imovie 10.0.6

    For reasons that you would have to ask Apple for they decided not to allow the precise position of the playhead to be shown in iMovie 10 (unlike in FCP 10.1.x).
    Geoff

  • Media player current time after seeking seems to be incorrect

    When I am doing seeking my current time is not updating properly. After seeking media player current time and seeking time differs.

    If you have files changing on a disc image, then each change will result in having the entire disc image backed up - again and again. Each backup will take much longer and eat up additional space on the backup drive. Each incremental backup of the disc image will require space for another copy of the disc image. This may well be the cause of the problem.

  • af media UI component. Programmatically seeking specified playback time.

    Hi everybody!
    According to business logic, I need to realize playback of audio and video file in my ADF application. I try to use <af media> UI component for this purposes. Everything is fine, but in addition I need to seek specified playback time programmatically (from managed Bean). I try to find out something about it in documentation, but I can't.
    Does anybody have programming experience with <af media> UI component?
    Thanks in advance!
    Emin

    Hi everybody!
    According to business logic, I need to realize playback of audio and video file in my ADF application. I try to use <af media> UI component for this purposes. Everything is fine, but in addition I need to seek specified playback time programmatically (from managed Bean). I try to find out something about it in documentation, but I can't.
    Does anybody have programming experience with <af media> UI component?
    Thanks in advance!
    Emin

Maybe you are looking for