Php obtains mp3 file information length modification

Source: Internet
Author: User
Modify function djinfo ($ dir) for obtaining mp3 file information using php)
{
If (! File_exists ($ dir) return '';
If (substr (php_uname ('s '),) = "Windows") {// not supported by LINUX
$ Player = new COM ("WMPlayer. OCX ");
$ Media = $ player-> newMedia ($ dir );
$ Time = $ media-> duration; // Obtain the duration
@ $ S_bitrate = $ media-> getItemInfo (Bitrate); // get the bit rate
@ $ Size = $ media-> getItemInfo (FileSize); // size
$ Time = sprintf ("% 01.0f", $ time );
$ S_duration = strftime ("% H: % M: % S seconds", $ time-28800 );
$ S_bitrate = str_replace (substr ($ s_bitrate,-3), "", $ s_bitrate). "Kbps ";
$ S_size = $ this-> formatsize ($ size );
Ob_flush (); flush ();
Return $ s_size. '|'. $ s_bitrate. '|'. $ s_duration;
} Else {
Return '';
}
}

The original code is like this. for example, if the original acquisition time is 01:08:05, you want to change it to 68 minutes and 05 seconds.
How can you change it? thank you.


Reply to discussion (solution)

Thank you for your help.

Do you want to edit mp3 files? According to Microsoft's definition, media should only read data and cannot modify mp3 files?
Https://msdn.microsoft.com/en-us/library/windows/desktop/dd563869 (v = vs.85). aspx #
Bitrate and FileSize isReadOnlyItem are both true, filesize definition page: https://msdn.microsoft.com/en-us/library/windows/desktop/dd562991 (v = vs.85). aspx

In this case, it is better to directly ask vb and other developers whether they can use WMPlayer. OCX to change files?

I want to convert the image to 68 minutes and 05 seconds after 01:08:05, instead of modifying the MP3 file.

So it's just a matter of time display?
$ Media-> duration results in seconds, so it is $ time/60 minutes, $ time % 60 seconds. what is the result?

So it's just a matter of time display?
$ Media-> duration results in seconds, so it is $ time/60 minutes, $ time % 60 seconds. what is the result?



$ Time = 4085;
Echo sprintf ("% dmin, % 02 dsec", floor ($ time/60), $ time % 60 );
This feeling

$ Time = $ time-28800; $ s_duration = date ('H', $ time) * 60 + date ('I', $ time ). date ("minute second", $ time); echo $ s_duration;
68 minutes 05 seconds

Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.