How can we change the time of the media file from java code ?

Hi,
particularly, how can we start the media file from the second 55 and not from the second 0 (beginning) ?
Thanks.

I tryed to use such method but an exception was raised:
javax.media.NotRealizedError: Cannot set media time on a unrealized controller
     at com.sun.media.BasicPlayer.setMediaTime(BasicPlayer.java:427)
     at com.sabily.mualim.main.MediaFileDemo.loadMediaFile(MediaFileDemo.java:72)
     at com.sabily.mualim.main.MediaFileDemo.<init>(MediaFileDemo.java:77)
     at com.sabily.mualim.main.MualimStandalone.main(MualimStandalone.java:12)
Exception in thread "main" javax.media.NotRealizedError: Cannot set media time on a unrealized controller
     at com.sun.media.BasicPlayer.setMediaTime(BasicPlayer.java:427)
     at com.sabily.mualim.main.MediaFileDemo.loadMediaFile(MediaFileDemo.java:72)
     at com.sabily.mualim.main.MediaFileDemo.<init>(MediaFileDemo.java:77)
     at com.sabily.mualim.main.MualimStandalone.main(MualimStandalone.java:12)
below is the code related to playing media file:
package com.sabily.mualim.main;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Panel;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.ControllerAdapter;
import javax.media.ControllerListener;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.RealizeCompleteEvent;
import javax.media.Time;
import javax.media.TimeBase;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MediaFileDemo extends JFrame{
     private Player player;
     Component center;
     Component south;
     private void loadMediaFile() {
          final Container contentPane = getContentPane();
          if (player != null) {
               player.stop();
          try {
//               player = Manager.createPlayer(new URL("file:C:/Nouveau dossier/e1_intro.wav"));
               player = Manager.createPlayer(new URL("file:C:/mp3/001.wav"));
               //player = Manager.createPlayer(new URL("file:D:/Film/Earth_Planet/Planet.Earth.EP08.Jungles/Planet.Earth.EP08.Jungles.avi"));
          } catch (NoPlayerException e) {
               e.printStackTrace();
          } catch (MalformedURLException e) {
               e.printStackTrace();
          } catch (IOException e) {
               e.printStackTrace();
          ControllerListener listener = new ControllerAdapter() {
               public void realizeComplete(RealizeCompleteEvent event) {
                    Component vc = player.getVisualComponent();
                    if (vc != null) {
                         contentPane.add(vc, BorderLayout.CENTER);
                         center = vc;
                    } else {
                         if (center != null) {
                              contentPane.remove(center);
                              contentPane.validate();
                    Component cpc = player.getControlPanelComponent();
                    if (cpc != null) {
                         contentPane.add(cpc, BorderLayout.SOUTH);
                         south = cpc;
                    } else {
                         if (south != null) {
                              contentPane.remove(south);
                              contentPane.validate();
                    pack();
                    //setTitle("Lesson 1");
          player.addControllerListener(listener);
          player.setMediaTime(new Time(15));
          player.start();
     public MediaFileDemo() {
          loadMediaFile();
     public Player getPlayer() {
          return player;
     public void setPlayer(Player player) {
          this.player = player;
Best Regards

Similar Messages

  • How can I use my time capsule to save files from my windows PC (Windows 8.1)?

    I have been to see the iStore close to where I live but I am frustrated to say that they are no help what so ever. The technical desk there freely admits that they do not how to do it and all they say is "apparently it is easy. Just follow the instructions on screen" which helps me no end!
    I have the Time Capsule set up on my mac and want to use part of the disc to save my files from my Windows PC (running Windows 8.1) that is on the same home network.
    I have found the apple forums so helpful in the past that I am pinning on my hopes on anyone that can help me via the forum now!

    Load the airport utility for windows. Sadly the most recent one is old.
    http://support.apple.com/kb/dl1547
    Although it is for windows 7 it does work on 8 and 8.1 .. tell us if you have problems loading it. Some people find it won't work without using safe mode.
    The utility will not help a lot to setup the latest model TC.. it is fine for Gen4 and earlier. But it does load bonjour for windows and a disk access agent.
    The TC should run simple names.. Short.. keep them below 10 characters if you can. No spaces and pure alphanumeric.
    That includes the base station name and wireless name.
    Once all of that is correct, open windows explorer and type in the address bar.
    \\TCname or \\TCipaddress where you replace TCname with the new short name or TCipaddress with obviously its actual IP.
    You will then get a request for username and password. Username is whatever.. admin will do. Password type in your disk access password.. public by default.
    TC is not designed to allow partitions so you cannot partition the TC disk. Create a folder and simply copy and paste your files to the folder.
    NOTE:: The TC cannot back itself up. So make sure you do not move files to the TC without having another copy.
    NOTE:: The TC does not happily mix TM backups and data.
    See http://pondini.org/TM/Home.html For info about TM and the TC.
    This area in particular.
    Q3 http://pondini.org/TM/Time_Capsule.html
    On mixing data and backups.

  • How can i Insert a blank line an output file from my code

    I hav a problem in printing the charecters at th partyicular positon by getting the getFilePointer SO p-lz do help

    It's not so simple as you might have in mind.
    The following may serve to give some idea for your purpose..
    import java.io.*;
    public class RandAcc {
    public static void main(String[] args) throws Exception{
    try{
    long filePointer=0L;
    java.io.RandomAccessFile rf = new java.io.RandomAccessFile("in.txt","rw");//arbitrary input text file
    System.out.println(String.valueOf(rf.getFilePointer()));
    int q=0;
    while((q=rf.read())!=-1){
        filePointer=rf.getFilePointer();
        System.out.print(String.valueOf(q)); 
        System.out.print(": file pointer is at ");     
        System.out.println(String.valueOf(filePointer));
    rf.seek(0L);//reset the filepointer
    System.out.println(String.valueOf((char)rf.read()));//initial position
    rf.close();    
    catch (Exception e){
        throw e;
    }

  • My Apple ID and rescue email are reversed. How can I change them both at the same time

    My Apple ID and rescue email are reversed. How can I change them both at the same time?

    I'd already used this standard tool (exhaustively!), but for the problem encountered it operated in Catch 22 mode - you had to do two things but neither order was permitted. I did find an answer eventually, but am not sure what it was I did that solved it! Thanks, anyway.

  • All photos in portrait format are displayed blurred in the preview mode "fill" of the library. In all other modes e.g. "fit"or "1:2" the photos are sharp. How can I change this, so that the photos are still sharp when displaying them in the mode "fill"?

    All photos in portrait format are displayed blurred in the preview mode "fill" of the library. In all other modes e.g. "fit"or "1:2" the photos are sharp. How can I change this, so that the photos are still sharp when displaying them in the mode "fill"? My Lightroom release is 5.7.1.
    Thanking you in anticipation!

    I'd like to get all these '-1 suffix' files together with their associated Develop adjustments into one folder (if they aren't already) so I can see them in Grid view in the Library module, which I use as my basic starting point for everything else at this early stage of my Lightroom 'career'.
    To see what folder these are stored in, right-click on a photo and select "Go to Folder in Library".
    Advice: if you are going to use Lightroom effectively, you probably want to stop using folders as your method to create a grouping of photos that are already in Lightroom; there are plenty of built-in tools, such as keywords, collections, color labels, etc.
    I don't understand why the search on the entire catalog picked up apparently the same two file versions but also got the Develop adjustments when going to the relevant Folder didn't show the adjustment black squares against each image in Grid view nor were they there when the images were opened in the Develop module.  Perhaps if I understood this, I'd be a bit more confident of moving forward myself.
    These are most likely different versions of the same photo, in different folders. Lightroom stores the edits in its own catalog, and so it knows that one folder's photos have edits, and the other folder's photos do not have edits. Please understand that Lightroom is a database, it knows where the photos are at the time you import them (or add them to the catalog by synchronize), and then if you move things around in your operating system, Lightroom does not know anything about that and problems begin. Thus the advice to organize using Lightroom tools and methods and not operating system tools and methods.

  • I signed up for my apple account while living in Canada, and now I lives in the US. I am looking for a specific app that apparently is only available through the US app store. How can I change my account to the US Apple Store?

    I signed up for my apple account while living in Canada, and now I lives in the US. I am looking for a specific app that apparently is only available through the US app store. How can I change my account to the US Apple Store?

    As long as you have a form of payment (credit or debit card) with a USA source, and with a billing address in the USA, then you just need to change your payment information on your account to that, change your country in the store settings, and you will then be able to shop in the USA store.
    Your AppleID will work in any country's store, as long as your payment source and billing addres are also specific to that country (and you are in that country as well, as there may be IP filters in place to stop use outside of the country).

  • How can I change my visa on the apple account

    How can I change my visa on the apple account

    A number of ways to do this, but on the iPad:
    Open the iTunes app ans select any of the product categories at the bottom (music, for example).
    Scroll down and then tap on the button with your AppleID
    Tap View ID
    Login
    Select Payment information and edit the info, then save

  • How can I change one section of the document to a landscape orientation and not the whole document?

    How can I change one section of the document to a landscape orientation and not the whole document?

    Page Setup, including page orientation, is done in the File menu. The setting applies to the whole document. As Peter says, you can rotate the contents of a page (not including the text layer of a word processing document).
    As an alternative, you could use Numbers, where Sheets are empty canvases onto which you may place images, charts, tables and text boxes, and where page orientation may be set for individual Sheets. The main tradeoff is that you lose many of the built-in word processing and page layout features of Pages.
    Regards,
    Barry

  • HT1677 iOS 7 for iPad the bookmarks tab is now on the top right hand side how can I change this back to the top left hand side as in the previous versions?

    iOS 7 for iPad the bookmarks tab is now on the top right hand side how can I change this back to the top left hand side as in the previous versions? Thanks

    Sorry but you can't

  • IPAD ID: I have changed my ID (mail) and now I can updated my apllications in the ipad because still appears my first ID... How can I change my ID in the IPAD????

    I have changed my ID (mail) and now I can updated my apllications in the ipad because still appears my first ID... How can I change my ID in the IPAD????

    Apple ID (your e-mail address) that was used to purchase apps are forever tied to that Apple ID for updates.
    Apple ID cannot be merged or transferred to another Apple ID.
    You can change the e-mail address associated with the Apple ID below:
    https://appleid.apple.com

  • I bought the HD season version of breaking bad, however I only need the regular @ 19.95. How can I change this and get the difference refunded?

    bought the HD season version of breaking bad, however I only need the regular @ 19.95. How can I change this and get the difference refunded?

    When you purchase an HD video on a supported device or computer, only HD video will be downloaded. To download the SD version, you need to download the video again from your Purchased page. Conversely, if you purchase an HD video on an unsupported device, the SD version will be downloaded. Then, you will need to download the HD version from your Purchased page. Learn more about downloading previous purchases."
    iTunes: Purchasing and viewing HD videos

  • How can I change game centre and iCloud account information from previous owner of my iPad?

    How can I change game centre and iCloud account information from previous owner to me?

    You can't do it on your own. The previous owner has to erase the device for you. You would need his Apple ID and password in order to delete his iCloud account. This is due to the Activation Lock in iOS 7 - assuming that your iPad is running iOS 7.
    Contact the owner and ask home to erase it remotely using iCloud, or return the device and ask for your money back. If you can't contact the pervious owner, you will have a useless iPad on your hands.
    Read this for more information. This is what you need the previous owner to do.
    What to do before selling or giving away your iPhone, iPad, or iPod ...

  • How can i run Lightroom 3.6 with RAW files from Canon 650D?

    How can i run Lightroom 3.6 with RAW files from Canon 650D?

    Download the newest DNG converter from Adobe, convert your RAW photos to DNG, and then Import into Lightroom.

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • How to modify an existing xml file from java code.

    Hi
    I have worked on creating a new xml file from java code using xmlbeans.But if i try to modify an already existing file using java code I am unable to get errorfree xmlfile.
    For example if xml file(studlist.xml) is as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    Now suppose i have set name to victor using student.setName,
    and set age to 20 using setAge from javacode,
    the new xml file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    <Student>
              <Name>victor</Name>
              <Age>20</Age>
         </Student>
    As observed this is not a valid xml file.But how can i modify without any errors?

    I know it's an old post, but I found this while doing a google search for something else, and don't like to leave it un-aswered
    Just in case anyone has a similar problem... In this case the new elements have been appended outside of the root element
    What you need to do is first get the root element and then append the new children to that, there are several ways of getting the root element, which depend on what you want to do with the elements you get back here's a simple (incomplete) way.
    // gets the root element of the specified file (code not shown)
    Element rootElement= new SAXReader().read(file).getRootElement();Then just append the new elements as below (this is non-generic code and would need to be modified for your situation)
    // write a new student element
    Element student = document.createElement("Student");  // creates the new student
    rootElement.appendChild(student); // ***appends it to the root element***
    Element name = document.createElement("Name"); // creates the name element
    name.appendChild(document.createTextNode("Fred")); // adds the name text to the name element
    student.appendChild(name); // appends the name to the student
    Element age= document.createElement("Age"); // creates the age element
    age.appendChild(document.createTextNode("26")); // adds the age text to the age element
    student.appendChild(age); // appends the name to the studentThen flush ya buffers or whatever and write the file
    Edited by: Dream-Scourge on Apr 23, 2008 11:10 AM

Maybe you are looking for