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 answers
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
- I need help to understand the time wich my simple ''hello world'' is taking to execute
- What would be the most efficient way to store multiple sets of fixed arrays (std::vector)?
- C++ : Is there an objective universal way to compare the speed of iterative algorithms?
- (React)At rendering, initial value of zustand comesout firstly Please, give me your opinions
- Time not correct in "Device explorer" (device manager ; android studio)
- Countdown to varying payday in Javascript
- Time Limit Exceeded, Leetcode problem, 3Sum, 308 / 313 testcases passed, Why is it slow? Python
- Print time stamp in c
- TIMESTAMP Field - UTC <> Local TimeZone
- How to carry Last 24 hours value in time filter from one dashboard to another dashboard in Splunk
- Is there a way to get daylight savings time info for non local timezones
- Can I print '1' n times without using a loop in C programming?
- Embedded Linux board using a GPIO-PPS (without GPS, etc.) for time conditioning - ppstest can SEE the signal and report, but no time conditioning
- Converting streamlit library time input to milliseconds since epoch
- latest version of redshift with crazy compile times
Related Questions in MP3
- kid3 - Import Album Art along with other tags from Discogs
- Implementing trim and fade filters with ffmpeg - MP3
- playing mp3 downloaded via curllib gets cut short
- Can Twilio save a voicemail in MP3 format when using the AWS S3 external storage option
- Using polly to generate audio from LLM output
- How to re-encode an audio to match another one, to avoid re-encoding the whole audio
- Can I just append mp3s to each other? Does that create audio artifacts?
- How can I make it so other people (and myself) can open the .py file and not have it crash when using mp3 files in the code?
- Problem with saving metadata in mp3 files using eyed3 (python)
- tagging mp3 file with TagLibSharp corrupts it
- Resolving "Module parse failed" error importing MP3s in NextJS14 TS?
- Play audio response from OpenAI TTS API in React Native with Expo
- MP3 file won't load on iOS Safari, works fine on MacOS / Chrome / Edge?
- How do you use eyed3 to create comments for MP3 files?
- Lamejs exports mp3 compressed audio file with no sound
Related Questions in DURATION
- Flutter Duration_Picker Package not working properly with ColorScheme(brightness.dark)
- Incorrect duration calculation in php
- how to present seconds as duration in jq
- How to find out duration using 2 date value which are in string format in presto SQL
- Flutter mediaItem.duration and playback speed design
- AppSheets timestamps and duration difference
- How to parse moment.duration with multiple formats
- How to migrate Joda time Period API to Java time (java 8)?
- Spring Boot 3 Unit Test cannot convert Duration value when ContextConfiguration is used to provide test scope
- How can I calculate the duration of workblocks in Power BI when I only have a table with timestamps and no explicit start or end information?
- Format a duration in days hours minutes in Excel
- In jmeter How to configure test plan with different duration and threads rampup
- Tkinter Display Stopwatch hours, seconds and minutes
- How to change the format of a Duration?
- MusicAlbum duration in Schema.org
Related Questions in JLAYER
- Runtime error on a program to make a music jukebox using Jlayer library (v1.0.1)
- Java JLayer: Problem with implementing Pausable Player
- Synthetica look and feel throws a class cast exception when using JLayer with JscrollPane with Java 11
- Cannot play the sound of music with no error for Java
- Is there a way to draw a fixed rectangle on a JScrollPane?
- Why JLayer Music can't play in Jar file?
- Serious Performance issue using JLayer drawing with AquaLookAndFeel
- JLayer sometimes unable to load resource 'sfd.ser'
- Java: Console stops working when using javazoom
- java.io.FileNotFoundException even when the file path is correct
- JLayer Change volume while playing (JavaZoom)
- How do I double-buffer in Java Swing on a Retina display without losing the higher resolution?
- Can't stop song because it has to end before other lines run
- Why is this program not playing my music files?
- Java jlayer on RasberryPi
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?
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)
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/