google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

Crossfade implementation question #2946

Closed marcin-adamczewski closed 7 years ago

marcin-adamczewski commented 7 years ago

Hello,

I want to implement a BPM matching Crossfade feature using Exoplayer. Basically I have a concept how it should work, but I'm not sure which Exoplayer classes to modify to achieve my goals.

Let me please first write how I want to do this so you can understand the case. As you probably know BPM Crossfade let to seamlessly switch from one song to another. Additionally it adjusts second song tempo to first song tempo during the crossfade. So the plan is as follows:

  1. Load song A and B so they both starts to buffer.
  2. Decoded samples of song A and B are stored in buffers BF1 and BF2.
  3. There is a class called MUX which is a main buffer and contains both songs buffers BF1 and BF2. MUX provides audio samples to the Player. Samples provided to the Player are BF1 samples or mixed samples from BF1 and BF2 if there is a crossfade.
  4. If buffer reach the crossfade point then samples are send to Analyser class so it can analyse samples from both buffers and modify them for crossfade. Analyser sends modified samples to MUX which updated it's main buffer.
  5. When crossfade is finished load next song from playlist

So basically which class to extend to create class like MUX? Should it be some custom MediaSource? How can I access BF1 and BF2?

I've also read somewhere that you don't anymore buffer songs that are not active. How can I overcome this as I want to manage second song buffer.

I hope you can guide me a little bit. I decided to ask question here and not on StackOverflow as you have much deeper knowledge of ExoPlayer structure.

Thanks in advance for any help!

ojw28 commented 7 years ago

This is quite far outside the scope of this issue tracker. We're unable to offer advice on this kind of large customization effort; we simply don't have enough time. Sorry.