add skipping forward/backward by 2% at pressing the song progress text
This commit is contained in:
parent
b4e8a5a3a2
commit
38ba519c43
5 changed files with 26 additions and 4 deletions
|
@ -115,6 +115,8 @@
|
|||
<action android:name="com.simplemobiletools.musicplayer.action.PLAYPOS"/>
|
||||
<action android:name="com.simplemobiletools.musicplayer.action.REFRESH_LIST"/>
|
||||
<action android:name="com.simplemobiletools.musicplayer.action.SET_PROGRESS"/>
|
||||
<action android:name="com.simplemobiletools.musicplayer.action.SKIP_BACKWARD"/>
|
||||
<action android:name="com.simplemobiletools.musicplayer.action.SKIP_FORWARD"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ class MainActivity : SimpleActivity(), SongListListener {
|
|||
play_pause_btn.setOnClickListener { sendIntent(PLAYPAUSE) }
|
||||
next_btn.setOnClickListener { sendIntent(NEXT) }
|
||||
repeat_btn.setOnClickListener { toggleSongRepetition() }
|
||||
song_progress_current.setOnClickListener { }
|
||||
song_progress_max.setOnClickListener { }
|
||||
song_progress_current.setOnClickListener { sendIntent(SKIP_BACKWARD) }
|
||||
song_progress_max.setOnClickListener { sendIntent(SKIP_FORWARD) }
|
||||
|
||||
songs_playlist_empty_add_folder.setOnClickListener { addFolderToPlaylist() }
|
||||
volumeControlStream = AudioManager.STREAM_MUSIC
|
||||
|
|
|
@ -285,8 +285,8 @@ class SongAdapter(activity: SimpleActivity, var songs: ArrayList<Song>, val list
|
|||
play_pause_btn.setOnClickListener { activity.sendIntent(PLAYPAUSE) }
|
||||
next_btn.setOnClickListener { activity.sendIntent(NEXT) }
|
||||
repeat_btn.setOnClickListener { listener.listToggleSongRepetition() }
|
||||
song_progress_current.setOnClickListener { }
|
||||
song_progress_max.setOnClickListener { }
|
||||
song_progress_current.setOnClickListener { activity.sendIntent(SKIP_BACKWARD) }
|
||||
song_progress_max.setOnClickListener { activity.sendIntent(SKIP_FORWARD) }
|
||||
|
||||
previous_btn.applyColorFilter(textColor)
|
||||
play_pause_btn.applyColorFilter(textColor)
|
||||
|
|
|
@ -19,6 +19,8 @@ const val PLAYPOS = PATH + "PLAYPOS"
|
|||
const val REFRESH_LIST = PATH + "REFRESH_LIST"
|
||||
const val SET_PROGRESS = PATH + "SET_PROGRESS"
|
||||
const val SET_EQUALIZER = PATH + "SET_EQUALIZER"
|
||||
const val SKIP_BACKWARD = PATH + "SKIP_BACKWARD"
|
||||
const val SKIP_FORWARD = PATH + "SKIP_FORWARD"
|
||||
|
||||
// shared preferences
|
||||
const val SHUFFLE = "shuffle"
|
||||
|
|
|
@ -177,6 +177,8 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
}
|
||||
}
|
||||
}
|
||||
SKIP_BACKWARD -> skipBackward()
|
||||
SKIP_FORWARD -> skipForward()
|
||||
}
|
||||
|
||||
return START_NOT_STICKY
|
||||
|
@ -636,4 +638,20 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
mProgressHandler!!.removeCallbacksAndMessages(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun skipBackward() {
|
||||
skip(false)
|
||||
}
|
||||
|
||||
private fun skipForward() {
|
||||
skip(true)
|
||||
}
|
||||
|
||||
private fun skip(forward: Boolean) {
|
||||
val curr = mPlayer!!.currentPosition
|
||||
val twoPercents = mPlayer!!.duration / 50
|
||||
val newProgress = if (forward) curr + twoPercents else curr - twoPercents
|
||||
mPlayer!!.seekTo(newProgress)
|
||||
resumeSong()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue