Saved the playback position when the player is paused

This commit is contained in:
CappielloAntonio 2022-01-02 17:43:30 +01:00
parent e4d09f3bc0
commit 40866a2855
7 changed files with 101 additions and 13 deletions

View file

@ -3,6 +3,7 @@ package com.cappielloantonio.play.database;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.room.AutoMigration;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
@ -20,9 +21,9 @@ import com.cappielloantonio.play.model.Server;
@SuppressLint("RestrictedApi")
@Database(
version = 29,
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class}
// autoMigrations = { @AutoMigration(from = 23, to = 24) }
version = 30,
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class},
autoMigrations = { @AutoMigration(from = 29, to = 30) }
)
public abstract class AppDatabase extends RoomDatabase {
private static final String TAG = "AppDatabase";

View file

@ -37,6 +37,12 @@ public interface QueueDao {
@Query("UPDATE queue SET last_play=:timestamp WHERE id=:id")
void setLastPlay(String id, long timestamp);
@Query("UPDATE queue SET playing_changed=:timestamp WHERE id=:id")
void setPlayingChanged(String id, long timestamp);
@Query("SELECT track_order FROM queue ORDER BY last_play DESC LIMIT 1")
int getLastPlay();
@Query("SELECT playing_changed FROM queue ORDER BY last_play DESC LIMIT 1")
long getLastPlayedTimestamp();
}