I have a custom AudioPlayer
class to handle playing audio in my app, and it uses the android MediaPlayer
class under the hood.
It currently has a method play(source: MediaDataSource)
. This needs to take in some generic source object that it can play, so I decided to use MediaDataSource
which seems right.
How do I obtain a MediaDataSource
from a resource, e.g. R.raw.my_audio_file
, so that my custom AudioPlayer
class can use it? Or is MediaDataSource
the wrong type to use here, and if so what other type should I use?