I am developing an application in Java. Part of it includes playing an mp3 file via another application. I need to find the duration (total play time) of the mp3 file. How do I do that?
how do i find out duration/total play time of an mp3 file using java?
3.1k Views Asked by shibi vb At
2
There are 2 best solutions below
0
Anshu kumar
On
For small .mp3 files you can use:
AudioFile audioFile = AudioFileIO.read(MyFileChooser.fileName);
int duration= audioFile.getAudioHeader().getTrackLength();
System.out.println(duration);
This will give a string containing the minute and second duration in it. eg: 316 for 3:16.
Note that This method is not suitable with larger files.
Related Questions in TIME
- Perform a task each interval
- PLSQL Need REFCURSOR DATE + TIME
- How to set timezone to the local in Rails?
- How to check duplicates in an array with a time complexity of O(n) in C lang?
- Having trouble writing a calendar, I couldn't find a detailed guide answering my questions anywhere
- How to write the current time to a new line of a .txt file on php execution
- Golang time zone parsing not returning the correct zone on ubuntu server
- CMD specifying columns to save?
- How do I check if a time is between two times which are stored as Strings in Ruby on Rails?
- having issues with python time object
- Why Google Analytics show bounce rate 100% and avg time more then 1min
- time formatting in matlab
- Python - creating a delay that takes in account the execution time
- JodaTime Comparing two dates with different time zone
- The simple timezone clock function falls into incorrect condition and I have no idea why
Related Questions in MP3
- Convert youtube video to mp3 using Quick MP3 API
- mp3 to sample array NAudio
- How to fit the Ringdroid waveform in full width according to width of mobile screen
- How to join mp3 and wav files
- Unknown android app using my mp3 files without my permission
- Android audio too fast on some devices with MediaCodec and AudioTrack
- change .mp3 file format to .aac file format in android using java programming
- Crop MP3 to last N seconds
- Streaming songs from pc
- Splitting up a variable in bash
- MP3 songs do not play in media player
- how to make a button that share my res/raw/xxx.mp3 file
- Adding tags to mp3 with eyed3 results in no change
- How to make an MP3 file wait to play until after another MP3
- PHP - MP3 proxy for streaming
Related Questions in DURATION
- Asterisk: How to convert time to seconds
- how to convert javax.xml.datatype.Duration
- How to format duration in Python (timedelta)?
- Save duration with precision in Parse.com
- Time duration to string 2h instead 2h0m0s
- How to get the time duration from subtracting two times
- How to remove songs which has 0 duration in cursor in android
- Show hidden div on :hover, and make div stay visible for 5 seconds after mouseout on CSS / CSS3
- backstretch.js duration out of sync with .animate() delay
- Notification like Toast but with longer duration
- ISO 8601 Duration with milliseconds?
- How to use the Java 8 Duration.of(amount, unit) method?
- Windows Phone 8 - get duration of a Song object when use MediaPlayer
- What Java library object encapsulate a number and `TimeUnit`?
- How to check duration of video in Angular 4.3.1 using ng2-file-upload?
Related Questions in JLAYER
- Problems with adding JPanel into JLayer
- Java executable .jar file does not play MP3 file from external resource
- Use JLayer to play mp3 resource
- AudioSystem.getAudioFileFormat not working with mp3 Java
- Jar with compressed music with java?
- Why does buffer size affect audio data?
- Java JLayer: Problem with implementing Pausable Player
- can't make the Jlayer change position with the scrollpane
- jLayer 1.0.1 getPosition does not always return ms
- how do i find out duration/total play time of an mp3 file using java?
- Can't stop song because it has to end before other lines run
- Circular Progress Bar for Java Swing not working
- Java 7 - JLayer, no LockableUI
- JLayer - Pause and resume song
- jLayer -- Playing mp3 causes distortion at start of file
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can do this very easily using JAudioTagger:
That will print out the track length of the file at filePath. The logger line is to remove a lot of (probably) unwanted info/debugging logging from JAudioTagger. Besides this, JAudioTagger supports getting all sorts of metadata tags from different audio file types (MP3, MP4, WMA, FLAC, Ogg Vorbis), both from file-embedded tags. You can even get MusicBrainz info easily, but I haven't tried that yet. For more info:
http://www.jthink.net/jaudiotagger/examples_read.jsp
You can get the jar files for it here:
http://download.java.net/maven/2/org/jaudiotagger/