+ 12
Music player kotlin [SOLVED]
6 odpowiedzi
+ 11
Do you need help for last code coach in kotlin lesson
+ 5
Nyuon Khoryom Nyuon bro use this :
class MusicPlayer {
private var songs: Array<String> = arrayOf()
//your code goes here
fun add(track : String){
songs += track
}
fun show() {
var song : String;
for (song in songs)
println(song)
}
fun play() {
println("Playing "+songs[0]);
}
}
fun main(args: Array<String>) {
val m = MusicPlayer()
while(true) {
var input = readLine()!!
if(input == "stop") {
break
}
m.add(input)
}
m.show()
m.play()
}
+ 1
class MusicPlayer {
private var songs: Array<String> = arrayOf()
//your code goes here
}
fun main(args: Array<String>) {
val m = MusicPlayer()
while(true) {
var input = readLine()!!
if(input == "stop") {
break
}
m.add(input)
}
m.show()
m.play()
}
this is my attempt bro and its not working
+ 1
This concept quite helpful :-
class MusicPlayer {
private var songs: Array<String> = arrayOf()
//your code goes here
fun add(track : String){ //to add songs
songs += track
}
fun show() { //to show songs
var song : String;
for (song in songs)
println(song)
}
fun play() { //to play new songs
println("Playing "+songs[0]);
}
}
fun main(args: Array<String>) {
val m = MusicPlayer()
while(true) {
var input = readLine()!!
if(input == "stop") {
break
}
0
Nope!
0
Here's a simple example of a music player interface in Kotlin:
Create a new Android project in Android Studio.
Design your music player layout. For simplicity, you can create a layout file (e.g., activity_main.xml) with buttons for play, pause, stop, and a seek bar to display the progress of the currently playing track.
xml
Copy code
<!-- activity_main.xml -->
<LinearLayout
xmlns:android="http://schemas.android.com https://artistpush.me/"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<!-- Add UI elements like TextView for displaying song title and artist -->
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" />
<Button
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play" />
<Button
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pause" />
<Button
android:id="@+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stop" />
</LinearLayout>