-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added prev and next buttons to player controls using custom layout (n…
…eeds work); added a lite flavour
- Loading branch information
1 parent
b2ada44
commit 17794ee
Showing
10 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Recording Studio</string> | ||
<string name="app_name_short">Rec Studio</string> | ||
</resources> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Recording Studio Lite</string> | ||
<string name="app_name_short">Rec Studio Lite</string> | ||
</resources> |
2 changes: 1 addition & 1 deletion
2
..._list/playback/PlaybackServiceLauncher.kt → .../data/playback/PlaybackServiceLauncher.kt
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
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
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
55 changes: 55 additions & 0 deletions
55
.../main/java/io/github/leonidius20/recorder/ui/recordings_list/playback/PlaybackControls.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.github.leonidius20.recorder.ui.recordings_list.playback | ||
|
||
import android.content.ComponentName | ||
import android.content.Context | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.media3.common.MediaItem | ||
import androidx.media3.common.MediaMetadata | ||
import androidx.media3.session.MediaController | ||
import androidx.media3.session.SessionToken | ||
import com.google.common.util.concurrent.ListenableFuture | ||
import com.google.common.util.concurrent.MoreExecutors | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import io.github.leonidius20.recorder.data.playback.PlaybackService | ||
import io.github.leonidius20.recorder.ui.recordings_list.RecordingsListFragment | ||
|
||
/*class PlaybackControls( | ||
@ApplicationContext private val context: Context, | ||
): DefaultLifecycleObserver { | ||
private var mediaController: MediaController? = null | ||
private var controllerFuture: ListenableFuture<MediaController>? = null | ||
override fun onStart(owner: LifecycleOwner) { | ||
super.onStart(owner) | ||
val sessionToken = SessionToken(context, ComponentName(context, PlaybackService::class.java)) | ||
val factory = MediaController.Builder(context, sessionToken).buildAsync() | ||
controllerFuture = factory | ||
factory.addListener( { | ||
mediaController = factory?.let { | ||
if (it.isDone) | ||
it.get() | ||
else | ||
null | ||
} | ||
(owner as RecordingsListFragment).attachPlayerToView(mediaController!!) | ||
viewModel.recordings.value!!.forEach { recording -> | ||
mediaController?.addMediaItem( | ||
MediaItem.Builder().setUri(recording.uri).setMediaMetadata( | ||
MediaMetadata.Builder().setDisplayTitle(recording.name).build() | ||
).build() | ||
) | ||
} | ||
mediaController?.prepare() | ||
}, MoreExecutors.directExecutor()) | ||
} | ||
}*/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="bottom" | ||
android:layoutDirection="ltr" | ||
android:background="@color/md_theme_secondaryContainer" | ||
android:orientation="vertical" | ||
tools:targetApi="28"> | ||
|
||
<!-- | ||
docs regarding the IDs used here: | ||
https://github.com/google/ExoPlayer/blob/release-v2/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java | ||
--> | ||
|
||
<LinearLayout | ||
|
||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:paddingTop="4dp" | ||
android:orientation="horizontal"> | ||
|
||
<ImageButton | ||
android:id="@id/exo_prev" | ||
style="@style/ExoMediaButton.Previous"/> | ||
|
||
<ImageButton android:id="@id/exo_play_pause" | ||
style="@style/ExoMediaButton.Play"/> | ||
|
||
<ImageButton | ||
android:id="@id/exo_next" | ||
style="@style/ExoMediaButton.Next"/> | ||
|
||
<!-- todo: slider for time --> | ||
|
||
|
||
|
||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@id/exo_position"/> | ||
|
||
<View | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@id/exo_progress_placeholder"/> | ||
|
||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@id/exo_duration"/> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
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