yoheimuta / RxMusicPlayer

A reactive library to make it easy for audio playbacks using RxSwift.
MIT License
58 stars 8 forks source link

Player seek #20

Closed rastaman111 closed 2 years ago

rastaman111 commented 3 years ago

Hi @yoheimuta !

I want to do through SoreDate to do time saving In the musicPlayer.player method? .Rx.currentItemTime (), as I understand it, it is best to save data every 5 seconds var i = Int (($ 0.0? .seconds!)!)% 5

Снимок экрана 2020-10-27 в 11 13 02

If I'm wrong, correct me and tell me how best to save seconds here

The second question is to start at a certain second i start in musicPlayer.player? .run (cmd: cmd)

Снимок экрана 2020-10-27 в 11 12 51

But then there is a problem with the fact that if there is a saved time for example 5 seconds and I am now at 9 seconds and pressed stop, then pressing start I start from 5 seconds

If I'm wrong, correct me and tell me how best to start here

My code is not working correctly

I would be grateful for your help 👍

rastaman111 commented 3 years ago

Hi, have any thoughts on this issue?

yoheimuta commented 3 years ago

@rastaman111 Thank you for your interest 🙋‍♀️

I'll be getting to it tomorrow. In the meantime, I have some questions to make it clearer.

  1. What does SoreDate mean?
  2. 1st question means you want to seek a better solution to save the current time of the playback periodically? Your code barely achieves your purpose, though?
  3. 2nd question means you want to play the music from the specified position using a seek method smoothly?
rastaman111 commented 3 years ago

@yoheimuta

The task is this: you need to save the last second of audio, that is, you left the application, saved it, listened for 10 seconds and switched to another track, saved it, etc., all this is saved in CoreData, and when I turn on audio and if this audio is in CoreData, comparison by name , then I start from the second that is indicated in CoreData. I think I clearly explained the task)

yoheimuta commented 3 years ago

@rastaman111

In the musicPlayer.player method? .Rx.currentItemTime (), If I'm wrong, correct me and tell me how best to save seconds here

Using currentItemTime is a good way to implement this. I have no idea about any better solutions.

there is a problem with the fact that if there is a saved time for example 5 seconds and I am now at 9 seconds and pressed stop, then pressing start I start from 5 seconds

It seems to be better to remove a used item from the listItems to prevent from reusing the same one, although I presume that this part is not relevant to the library actually.

rastaman111 commented 3 years ago

@yoheimuta The .Rx.currentItemTime () method is called about 10 times in 1 second, and so how can I stop all actions in the same way to save time in the first call?

yoheimuta commented 3 years ago

@rastaman111 Your question means that you want to save the exact one per second? If so, I recommend that you filter all saved data by yourself like the below steps.

  1. Save all times data emitted by Rx.currentItemTime() method in your array
  2. Filter your array to remove duplicate data with the same second