-
Notifications
You must be signed in to change notification settings - Fork 151
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
Streamer from bytes reader has a length of 0 #123
Comments
I think something is accidentally lost in the process of converting []byte to io.ReadCloser, or os.File is the most appropriate for mp3.Decode, so I recommend converting []byte to os.File; And I succeeded, solved the problem, and got the music length.
It works like this:
Hope it can help you! |
In order for Len and Seek methods to work you need to implement io.Seeker on the struct you pass into mp3.Decode, which NopCloser does not |
Tested it, and implementing io.Seeker wont actually help, because beep uses go-mp3 package, and it sets the length when you call mp3.Decode, which means it will only be the size of the buffer at that time. |
I think the problem has been solved. This is my blog article, which contains more information: https://blog.csdn.net/Deng_Xian_Sheng/article/details/125128054?ops_request_misc=&request_id=e233f01259634c8a88aba26c32e9cd7c&biz_id=&utm_medium=distribute.pc_search_result.none -Task blog-2 |
…name-to-readme-links Apply the master -> main branch rename to links and images in the README
I'm trying to read an audio file through a reader from a
[]byte
array, but when I do this, the length of the output stream is0
. However, using the traditional method ofos.Open()
, the length is9589248
. Both methods can play the audio, but I can't use.Seek()
when using thebyte
array. I'm not sure what's wrong, any help would be appreciated.The text was updated successfully, but these errors were encountered: