Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes:#2 #13

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.activity:activity:1.8.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
android:supportsRtl="true"
android:theme="@style/Theme.Arjan"
tools:targetApi="31">

<activity
android:name=".MainActivity"
android:exported="true">
android:name=".splash"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity
android:name=".MainActivity"
android:exported="true">

</activity>
</application>

Expand Down
128 changes: 100 additions & 28 deletions app/src/main/java/com/example/arjan/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,136 @@ package com.example.arjan
import android.media.MediaPlayer
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Looper
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.SeekBar
import com.google.android.material.slider.Slider
import java.util.logging.Handler
import android.widget.TextView
import android.widget.Toast

class MainActivity : AppCompatActivity() {

private var mp : MediaPlayer? = null
private lateinit var play : ImageView
private lateinit var pause : ImageView
private var mp: MediaPlayer? = null
private lateinit var play: ImageView
private lateinit var prev: ImageView
private lateinit var card: ImageView
private lateinit var songTitle: TextView
private lateinit var next: ImageView
private lateinit var seekbar: SeekBar
private var currentSong = mutableListOf(R.raw.arjan)
private var currentSong = mutableListOf(R.raw.arjan, R.raw.bekhayalii,R.raw.sajde,R.raw.ehsan)
private var currentSongName =
mutableListOf("Arjan Vailly(From Animal)", "Bekhayali(From Kabir Singh)","Sajde(From Kill-Dil)","Ehsan tera hoga (From Sanam)")
private var songCard = mutableListOf(R.drawable.arjan, R.drawable.bekhali,R.drawable.sajdecard,R.drawable.ehsancard)
private var noc = 0
private var ps = 0;
private var currentSongindex = 0
private lateinit var btn_like: ImageView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

play= findViewById(R.id.imageView5)
pause= findViewById(R.id.imageView4)
play = findViewById(R.id.playpause)
card = findViewById(R.id.card)
prev = findViewById(R.id.pre)
next = findViewById(R.id.imageView4)
seekbar = findViewById(R.id.progress)
songTitle = findViewById(R.id.songTitle)
btn_like = findViewById(R.id.btn_like)

btn_like.setOnClickListener(View.OnClickListener {
change()
})

controlSound(currentSong[0])
next.setOnClickListener(View.OnClickListener { next() })
prev.setOnClickListener(View.OnClickListener { prev() })
}

