yoheimuta / RxMusicPlayer

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

Don't updated speed locked screen #8

Closed rastaman111 closed 4 years ago

rastaman111 commented 4 years ago

Hello! After scrolling, I’ll see progress at any time, NowPlayingInfoCenter is not updated on the locked screen only if you click stop and again the strat, then it will be updated and it is also possible to turn on the audio playback speed at 2x NowPlayingInfoCenter is also not updated, the strip moves like usual 1x speed.

link to an example video: https://yadi.sk/i/znHUhyeHrdKekg

var rate: Float = 1.0 override func viewDidLoad() { super.viewDidLoad()

     rateSeekSpeed(self.rate)
}
func rateSeekSpeed(_ rate: Float) {

    musicPlayer.player?.rx.playerIndex()
    .do(onNext: { index in
        self.musicPlayer.player?.player?.rate = rate
    })
    .drive()
    .disposed(by: musicPlayer.disposeBag)

}

@IBAction func rateSpeedButton(_ sender: UIButton) {
    let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
    alert.addAction(UIAlertAction(title: "2x", style: .default, handler: { (alert) in
        self.rate = 2
        self.rateSeekSpeed(self.rate)
    }))
    alert.addAction(UIAlertAction(title: "1.5x", style: .default, handler: { (alert) in
        self.rate = 1.5
        self.rateSeekSpeed(self.rate)
    }))
    alert.addAction(UIAlertAction(title: "1.25x", style: .default, handler: { (alert) in
        self.rate = 1.25
        self.rateSeekSpeed(self.rate)
    }))
    alert.addAction(UIAlertAction(title: "1x", style: .default, handler: { (alert) in
        self.rate = 1
        self.rateSeekSpeed(self.rate)
    }))
    alert.addAction(UIAlertAction(title: "0.75x", style: .default, handler: { (alert) in
        self.rate = 0.75
        self.rateSeekSpeed(self.rate)
    }))
    alert.addAction(UIAlertAction(title: "0.5x", style: .default, handler: { (alert) in
        self.rate = 0.5
        self.rateSeekSpeed(self.rate)
    }))

    alert.addAction(UIAlertAction(title: "Отмена", style: .cancel, handler: nil))
    alert.view.tintColor = .black
    present(alert, animated: true, completion: nil)
}
yoheimuta commented 4 years ago

@rastaman111 Thank you for reaching out. I'm investigating it.

yoheimuta commented 4 years ago

I found out that the RxMusicPlayer needs built-in support for the playback rate. I'm going to add the feature.

rastaman111 commented 4 years ago

Hello! Thank you, I look forward to an update.

rastaman111 commented 4 years ago

Hello! I found another bug with playback speed

I turn on the audio, select a speed of 2x, press pause and when I click play the speed becomes 1x by default

yoheimuta commented 4 years ago

[memo] It's almost finished, except for a confirmation with a device, which my local preparation is taking some time.

rastaman111 commented 4 years ago

Hello! I did not quite understand You did, but it remains to check everything on a real device?

yoheimuta commented 4 years ago

@rastaman111 I updated the master branch to add the feature. Can you confirm it works fine?

rastaman111 commented 4 years ago

Hi. where can i find your update?

yoheimuta commented 4 years ago

@rastaman111 Can you elaborate? I updated the master branch of this repository.

yoheimuta commented 4 years ago

I plan to update the Podspec after your confirmation. If you want the updated Pod now, I can do it ahead of that.

rastaman111 commented 4 years ago

Hi, we checked it for how everything works, but can you tick the end of the selected speed? Example 1x ✓

yoheimuta commented 4 years ago

Thank you for your confirmation.

Yes. I added a tick at the end.