doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.25k stars 1.01k forks source link

[Feature Request] Handle local file update #2129

Closed catalinmiron closed 1 year ago

catalinmiron commented 1 year ago

What is the need and use case of this feature? Playing a local file that I'm constantly updating/writing on. (using fs.writeStream) I am getting the chunks for the mp3 from the server and I am appending them to the file, but once the file has been added to the queue, there's no way to update it.

Describe the ideal solution It will be great if the player will know when the file has changed and update itself, keeping the player position in place.

Describe alternatives you've considered Keep track of the progress and when a new chunk was added, remove the track, add it again and set the progress as the previous progress.

Additional context On web, we have: MediaSource that you can pass to an <audio /> tag and in this way we create a fake streaming mechanism from a file that's constantly updated.

How I can Help What can you do to help get this feature into production? Can you assist by working on this feature and creating a Pull Request?

I don't know where to start or if it's possible to achieve this type of behaviour.

lovegaoshi commented 1 year ago

at least for android you might need to build your own datasource: https://juliensalvi.medium.com/building-custom-datasource-for-exoplayer-87fd16c71950 but why not just use HLS from your server for streaming?

catalinmiron commented 1 year ago

Hi @lovegaoshi the reason is that the server is not saving the file until the processing has finished and in return, it's sending the already processed chunks.

Do you have any recommendation for how can I approach this? It seems that Flutter just_audio package has this capability: image

If there's something I can help out with, please hit me up!

lovegaoshi commented 1 year ago

I dunno how much effort you'd like to spend on building your own http server like that flutter package did, RNTP and exoplayer definitely doesn't have that capability...

Does your server absolutely not store the chunk files temporarily to make a m3u8 file for hls? I think the dataSource link will do what you're looking for on Android at least - a customized read() that gets the specific chunk file. PR is very welcomed

On Tue, Sep 26, 2023, 7:29 AM Catalin Miron @.***> wrote:

Hi @lovegaoshi https://github.com/lovegaoshi the reason is that the server is not saving the file until the processing has finished and in return, it's sending the already processed chunks.

Do you have any recommendation for how can I approach this? It seems that Flutter just_audio https://pub.dev/packages/just_audio package has this capability: [image: image] https://user-images.githubusercontent.com/2805320/270691070-99122a0d-743a-45c5-aadd-ff4d34e71e78.png

If there's something I can help out with, please hit me up!

— Reply to this email directly, view it on GitHub https://github.com/doublesymmetry/react-native-track-player/issues/2129#issuecomment-1735663385, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVW2GB7DQG32KVGRYIDX4LRFNANCNFSM6AAAAAA47SUO7I . You are receiving this because you were mentioned.Message ID: @.*** com>

jspizziri commented 1 year ago

@catalinmiron to me this seems out of scope for this project, as you effectively are trying to build an embedded server.

What you're trying to accomplish is livestreaming it sounds like ("he server is not saving the file until the processing has finished"). You should investigate a serverside transcoding pipeline that uses HLS or Dash and serve that to your client. You can also serve the equivalent of a radio stream, which also works in RNTP.

Either way, I think what you're requesting is pretty far out of scope and I don't really see the use case for it. At least as you're describing it.

catalinmiron commented 1 year ago

Thanks @jspizziri for the clarification. I totally agree that this is out of the library scope. By the way, thank you very much for creating such powerful player. Take care ✌️