-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(player): remember playback state
- Loading branch information
1 parent
27deffb
commit f430cce
Showing
8 changed files
with
119 additions
and
12 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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/live/mehiz/mpvkt/database/MpvKtDatabase.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,11 @@ | ||
package live.mehiz.mpvkt.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import live.mehiz.mpvkt.database.dao.PlaybackStateDao | ||
import live.mehiz.mpvkt.database.entities.PlaybackStateEntity | ||
|
||
@Database(entities = [PlaybackStateEntity::class], version = 1) | ||
abstract class MpvKtDatabase: RoomDatabase() { | ||
abstract fun videoDataDao(): PlaybackStateDao | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/live/mehiz/mpvkt/database/dao/PlaybackStateDao.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,15 @@ | ||
package live.mehiz.mpvkt.database.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import androidx.room.Upsert | ||
import live.mehiz.mpvkt.database.entities.PlaybackStateEntity | ||
|
||
@Dao | ||
interface PlaybackStateDao { | ||
@Upsert | ||
suspend fun upsert(playbackStateEntity: PlaybackStateEntity) | ||
|
||
@Query("SELECT * FROM PlaybackStateEntity WHERE mediaTitle = :mediaTitle LIMIT 1") | ||
suspend fun getVideoDataByTitle(mediaTitle: String): PlaybackStateEntity? | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/live/mehiz/mpvkt/database/entities/PlaybackStateEntity.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,13 @@ | ||
package live.mehiz.mpvkt.database.entities | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity | ||
data class PlaybackStateEntity( | ||
@PrimaryKey val mediaTitle: String, | ||
val lastPosition: Int, // in seconds | ||
val sid: Int, | ||
val secondarySid: Int, | ||
val aid: Int, | ||
) |
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,14 @@ | ||
package live.mehiz.mpvkt.di | ||
|
||
import androidx.room.Room | ||
import live.mehiz.mpvkt.database.MpvKtDatabase | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.dsl.module | ||
|
||
val DatabaseModule = module { | ||
single<MpvKtDatabase> { | ||
Room | ||
.databaseBuilder(androidContext(), MpvKtDatabase::class.java, "mpvKt.db") | ||
.build() | ||
} | ||
} |
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