Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php 8.1 File append not working #12

Open
sodevrom opened this issue Nov 6, 2022 · 2 comments
Open

Php 8.1 File append not working #12

sodevrom opened this issue Nov 6, 2022 · 2 comments

Comments

@sodevrom
Copy link

sodevrom commented Nov 6, 2022

Hello
I am trying to append multiple mp3 files (same encoding), but the files do not get appended.
Only the first file is saved in the final output.
Example:

$file_mp3= \falahati\PHPMP3\MpegAudio::fromFile("audio1.mp3");
$file_mp3->append(\falahati\PHPMP3\MpegAudio::fromFile("audio2.mp3"));
$file_mp3->saveFile("final_file.mp3");

No errors, only the first mp3 is added in the final file, and the final saved file size is equal to file 1.

Can you please help?

@sodevrom
Copy link
Author

sodevrom commented Nov 7, 2022

Doing more tests, it seems the added function (to fix detection of end of file)

$this->memoryPointer = min($this->memoryLength, $index + $length);
//this is the problem ->
if ($this->memoryPointer >= $this->memoryLength) {
return false;
}

Is causing the problem with append. But if we remove this, in some cases it goes in an infinite loop.

@sodevrom
Copy link
Author

sodevrom commented Nov 7, 2022

More testing, I think I Found a fix.
Instead of
if ($this->memoryPointer >= $this->memoryLength) {
return false;
}

We should write
if($index+$length>$this->memoryLength)
return false;

It works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant