Created
February 5, 2023 14:10
-
-
Save alibahaaa/c43050b50f6893a1d404e55c68033ebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MusicPlayerFacade { | |
private val player = MediaPlayer() | |
private val playlist = Playlist() | |
fun play(song: Song) { | |
playlist.clear() | |
playlist.addSong(song) | |
player.reset() | |
player.setDataSource(song.filePath) | |
player.prepare() | |
player.start() | |
} | |
fun stop() { | |
player.stop() | |
} | |
} | |
class Song(val filePath: String) | |
class MediaPlayer { | |
fun reset() { | |
// Implementation for resetting the media player | |
} | |
fun setDataSource(filePath: String) { | |
// Implementation for setting the data source for the media player | |
} | |
fun prepare() { | |
// Implementation for preparing the media player | |
} | |
fun start() { | |
// Implementation for starting the media player | |
} | |
fun stop() { | |
// Implementation for stopping the media player | |
} | |
} | |
class Playlist { | |
private val songs = mutableListOf<Song>() | |
fun clear() { | |
songs.clear() | |
} | |
fun addSong(song: Song) { | |
songs.add(song) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment