SwiftAudio icon indicating copy to clipboard operation
SwiftAudio copied to clipboard

Caching & More Robust Loading

Open dcvz opened this issue 5 years ago • 7 comments

Wanted to bring this to your attention: https://github.com/neekeetab/CachingPlayerItem

I've done some basic test integrating into the library and it's interesting.

In a library I would expect a track should play ASAP - and caching in queued mode to automatically download the next track when the current one is fully loaded.

This doesn't provide all of that but it has some nice ideas.

dcvz avatar Jan 30 '19 20:01 dcvz

Nice!

Yeah, I have thought about the same thing and it is definitely something that should be added 👍

jorgenhenrichsen avatar Jan 31 '19 09:01 jorgenhenrichsen

yes the library is so clean, a small suggestion is to use the same mentioned custom AVPlayerItem in SwiftAudio.

murad1981 avatar Apr 25 '19 11:04 murad1981

@dcvz Hey, I am trying to add caching to SwiftAudio using https://github.com/neekeetab/CachingPlayerItem

but the func add and load take AudioItem add(items: [AudioItem], playWhenReady: Bool = true)

and in the caching library AVPlayer take CachingPlayerItem so how to integrate it?

Thank in Advance

JhonnyTawk avatar Sep 30 '19 07:09 JhonnyTawk

@dcvz We could also add a preloading functionality. Ideas: https://github.com/delannoyk/AudioPlayer/issues/36#issuecomment-198806154

Thanks @dcvz for react-native-track-player. I came looking if the underlying SwiftAudio provides a preloading functionality. I am not an iOS developer but will try to implement this feature in a fork. I'll let you know if I come up with something. This is a must-have to built apps with awesome feeds (Instagram e.g.) with almost 0 load time.

nishanBende avatar Nov 11 '19 13:11 nishanBende

@dcvz I have attempted a preload functionality in SwiftAudio and tested with react-native-track-player. The playing becomes as fast as a downloaded asset. I have been testing this for a few days. https://github.com/nishanBende/SwiftAudio/commit/41e5564c4f604c86a5c8802eab627c887c2b8d80

P.S. I am not sure about the implications it can bring, I took the implementation idea from this comment. https://github.com/delannoyk/AudioPlayer/issues/36#issuecomment-198806154

nishanBende avatar Nov 17 '19 03:11 nishanBende

@dcvz I am managing the queue in JavaScript because the underneath QueueAudioPlayer is not preloading the next track, so, I have exported the preload function to RNTrackPlayer with preload/cancelPreload implementation in this commit. https://github.com/nishanBende/SwiftAudio/commit/41e5564c4f604c86a5c8802eab627c887c2b8d80

I feel we should split it into 2 separate features.

  1. Caching while Playing. Similar to https://github.com/neekeetab/CachingPlayerItem.
  2. Preloading any asset programmatically.

Can we also let AVQueuePlayer handle the queue for us? There's some discussion that it internally preloads the next track but I cannot confirm. https://developer.apple.com/documentation/avfoundation/avqueueplayer

nishanBende avatar Nov 17 '19 04:11 nishanBende

I also come from react-native-track-player and would love to see gapless queues implemented.

whsmacon avatar Jul 27 '20 04:07 whsmacon