yoheimuta / RxMusicPlayer

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

Repeat mode settings #14

Open Shishani58 opened 4 years ago

Shishani58 commented 4 years ago

Thanks so much for such a nice library. Is it possible to do something like numberOfLoops from AVAudioPlayer? For both modes — repeatOne and repeatAll?

yoheimuta commented 4 years ago

@Shishani58 Sorry for the late replay. It looks hard to do something like numberOfLoops at the moment. To support this, RxMusicPlayer should implement the numberOfLoops for repeatOne, like the below.

diff --git a/RxMusicPlayer/RxMusicPlayer.swift b/RxMusicPlayer/RxMusicPlayer.swift
index c0dc8ce..6ce6f2b 100644
--- a/RxMusicPlayer/RxMusicPlayer.swift
+++ b/RxMusicPlayer/RxMusicPlayer.swift
@@ -87,7 +87,7 @@ open class RxMusicPlayer: NSObject {
      */
     public enum RepeatMode: Equatable {
         case none
-        case one
+        case one(numberOfLoops: Int)
         case all
     }

If you like it, I can accept your PR. Or I try to implement It when I have time.