private fun controlSound(id: Int){

private fun controlSound(id: Int) {
play.setOnClickListener {
if(mp==null){
mp=MediaPlayer.create(this,id)
Log.d("MainActivity","ID: ${mp!!.audioSessionId}")
initialiseSeekbar()
if (ps++ % 2 == 0) {
play.setImageResource(R.drawable.finalp)
if (mp == null) {
mp = MediaPlayer.create(this, id)
Log.d("MainActivity", "ID: ${mp!!.audioSessionId}")
initialiseSeekbar()
}
mp?.start()
Log.d("MainActivity", "ID: ${mp!!.duration / 1000} seconds")
} else {
play.setImageResource(R.drawable.pause)
if (mp != null) mp?.pause()
Log.d("MainActivity", "ID: ${mp!!.currentPosition / 1000} seconds")
}
mp?.start()
Log.d("MainActivity","ID: ${mp!!.duration/1000} seconds")
}
pause.setOnClickListener {
if(mp!=null) mp?.pause()
Log.d("MainActivity","ID: ${mp!!.currentPosition/1000} seconds")

}

}

private fun initialiseSeekbar(){
private fun initialiseSeekbar() {
seekbar.max = mp!!.duration

val handler = android.os.Handler()
handler.postDelayed(object :Runnable{
override fun run(){
handler.postDelayed(object : Runnable {
override fun run() {
try {
seekbar.progress = mp!!.currentPosition
handler.postDelayed(this,1000)
}
catch (e:Exception){
handler.postDelayed(this, 1000)
} catch (e: Exception) {
seekbar.progress = 0
}
}
},1000)
}, 1000)
}

fun change() {
if (noc % 2 == 0) {
btn_like.setImageResource(R.drawable.heart)
} else
btn_like.setImageResource(R.drawable.heartwhitecom)
noc++;
}

fun next() {
if (currentSongindex < currentSong.size - 1) {
ps=0
play.setImageResource(R.drawable.pause)
currentSongindex++
songTitle.setText(currentSongName[currentSongindex])
mp?.reset()
mp=null

controlSound(currentSong[currentSongindex])

card.setImageResource(songCard[currentSongindex])




}
else
{
Toast.makeText(this, "No more songs", Toast.LENGTH_SHORT).show()
}

}

fun prev() {
if (currentSongindex > 0) {
ps = 0
currentSongindex--
play.setImageResource(R.drawable.pause)
songTitle.setText(currentSongName[currentSongindex])
mp?.reset()
mp = null
controlSound(currentSong[currentSongindex])
card.setImageResource(songCard[currentSongindex])

}
else
{
Toast.makeText(this, "No more songs", Toast.LENGTH_SHORT).show()
}
}
}
}
32 changes: 32 additions & 0 deletions app/src/main/java/com/example/arjan/splash.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.arjan

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.view.animation.AnimationUtils
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity


class splash : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_splash)

val imageView = findViewById<ImageView>(R.id.logo)

// Load the fade animation
val fadeAnimation = AnimationUtils.loadAnimation(this, R.anim.fade)

// Apply the animation to the image view
imageView.startAnimation(fadeAnimation)

Handler().postDelayed(Runnable {

val i = Intent(this@splash, MainActivity::class.java)
startActivity(i)
}, 2000)
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/anim/fade.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- fade_animation.xml -->
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="4000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
Binary file added app/src/main/res/drawable/bekhali.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ehsancard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/heartwhitecom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1000dp"
android:height="1000dp"
android:viewportWidth="29"
android:viewportHeight="29">
<path
android:pathData="M15.7,4C18.87,4 21,6.98 21,9.76C21,15.39 12.16,20 12,20C11.84,20 3,15.39 3,9.76C3,6.98 5.13,4 8.3,4C10.12,4 11.31,4.91 12,5.71C12.69,4.91 13.88,4 15.7,4Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
Binary file added app/src/main/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/sajdecard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@


<ImageView
android:id="@+id/imageView"
android:id="@+id/card"
android:layout_width="250dp"
android:layout_height="300dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.237"
app:srcCompat="@drawable/dummy" />
app:srcCompat="@drawable/arjan" />

<TextView
android:id="@+id/textView"
android:id="@+id/songTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Arjan Vailly (From Animal)"
android:textColor="@color/white"
android:textColor="@color/black"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/imageView" />
app:layout_constraintTop_toBottomOf="@id/card" />

<TextView
android:id="@+id/singer"
Expand All @@ -55,18 +55,18 @@
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView" />
app:layout_constraintTop_toBottomOf="@id/songTitle" />

<ImageView
android:id="@+id/imageView2"
android:id="@+id/btn_like"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="@id/singer"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView"
app:layout_constraintTop_toBottomOf="@id/songTitle"
app:srcCompat="@drawable/heart" />

<SeekBar
Expand Down Expand Up @@ -116,7 +116,7 @@
/>

<ImageView
android:id="@+id/imageView3"
android:id="@+id/pre"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="50dp"
Expand All @@ -136,13 +136,13 @@
app:srcCompat="@android:drawable/ic_media_next" />

<ImageView
android:id="@+id/imageView5"
android:id="@+id/playpause"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="50dp"
android:src="@drawable/finalp"
android:src="@drawable/pause"
app:layout_constraintEnd_toEndOf="@id/imageView4"
app:layout_constraintStart_toStartOf="@id/imageView3"
app:layout_constraintStart_toStartOf="@id/pre"
app:layout_constraintTop_toBottomOf="@id/progress" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".splash">

<ImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/logo" />
</LinearLayout>
Binary file added app/src/main/res/raw/bekhayalii.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/ehsan.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/sajde.mp3
Binary file not shown.
Loading