Getting the filename of a placed image inside a smart object

Hi
I'm wondering if I can get any help with a problem I'm trying to overcome for a friend of mine.
My friend is a photographer who does a lot of schhols work (pupil portraits) and wants to create a little document similar to this (very simplified) version:
I'm trying to help him to create a batch process so that he can make this take up much less of his time!
Here's where I've got to so far. I've created the layout above which is essentially a smart object (from an external file) manipulated in a couple of ways.
The workflow as I see it at the moment (although I'm wide open to suggestions, and I'm having a bit of Friday brain) is this: I generate an action that replaces the content of the external file with the contents of (each file in his incoming list, sequentially).
That file then comes back into the layout above and a new (flattened) copy is saved out from there.
Rinse and rerpeat through the list of incoming files.
I can just about make that bit happen using actions, but here's what I can't get - the filename of the incoming file (the one that's placed in the smart object). Can I can use a modified version of the AddFileName script to generate a text layer based on the filename of the placed contents in the smart object? Does any of that make sense? I'm reading this back to myself and even I'm not sure! ho ho.
My lack of logic/coherent sentence structure here is what probably holds me back in any eforts I have made in getting into scripting.
I'd appreciate any help that could be offered.
Thanks.
Fenton

Ah - alas it sems not to be. I think I am going to have to come up with a different workflow and by extension, solution. My current thinking is that I need to have an input folder for the images to be used in the layout, and an output folder for the results to be saved into, along with the layout.psd (as above) all housed in the same folder. Then I need (help) to write a script that does the following:
Checks that the layout document is open (that bit is easy enough)
if(documents.length==0){
   alert("You need to have your layout template open (-layout.psd-)")
}else{
    // Do next bit here - and what I'm trying to do is described below.
    // Hopefully by typing it out I might start to get it straight in my head
    // Any help with any part of this process is greatluy appreciated
    // I'm trying to learn!
Then what I think the script needs to do is tocheck the contents of the input folder and find out how many files are in it then set this as a variable, to set the length of a loop, maybe? Or should it load the filenames as an array and work through them sequentially?
Once that information is established, there is a smart object on the first layer that needs to be updated with the contents of the first file - my thinking s that this is done by the script opening each image, and then copy/pasting into the smart object, merging down (so I don't end up with an enormous multi-layered file). My reason for thinking this would be a good idea would be that I could just run a quick check to make sure that no landscape pics have sneaked in there and if they have, rotate them (which again, is pretty easy as even I could do that bit, too).
doc = activeDocument;
            if (doc.height < doc.width) {
              doc.rotateCanvas(90);
            } else {
              // Carry on
This will update all of the smart object instances throughout the layout template.
Then the text underneath the main image needs to be updated with the filename of the file that has been pasted in the smart object, and after that a [flattened] copy saved out to an output folder.
Rinse and repeat for the remaining images in the input folder.
Any thoughts?
Thanks
Fenton

Similar Messages

  • Getting the offset of a placed PDF within the container rectangle

    I need to get the offset of a placed PDF inside of the container rectangle. I have figured out that this information should be available in the transformationMatrix of the placed file. So I do something like:
    var pdfTransform = pdf.transformValuesOf(CoordinateSpaces.pasteboardCoordinates)[0];
    var horzTranslation = pdfTransform.horizontalTranslation;
    var vertTranslation = pdfTransform.verticalTranslation;
    but the coordinates I get back are just weird. The horizontal value seems reasonable, but the vertical is way off what I expect.
    There may be some precondition to doing this that I'm missing. Running the pageitems/TransformValuesOf.jsx sample from the Scripting Guide also gives weird values. That sample creates a rectangle with a center point of [0, 0] and then retrieves the transform. I would expect the translation to be [0, 0] but I actually get [5, -415.95] (horz, vert).
    In that sample it talks about ruler coordinates, so I tried setting document.viewPreferences.rulerOrigin to different values, but that does nothing.
    I'm stumped. Can someone please give me a hint on what's going on here?

    Thanks Peter.
    Some more info: I basically want to get the coordinates of the objects in a placed file in the coordinate space of the containing document. As an extra twist, the placed file is a PDF created from an InDesign document. So, I first extract the coordinates from that InDesign file, then the coordinates for the document that contains the placed PDF, and finally I merge the coordinates of the two documents as if all the objects were contained in a single document. This workflow is then used outside of InDesign to draw frames around all the object boxes on a JPEG created from the document containing the placed PDF.
    Anyhow, to answer my own original question, this seems to work thus far:
    rectOffset = containingRect.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.PASTEBOARD_COORDINATES)[0];
    pdfOffset = pdf.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.PASTEBOARD_COORDINATES)[0];
    horzTranslation = rectOffset[0] - pdfOffset[0];
    vertTranslation = rectOffset[1] - pdfOffset[1];
    That gives the same values as I can see in InDesign when selecting the placed PDF. So far so good ...
    BUT, that is not enough! When placing a PDF using the default option of Crop to Bounding Box, I sometimes get a bit of extra margin (different for different documents) that offsets the translation values. I have no idea where this margin comes from but I need to compensate for it.
    Please help! And let me know if this description is unclear so I can try to explain better.

  • Is there a way to get the filename only on iOS using CameraRoll?

    This post is a sidetrack from this post: http://forums.adobe.com/thread/848761?tstart=0
    The method used in that post works perfect on both Android and iOS for selecting and uploading files.... BUT is there a way to get the filename of the file from the mediaPromise cross-plattform?
    If you let the user select an image it's not very nice to have the image be called "temp.jpg" after uploading - you want the user to know which image he/her have uploaded
    Any ideas? The "mediaPromise.file.relativePath()" works on Android but not on iOS. Not "mediaPromise["file"].url/relativePath/nativePath" either.
    Thank you

    Hey Joe what do you think of this solution.
    1. Let the user select the image
    2. Store the mediaPromise object in an array (event.data) for later use
    3. Load in the object using loadMediaPremise
    4. Add the loaded image into a movieclip (not visible from the scene)
    5. Resize that movieclip to let's say 100x100
    6. Use the BitmapData class to create a new bitmap from that movieclip and save it to storage
    7. Use the saved file within the app as a thumbail
    8. Use the mediaPromise object stored in the array later when the user wants to upload the images (then go through mediaPromise.open() on each image -> save to storage -> upload -> clear from storage -> loop).
    I haven't tried it yet (will do this week) but should that be a acceptable solution to the problem(?)
    I'm unsure if by just keeping the mediaPromise object within Flash will make the memory run wild though?

  • Getting the bounds of a drawn image on a panel

    Hello, I have a problem with getting the bounds of a drawn image on a panel...Since it is drawn as graphics, i tried getClipBounds and since my class extends JPanel i tried to get the bounds from the panel but neither of them worked properly. It only gets the bounds of a jframe that contains the panel.Then i tried to put the panel in a layeredpane and then a container; but this time the image disappeared completely. Hope someone can help or tell me what I am doing wrong. Thanks in advance. Here is the code below:
    By the way what I am trying to do in this code is basically zooming the image in and out by dragging or the mouse wheel. But I need to get the bounds so that I can use this.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Admin
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.awt.event.MouseWheelListener;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.NoninvertibleTransformException;
    import java.awt.geom.Point2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JPanel;
    public class ZoomDemo extends JPanel {
    AffineTransform tx = new AffineTransform();
    String imagePath = "D:/Documents and Settings/Admin/Belgelerim/tsrm/resim.jpg";
    Image image = Toolkit.getDefaultToolkit().getImage(imagePath);
    int width = image.getWidth(this);
    int height = image.getHeight(this);
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    double zoomfac = 1.0;
    int xAdj;
    int yAdj;
    int prevY;
    double scale = 1.0;
    Point pt;
    public static int x;
    public static int y;
    public static int w;
    public static int h;
    public ZoomDemo() {
    this.addMouseWheelListener(new ZoomHandler());
    this.addMouseListener(new ZoomHandler());
    this.addMouseMotionListener(new ZoomHandler());
      repaint();
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.drawImage(image, tx, this);
    // x =    (int) g2.getClipBounds().getX();
    // y=     (int) g2.getClipBounds().getY();
    // w=     (int) g2.getClipBounds().getWidth();
    // h=     (int) g2.getClipBounds().getHeight();
    // System.out.println(x+" "+y+" "+w+" "+h);
    //  public int getRectx(){
    //    return x;
    //public int getRecty(){
    //    return y;
    //public int getRectw(){
    //    return w;
    //public int getRecth(){
    //    return h;
    private class ZoomHandler implements MouseWheelListener,MouseListener, MouseMotionListener {
    public void mousePressed(MouseEvent e){
        System.out.println("Mouse Pressed");
    xAdj = e.getX();
    yAdj = e.getY();
    prevY = getY();
    public void mouseDragged(MouseEvent e){
           System.out.println("Mouse Dragged");
    boolean zoomed = false;
    if(e.getY()<prevY){
         zoomfac = zoomfac + 0.1;
         prevY = e.getY();
         zoomed = true;
    else if(e.getY()>prevY){
         zoomfac = zoomfac - 0.1;
         prevY = e.getY();
         zoomed = true;
       scale = zoomfac;
    Point2D p1 = new Point((int)xAdj-(width/2),(int)yAdj-(height/2));
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    tx.transform(p1, p2);
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
    public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
    Point2D p1 = e.getPoint();
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    scale -= (0.1 * e.getWheelRotation());
    scale = Math.max(0.1, scale);
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
            public void mouseClicked(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseReleased(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseEntered(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseExited(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseMoved(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
    public static void main(String[] args) {
    //SwingUtilities.invokeLater(new ZoomDemo());
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    JFrame f = new JFrame("Zoom");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(scrwidth , scrheight);
    //JLayeredPane lp = new JLayeredPane();
    //f.add(lp);
    ZoomDemo zd = new ZoomDemo();
    zd.getBounds();
    f.add(zd);
    //int x = (int) zd.getX();
    //int y = (int) zd.getY();
    //int w = (int) zd.getWidth();
    //int h = (int) zd.getHeight();
    //System.out.println(x+" "+y+" "+w+" "+h);
    //zd.setBounds(x ,y ,w ,h );
    //lp.add(zd, JLayeredPane.DEFAULT_LAYER);
    //f.setLocationRelativeTo(null);
    f.setVisible(true);
    //lp.setVisible(true);
    //zd.setVisible(true);
    }Edited by: .mnemonic. on May 26, 2009 11:07 PM
    Edited by: .mnemonic. on May 27, 2009 11:00 AM

    You'll need a stable point in the component to track and orient to the scaling transform(s).
    From this you can construct whatever you need in the way of image location and size.
    Let's try a center&#8211;of&#8211;image tracking point:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class ZD extends JPanel {
        BufferedImage image;
        Point center;
        AffineTransform at = new AffineTransform();
        Point2D.Double origin = new Point2D.Double(0,0);
        public ZD(BufferedImage image) {
            this.image = image;
            center = new Point(image.getWidth()/2, image.getHeight()/2);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g2.drawRenderedImage(image, at);
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(origin.x-1.5, origin.y-1.5, 4, 4));
            g2.setPaint(Color.blue);
            g2.fill(new Ellipse2D.Double(center.x-1.5, center.y-1.5, 4, 4));
        private void setTransform(double scale) {
            // keep image centered over Point "center"
            double x = center.x - scale*image.getWidth()/2;
            double y = center.y - scale*image.getHeight()/2;
            origin.setLocation(x, y);
            at.setToTranslation(x, y);
            at.scale(scale, scale);
        public static void main(String[] args) throws java.io.IOException {
            java.net.URL url = ZD.class.getResource("images/hawk.jpg");
            BufferedImage image = javax.imageio.ImageIO.read(url);
            ZD test = new ZD(image);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(500,500);
            f.setLocation(100,100);
            f.setVisible(true);
            test.addMouseListener(test.mia);
            test.addMouseMotionListener(test.mia);
        /** MouseAdapter okay in j2se 1.6+ */
        private MouseInputAdapter mia = new MouseInputAdapter() {
            final double SCALE_INC = 0.05;
            final int SCALE_STEP = 20;
            double scale = 1.0;
            double lastStep;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                center.setLocation(p);
                //System.out.printf("center = [%3d, %3d]%n", p.x, p.y);
                setTransform(scale);
                repaint();
            public void mouseDragged(MouseEvent e) {
                // scale up/down with relative vertical motion
                int step = (e.getY() - center.y)/SCALE_STEP;
                if(step != lastStep) {
                    scale += SCALE_INC*((step < lastStep) ? -1 : 1);
                    //System.out.printf("step = %3d  scale = %.3f%n", step, scale);
                    setTransform(scale);
                    lastStep = step;
                    repaint();
    }

  • To upload the ZIP file and get the filenames available in ZIP file in ABAP

    Hi Experts,
    For my requirement, file from legacy comes as ZIP file with number of files in that.
    Please provide one code sample to upload the ZIP file from local workstation and get the filenames available in ZIP file to check few filename validation checks for the available files in report program.
    Thanks in Advance,
    Regards,
    Basani

    1. Copy the ZIP file into App server
    2. Call function
      call function 'RFC_REMOTE_PIPE'
        destination 'SERVER_EXEC'
        exporting
          command = command  " Unzip command gunzip /path & file
          read = 'X'
        tables
          pipedata = std_lines
    then you can read the files and can validate the file names

  • How to get the filename from J2SE File adapter

    In our project scenario , we are using J2EE and J2SE engine both .J2EE for mapping  and J2SE for Deliveying the message .
    In one senario, routing will be based on the filename .
    J2SE Sender File adapter --- XI Adapter --- XI pipe line
    So the File reaching to XI pipelane via J2SE File adapter--> XI adapter.
    When we are using the dynamic configurator in the XI to get the filename
    we are not able to get the file name  becasue it is coming to XI via
    XI adapter.
    How to get the filename ????Hope I am clear about the problem.

    hi,
    try this
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //obtengo la Key del FileName
    DynamicConfigurationKey keyF = DynamicConfigurationKey.getName();
    http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/api/DynamicConfigurationKey.html
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70c89607-e4d9-2910-7280-f6746e964516
    /people/mohammed.zabiulla/blog/2008/03/26/have-you-ever-tried-to-determine-mail-cc-dynamically
    Hope it helps
    Thanks
    Rodrigo
    Edited by: Rodrigo Pertierra on Apr 11, 2008 9:31 AM

  • How to get the filename of the active jsp page?

    how can i get the filename of the active jsp page?

    You could register the JSP [ages in the web.xml and then use the ServletConfig.getServletName.
    You could use the JspContex.getServletName which will return the registered name or the name of the servlet class.
    You could programmatically add a page context attribute that holds the jsp page name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to get the filename when parsing a file with d3l

    All
    After some time have experience with interconnect, IStudio I need the following info. Is it possible to get the filename when parsing a flat file using a d3l? This is needed because we need to store the filename together with the data into the database.
    Any examples or directions to some documents are welcome.
    Regards
    Olivier De Groef

    has anyone some info on this

  • Get the icc profile of an image

    Hi all,
    I'm looking for a way to get the icc profile of an image in a PDF.
    I already know the tools like Acrobat preflight … But I only can get that my PDF contents RVB images or not.
    I'm looking for a tool to return the ICC profile of all images (s'RGB, Adobe 1988, etc.).
    Have anyone an ideas?
    Thanks a lot.
    Bye

    Hi,
    I have an other question …  Sorry
    I use this tool and it help me a lot … But I still can't get the icc profil name.
    For example: the inspector return CMYK device but I would like to have Fogra 27, ISO coated v2, Swop etc.
    Do you have an ideas?

  • How to get the copyright information for an image?

    How would I get the copyright data from an image in the DAM?

    Assuming you are using image component[1] on a page and copyright is a string.    As a sample you could use [2] to get the copyright information.  I am not well versed with the API as there might be an better option to implement. But this just gives you an idea for the information you were looking for.
    [1] /libs/foundation/components/image/image.jsp
    [2]
    Node refNode = resource.getResourceResolver().getResource(ResourceUtil.getValueMap(resource).get("fileRe ference","")).adaptTo(Node.class);
    String copyRight = refNode.getNode("jcr:content/metadata").getProperty("dc:rights").getString() ;

  • How do i get the code to register Pixillion Image converter? [was:glory614]

    how do i get the code to register Pixillion Image converter

    That's not Adobe software.
    You'll need to go to the maker's website and get your code from them
    http://www.nchsoftware.com/imageconverter/

  • Recently moved and installed ATT DLS - I use their wireless router and connectted my airport express - Now I'm getting the Blue ? on some images

    Recently moved and installed ATT DLS - I use their wireless router and connectted my airport express - Now I'm getting the Blue ? on some images - and at times - videos don't load.  I've increased / deleted Cache.  Suggestions? Misconfig?  Could it be possible my configuration from MacBook to router isn't correct?
    Thanks!

    JG,
    Thanks for the info.
    Couple of questions. I found an apple support document on this topic that opened with this line:
    "AirPort Express and all AirPort Extreme base stations can use WDS. Earlier AirPort base stations can't."
    If the TC is an airport extreme base station, why can't this work to extend the network? I think I misunderstand. Here is the full article:
    http://support.apple.com/kb/HT2044?viewlocale=en_US
    If I buy a new airport extreme, set it to wireless-n only as my main router, am I correct that my existing time capsule could be used as a bridge if plugged in upstairs?
    Final question (and that should do it), could I take this old airport express, plug it in upstairs using the ethernet connection, and just create a separate wireless network to use with a different name?
    I'd like to keep one network if possible but just kicking around short term solutions.
    Thanks again.

  • How can I get the value of a custom property from a resource object?

    I am trying to get the value(s) of a custom property, called "status" within a method. The method has an object of type IResource available to it.
    I have tried the following:
    PropertyName propName = new PropertyName("","status");
    value = res.getProperty(propName).toString();
    However, I am getting a NullPointerException when I try to create the PropertyName instance.
    Is there a better way to get the value of a specific property from a resource object?
    Thanks,
      Tom

    Thanks Praveen.
    I was missing the default namespace of "http://sapportals.com/xmlns/cm" - I thought I could just pass an empty string for the namespace, but it looks like I must always specifiy, even if it is default.
    Tom

  • Is there any way to get the height/width of an image before importing it in the indesign document.

    Hi All,
    I need to obtain an image's attributes such as dimensions (height, width in pixels) without placing image in indesign document.
    I have full path of the image (say abc.jpg is stored at c:\my pic\abc.jpg).
    I have obtained the IDFile for this image, tried getting size using GetFileSize() which correctly return size in bytes.
    Is there any way to get the height/width of image without importing it in the indesign document.
    Please, give me some hints. I have spent quite a lot time digging in CHM. I have searched in FileUtils, IDFile API's but found no method which serves this purpose.
    At this point I am clueless where to search next.
    Any help will be appriciated.
    Just a point to mention, I am able to get image height and width for an image in indesign doc though Its not my requirement.
    Thnx,
    D.

    You might be able to examine the contents of the PlaceGun after calling kImportAndLoadPlaceGunCmdBoss without actually placing the image in a document. Not sure, but would be worth looking at.
    Otherwise you will probably have to write platform specific code, ideally with a generic platform-independant wrapper (see SDKSamples/paneltreeview/PlatformFileSystemIterator).
    For the Mac, look at CGImageGetWidth() etc., not sure what the best option is for windows.
    Perhaps Quicktime could provide you with a platform independant solution.

  • Get the duration of all mp3 files inside a directory

    Hello everyone,
    I am working on a little project done with swing. Since I need an mp3 player inside my swing application, I found a really good solution with JavaFX 2. I have never worked with JavaFX before, therefor it seems to me a little bit strange on some parts.
    Anyway.
    I created a button on my application and as soon as somebody presses that button, the application should scan recursivly a unique directory for mp3 files and store the information of artist, title and track length into a database.
    The mp3 player I created is based on the example from this page:
    http://www.java2s.com/Code/Java/JavaFX/Mp3playerwithmetadataviewandcontrolpanel.htm
    I understand the source code for most parts, but some behaivors are not really clear to me. My thoughts about getting the complete length of the mp3 file was
    media.getDuration
    or
    mediaplayer.getTotalDuration
    but both results are NaN if I call .toMillis();
    Instead I need to create a listener (why?)
    private class TotalDurationListener implements InvalidationListener {
        @Override
        public void invalidated(Observable observable) {
          final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
          final Duration totalDuration = mediaPlayer.getTotalDuration();
          totalDurationLabel.setText(formatDuration(totalDuration));
      }and register this listener on the mediaplayer
    mp.totalDurationProperty().addListener(new TotalDurationListener());I can image that the mediaplayer can "host" several media objects somewho and the listener is called as soon as a new media will be added to the mediaplayer in order
    the calculate the overall duration.
    When is this listener exactly called and is there no other ways to get the total length of the mp3 file?
    Here is a minimal example which should work without any external libs
    package de.hauke.schwimmbad.application.playground;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;
    import javafx.application.Platform;
    import javafx.beans.property.ReadOnlyObjectWrapper;
    import javafx.embed.swing.JFXPanel;
    import javafx.scene.Scene;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.paint.Color;
    import javafx.util.Duration;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.UIManager;
    public class Testing10 extends JFrame {
         private MediaPlayer mediaPlayer;
         private final ReadOnlyObjectWrapper<MediaPlayer> mediaPlayerWrapper = new ReadOnlyObjectWrapper<MediaPlayer>(
                   this, "mediaPlayer");
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   new Testing10();
              } catch (Exception ex) {
                   System.out.println(ex);
         public Testing10() {
              super();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLayout(null);
              setSize(500, 500);
              setTitle("Testing");
              setLocationRelativeTo(null);
              setResizable(false);
              JButton button = new JButton("Scan");
              button.setBounds(10, 10, 150, 30);
              add(button);
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent arg0) {
                        scan();
              final JFXPanel fxPanel = new JFXPanel();
              fxPanel.setBounds(30, 80, 300, 300);
              add(fxPanel);
              Platform.runLater(new Runnable() {
                   public void run() {
                        initFX(fxPanel);
              setVisible(true);
         private void scan() {
              File directory = new File("C:\\dev\\mp3");
              List<File> mp3Files = new ArrayList<File>();
              for (File file : directory.listFiles()) {
                   if(file.getName().endsWith("mp3")) {
                        mp3Files.add(file);
              for (File file : mp3Files) {
                   System.out.println(file.getAbsoluteFile());
                   getLength(file);
         private Duration getLength(File file) {
              if(mediaPlayer != null) {
                   mediaPlayer.stop();
              final Media media = new Media(file.toURI().toString());
              mediaPlayer = new MediaPlayer(media);
              mediaPlayerWrapper.setValue(mediaPlayer);
              if(media.durationProperty()==null) System.out.println("durationProperty ist null");
              if(media.durationProperty().get()==null) System.out.println(".get() ist null");
              System.out.println("---> " + media.durationProperty().get().toMillis());
              return media.getDuration();
         private void initFX(JFXPanel fxPanel) {
              BorderPane root = new BorderPane();
              Scene scene = new Scene(root, Color.ALICEBLUE);
              fxPanel.setScene(scene);
    }The other question is why do I need a listener for the meta data to be changed in order to get the meta data?
    media.getMetadata().addListener(new MapChangeListener<String, Object>()Why can't I call something like
    media.getMetadata() --> returns a filled map?
    The metadata problem is not included inside the example from above.
    Sorry for my english but I hope everybody can understand the issue.
    Many greetings,
    Hauke

    The nature of the Media class is that it accesses it asynchronously. This means that when you create an instance of it, and then immediately query it, the data you want may not be available yet. This is all in the Javadoc, see the doc for Media:
    The media information is obtained asynchronously and so not necessarily available immediately after instantiation of the class. All information should however be available if the instance has been associated with a MediaPlayer and that player has transitioned to MediaPlayer.Status.READY statusSo you could associate the Media with a MediaPlayer, and then wait until it goes to the Status READY, and then read the length of the Media.
    As for your 2nd question, getMetadata() returns a Map. You can just loop through it:
      for(Map.Entry<String, Object> entry : media.getMetadata()) {
        // etc
      }However, the same restrictions apply as with Media -- you will probably need to wait before the information is available -- that's why the Listener approach works, because it will notify you as soon as the information is added to the map.

Maybe you are looking for

  • HT2589 How can I Change my apple id (email adress) and keep the same account? Or do I have to create a whole new account?

    My email address was hacked and I can no longer use it. How can I change the email address with our loosing everything on my iTunes account?

  • Open in Browser changes 2 pages

    There are several pages for reference, but they all act the same. www.shallowdivemedia.com Click "compare" at the bottom. A pop-up will come up - which is supposed to happen But then the main screen also shows the comparison chart I can't find any ex

  • Keynote 6.0 - Functionality Questions & A few Bugs

    I'm a presentation designer who works in Keynote extensively.  The new version really turned everything sideways with some good changes and some bad.  I've got a lot of questions (and obvoiusly the help file is only "eh" -- it's so not a manual for h

  • Mail with French / Spanish accented characters appear as Question marks

    Hi I am facing issues in mails that have French / Spanish accented characters in mail subject.Accented characters appear as Question marks (?) when received in the inbox.Mail subject is read from properties file. Please let me know the following - Sh

  • Read Text Parameters

    Hi All ; I have problem with read text parameters. Now Im using the parameters like below; name = belnr + gjahr + buzei call function 'READ_TEXT'             exporting             client                = sy-mandt             id                      =