Comments (12)
Hey, this is is a feature that probably will be included sometime in the future.
Meanwhile, this is one possible solution:
var player = QueuedAudioPlayer()
player.addItems([
audioItem1,
audioItem2,
audioItem3
]]
player.event.playbackEnd.addListener(self, handlePlaybackEnd)
func handlePlaybackEnd(data: AudioPlayer.PlaybackEndEventData) {
if data == .playedUntilEnd {
try? player.previous()
}
}
This will just step back the queue whenever a track is finished. If you want to enable/disable the repeat function you can just add a boolean and check that whenever a track finishes.
from swiftaudio.
Thank you for your response, unfortunately, this suggestion doesn't work. The app crashes after playback ends with error:
reason: 'Cannot remove an observer <SwiftAudio.AVPlayerObserver 0x6000035f2840> for the key path "timeControlStatus" from <AVPlayer 0x6000022b8800> because it is not registered as an observer.
audioController.player.event.playbackEnd.addListener(self, handlePlaybackEnd) is added in ViewDidLoad method
This is what I tried
func handlePlaybackEnd(data: AudioPlayer.PlaybackEndEventData) {
if data == .playedUntilEnd {
if repeatOn {
// audioController.player.pause()
try? audioController.player.previous()
// audioController.player.play()
}else {
try? audioController.player.next()
}
}
}
```
from swiftaudio.
Okay I see. What version of SwiftAudio are you using?
from swiftaudio.
I am using the latest version.
from swiftaudio.
Is it happening when the player.previous()
is triggered? Or player.next()
?
from swiftaudio.
from swiftaudio.
Okay, for me the method kinda worked, but it is not optimal. I am gonna tag this as an enhancement since a repeat function is useful, so it will be implemented when I get around to it
from swiftaudio.
from swiftaudio.
Thanks, yeah that seems like a good solution for now
from swiftaudio.
from swiftaudio.
Nice, good job
from swiftaudio.
@wawilliams003 can you give me pointers how did you add the shuffle and the repeat button?
Thank you
from swiftaudio.
Related Issues (20)
- Skipforward and skipforward issue HOT 5
- Set preferredPeakBitRate
- Catch Expired Auth Token to modify headers HOT 1
- Player state not updated after triggering the play()
- Cannot run Example app HOT 1
- How to know that the song is ended HOT 1
- AVQueuePlayer for gapless audio
- Regarding stop button functionality HOT 15
- QueuedAudioPlayer.reset() is not accessible due to 'internal' protection level
- Not working with local file in Queue HOT 1
- Load the audio player
- MPRemoteCommandCenter
- handleAudioPlayerStateChange call multiple time HOT 1
- how to clearQueue HOT 2
- .wav file not play
- Repository Future HOT 2
- @available enum issue on XCode 13 HOT 2
- iOS 15 can not play music in the background HOT 6
- Song will not play if it contains any character between "èéêëēėęàáâäæãåāîïíīįìôöòóœøōõûüùúū"
- Xcode 12.5 - Using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftaudio.