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

Feature: multi-track. #1

Open
wants to merge 8 commits into
base: release-qingmei2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
multi-track app initial.
  • Loading branch information
qingmei2 committed Jul 18, 2022
commit 0f3ca166ea6f06cccc7f7962d8f7b6b2b47e758b
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class SinglePartItemController(context: Context,
switchCallback: OnTrackSwitchChangedCallback) {
this.mDurationCallback = durationCallback
this.mSwitchChangedCallback = switchCallback

startTimer()
}

override fun setTrackOpen(isOpen: Boolean) {
Expand All @@ -74,7 +76,7 @@ class SinglePartItemController(context: Context,
}

override fun isTrackOpen(): Boolean {
return mExoPlayer.isPlaying
return isTrackOpen
}

override fun onSeek(@IntRange(from = 0, to = 100) progress: Int, byUser: Boolean) {
Expand Down Expand Up @@ -104,8 +106,10 @@ class SinglePartItemController(context: Context,
scheduleAtFixedRate(object : TimerTask() {
override fun run() {
mHandler.post {
val targetProgress = 100.0f * mExoPlayer.currentPosition / mExoPlayer.duration
mDurationCallback?.invoke(targetProgress)
if (mExoPlayer.isPlaying) {
val targetProgress = 100.0f * mExoPlayer.currentPosition / mExoPlayer.duration
mDurationCallback?.invoke(targetProgress)
}
}
}
}, 1000L, 1000L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class MultiTrackListViewHolder(view: View) : RecyclerView.ViewHolder(view) {
trackSwitch = view.findViewById(R.id.swt_track)
}

fun binds(pos: Int, trackItem: SongPartItem, controller: IPartItemController) {
fun binds(pos: Int, trackItem: SongPartItem,
controller: IPartItemController) {
val isTrackOpen = controller.isTrackOpen()
this.onTrackOpenChanged(isTrackOpen)

Expand All @@ -102,6 +103,8 @@ class MultiTrackListViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
trackSwitch.isChecked = isTrackOpen

seekbar.progress = 0
seekbar.max = 100
seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, byUser: Boolean) {
controller.onSeek(progress, byUser)
Expand Down