diff --git a/app/schemas/com.fongmi.android.tv.db.AppDatabase/32.json b/app/schemas/com.fongmi.android.tv.db.AppDatabase/32.json deleted file mode 100644 index 0df524c53..000000000 --- a/app/schemas/com.fongmi.android.tv.db.AppDatabase/32.json +++ /dev/null @@ -1,451 +0,0 @@ -{ - "formatVersion": 1, - "database": { - "version": 32, - "identityHash": "23710113f88894310d2acbc92c9e5ef1", - "entities": [ - { - "tableName": "Keep", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `siteName` TEXT, `vodName` TEXT, `vodPic` TEXT, `createTime` INTEGER NOT NULL, `type` INTEGER NOT NULL, `cid` INTEGER NOT NULL, PRIMARY KEY(`key`))", - "fields": [ - { - "fieldPath": "key", - "columnName": "key", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "siteName", - "columnName": "siteName", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "vodName", - "columnName": "vodName", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "vodPic", - "columnName": "vodPic", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "createTime", - "columnName": "createTime", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "type", - "columnName": "type", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "cid", - "columnName": "cid", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": false, - "columnNames": [ - "key" - ] - }, - "indices": [], - "foreignKeys": [] - }, - { - "tableName": "Site", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `searchable` INTEGER, `changeable` INTEGER, PRIMARY KEY(`key`))", - "fields": [ - { - "fieldPath": "key", - "columnName": "key", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "searchable", - "columnName": "searchable", - "affinity": "INTEGER", - "notNull": false - }, - { - "fieldPath": "changeable", - "columnName": "changeable", - "affinity": "INTEGER", - "notNull": false - } - ], - "primaryKey": { - "autoGenerate": false, - "columnNames": [ - "key" - ] - }, - "indices": [], - "foreignKeys": [] - }, - { - "tableName": "Live", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `boot` INTEGER NOT NULL, `pass` INTEGER NOT NULL, PRIMARY KEY(`name`))", - "fields": [ - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "boot", - "columnName": "boot", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "pass", - "columnName": "pass", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": false, - "columnNames": [ - "name" - ] - }, - "indices": [], - "foreignKeys": [] - }, - { - "tableName": "Track", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `group` INTEGER NOT NULL, `track` INTEGER NOT NULL, `key` TEXT, `name` TEXT, `selected` INTEGER NOT NULL, `adaptive` INTEGER NOT NULL)", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "type", - "columnName": "type", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "group", - "columnName": "group", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "track", - "columnName": "track", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "key", - "columnName": "key", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "selected", - "columnName": "selected", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "adaptive", - "columnName": "adaptive", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": true, - "columnNames": [ - "id" - ] - }, - "indices": [ - { - "name": "index_Track_key_type", - "unique": true, - "columnNames": [ - "key", - "type" - ], - "orders": [], - "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Track_key_type` ON `${TABLE_NAME}` (`key`, `type`)" - } - ], - "foreignKeys": [] - }, - { - "tableName": "Config", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `time` INTEGER NOT NULL, `url` TEXT, `json` TEXT, `name` TEXT, `logo` TEXT, `home` TEXT, `parse` TEXT)", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "type", - "columnName": "type", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "time", - "columnName": "time", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "url", - "columnName": "url", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "json", - "columnName": "json", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "logo", - "columnName": "logo", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "home", - "columnName": "home", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "parse", - "columnName": "parse", - "affinity": "TEXT", - "notNull": false - } - ], - "primaryKey": { - "autoGenerate": true, - "columnNames": [ - "id" - ] - }, - "indices": [ - { - "name": "index_Config_url_type", - "unique": true, - "columnNames": [ - "url", - "type" - ], - "orders": [], - "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Config_url_type` ON `${TABLE_NAME}` (`url`, `type`)" - } - ], - "foreignKeys": [] - }, - { - "tableName": "Device", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uuid` TEXT, `name` TEXT, `ip` TEXT, `type` INTEGER NOT NULL)", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": false - }, - { - "fieldPath": "uuid", - "columnName": "uuid", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "ip", - "columnName": "ip", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "type", - "columnName": "type", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": true, - "columnNames": [ - "id" - ] - }, - "indices": [ - { - "name": "index_Device_uuid_name", - "unique": true, - "columnNames": [ - "uuid", - "name" - ], - "orders": [], - "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Device_uuid_name` ON `${TABLE_NAME}` (`uuid`, `name`)" - } - ], - "foreignKeys": [] - }, - { - "tableName": "History", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `vodPic` TEXT, `vodName` TEXT, `vodFlag` TEXT, `vodRemarks` TEXT, `episodeUrl` TEXT, `revSort` INTEGER NOT NULL, `revPlay` INTEGER NOT NULL, `createTime` INTEGER NOT NULL, `opening` INTEGER NOT NULL, `ending` INTEGER NOT NULL, `position` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `speed` REAL NOT NULL, `scale` INTEGER NOT NULL, `cid` INTEGER NOT NULL, PRIMARY KEY(`key`))", - "fields": [ - { - "fieldPath": "key", - "columnName": "key", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "vodPic", - "columnName": "vodPic", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "vodName", - "columnName": "vodName", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "vodFlag", - "columnName": "vodFlag", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "vodRemarks", - "columnName": "vodRemarks", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "episodeUrl", - "columnName": "episodeUrl", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "revSort", - "columnName": "revSort", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "revPlay", - "columnName": "revPlay", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "createTime", - "columnName": "createTime", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "opening", - "columnName": "opening", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "ending", - "columnName": "ending", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "position", - "columnName": "position", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "duration", - "columnName": "duration", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "speed", - "columnName": "speed", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "scale", - "columnName": "scale", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "cid", - "columnName": "cid", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": false, - "columnNames": [ - "key" - ] - }, - "indices": [], - "foreignKeys": [] - } - ], - "views": [], - "setupQueries": [ - "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '23710113f88894310d2acbc92c9e5ef1')" - ] - } -} \ No newline at end of file diff --git a/app/schemas/com.fongmi.android.tv.db.AppDatabase/33.json b/app/schemas/com.fongmi.android.tv.db.AppDatabase/34.json similarity index 83% rename from app/schemas/com.fongmi.android.tv.db.AppDatabase/33.json rename to app/schemas/com.fongmi.android.tv.db.AppDatabase/34.json index 327097f38..8bc3b819a 100644 --- a/app/schemas/com.fongmi.android.tv.db.AppDatabase/33.json +++ b/app/schemas/com.fongmi.android.tv.db.AppDatabase/34.json @@ -1,8 +1,8 @@ { "formatVersion": 1, "database": { - "version": 33, - "identityHash": "52e51ac2d24c028878314c9ba50e8008", + "version": 34, + "identityHash": "f6dff07c7842200b0224662b90261e07", "entities": [ { "tableName": "Keep", @@ -17,20 +17,17 @@ { "fieldPath": "siteName", "columnName": "siteName", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "vodName", "columnName": "vodName", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "vodPic", "columnName": "vodPic", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "createTime", @@ -56,9 +53,7 @@ "columnNames": [ "key" ] - }, - "indices": [], - "foreignKeys": [] + } }, { "tableName": "Site", @@ -73,14 +68,12 @@ { "fieldPath": "searchable", "columnName": "searchable", - "affinity": "INTEGER", - "notNull": false + "affinity": "INTEGER" }, { "fieldPath": "changeable", "columnName": "changeable", - "affinity": "INTEGER", - "notNull": false + "affinity": "INTEGER" } ], "primaryKey": { @@ -88,9 +81,7 @@ "columnNames": [ "key" ] - }, - "indices": [], - "foreignKeys": [] + } }, { "tableName": "Live", @@ -105,8 +96,7 @@ { "fieldPath": "keep", "columnName": "keep", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "boot", @@ -126,13 +116,11 @@ "columnNames": [ "name" ] - }, - "indices": [], - "foreignKeys": [] + } }, { "tableName": "Track", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `group` INTEGER NOT NULL, `track` INTEGER NOT NULL, `key` TEXT, `name` TEXT, `selected` INTEGER NOT NULL, `adaptive` INTEGER NOT NULL)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `group` INTEGER NOT NULL, `track` INTEGER NOT NULL, `key` TEXT, `name` TEXT, `selected` INTEGER NOT NULL)", "fields": [ { "fieldPath": "id", @@ -161,26 +149,18 @@ { "fieldPath": "key", "columnName": "key", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "name", "columnName": "name", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "selected", "columnName": "selected", "affinity": "INTEGER", "notNull": true - }, - { - "fieldPath": "adaptive", - "columnName": "adaptive", - "affinity": "INTEGER", - "notNull": true } ], "primaryKey": { @@ -200,8 +180,7 @@ "orders": [], "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Track_key_type` ON `${TABLE_NAME}` (`key`, `type`)" } - ], - "foreignKeys": [] + ] }, { "tableName": "Config", @@ -228,38 +207,32 @@ { "fieldPath": "url", "columnName": "url", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "json", "columnName": "json", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "name", "columnName": "name", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "logo", "columnName": "logo", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "home", "columnName": "home", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "parse", "columnName": "parse", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" } ], "primaryKey": { @@ -279,8 +252,7 @@ "orders": [], "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Config_url_type` ON `${TABLE_NAME}` (`url`, `type`)" } - ], - "foreignKeys": [] + ] }, { "tableName": "Device", @@ -289,26 +261,22 @@ { "fieldPath": "id", "columnName": "id", - "affinity": "INTEGER", - "notNull": false + "affinity": "INTEGER" }, { "fieldPath": "uuid", "columnName": "uuid", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "name", "columnName": "name", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "ip", "columnName": "ip", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "type", @@ -334,8 +302,7 @@ "orders": [], "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Device_uuid_name` ON `${TABLE_NAME}` (`uuid`, `name`)" } - ], - "foreignKeys": [] + ] }, { "tableName": "History", @@ -350,32 +317,27 @@ { "fieldPath": "vodPic", "columnName": "vodPic", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "vodName", "columnName": "vodName", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "vodFlag", "columnName": "vodFlag", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "vodRemarks", "columnName": "vodRemarks", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "episodeUrl", "columnName": "episodeUrl", - "affinity": "TEXT", - "notNull": false + "affinity": "TEXT" }, { "fieldPath": "revSort", @@ -443,15 +405,12 @@ "columnNames": [ "key" ] - }, - "indices": [], - "foreignKeys": [] + } } ], - "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '52e51ac2d24c028878314c9ba50e8008')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f6dff07c7842200b0224662b90261e07')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/fongmi/android/tv/bean/Track.java b/app/src/main/java/com/fongmi/android/tv/bean/Track.java index 9f65360d4..b80d2642f 100644 --- a/app/src/main/java/com/fongmi/android/tv/bean/Track.java +++ b/app/src/main/java/com/fongmi/android/tv/bean/Track.java @@ -23,7 +23,6 @@ public class Track { private String key; private String name; private boolean selected; - private boolean adaptive; public Track(int type, String name) { this.type = type; @@ -86,14 +85,6 @@ public class Track { this.selected = selected; } - public boolean isAdaptive() { - return adaptive; - } - - public void setAdaptive(boolean adaptive) { - this.adaptive = adaptive; - } - public Track key(String key) { setKey(key); return this; @@ -105,7 +96,7 @@ public class Track { } public Track save() { - if (TextUtils.isEmpty(getKey())) return this; + if (TextUtils.isEmpty(getKey()) || !isSelected()) return this; AppDatabase.get().getTrackDao().insert(this); return this; } diff --git a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java index a13de2514..6ad833c6a 100644 --- a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java +++ b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java @@ -35,7 +35,7 @@ import java.util.Locale; @Database(entities = {Keep.class, Site.class, Live.class, Track.class, Config.class, Device.class, History.class}, version = AppDatabase.VERSION) public abstract class AppDatabase extends RoomDatabase { - public static final int VERSION = 33; + public static final int VERSION = 34; public static final String NAME = "tv"; public static final String SYMBOL = "@@@"; @@ -94,7 +94,9 @@ public abstract class AppDatabase extends RoomDatabase { .addMigrations(Migrations.MIGRATION_30_31) .addMigrations(Migrations.MIGRATION_31_32) .addMigrations(Migrations.MIGRATION_32_33) - .allowMainThreadQueries().fallbackToDestructiveMigration().build(); + .addMigrations(Migrations.MIGRATION_33_34) + .fallbackToDestructiveMigration(true) + .allowMainThreadQueries().build(); } public abstract KeepDao getKeepDao(); diff --git a/app/src/main/java/com/fongmi/android/tv/db/Migrations.java b/app/src/main/java/com/fongmi/android/tv/db/Migrations.java index 855e34b91..97057ecb2 100644 --- a/app/src/main/java/com/fongmi/android/tv/db/Migrations.java +++ b/app/src/main/java/com/fongmi/android/tv/db/Migrations.java @@ -31,4 +31,13 @@ public class Migrations { database.execSQL("ALTER TABLE Live ADD COLUMN keep TEXT DEFAULT NULL"); } }; + + public static final Migration MIGRATION_33_34 = new Migration(33, 34) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("DROP TABLE Track"); + database.execSQL("CREATE TABLE Track (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `group` INTEGER NOT NULL, `track` INTEGER NOT NULL, `key` TEXT, `name` TEXT, `selected` INTEGER NOT NULL)"); + database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_Track_key_type` ON `Track` (`key`, `type`)"); + } + }; } diff --git a/app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java b/app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java index 010ec287d..5a89fe013 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java +++ b/app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java @@ -75,18 +75,6 @@ public class ExoUtil { return count > 0; } - public static void selectTrack(ExoPlayer player, int group, int track) { - List trackIndices = new ArrayList<>(); - selectTrack(player, group, track, trackIndices); - setTrackParameters(player, group, trackIndices); - } - - public static void deselectTrack(ExoPlayer player, int group, int track) { - List trackIndices = new ArrayList<>(); - deselectTrack(player, group, track, trackIndices); - setTrackParameters(player, group, trackIndices); - } - public static void resetTrack(ExoPlayer player) { player.setTrackSelectionParameters(player.getTrackSelectionParameters().buildUpon().clearOverrides().build()); } @@ -138,24 +126,22 @@ public class ExoUtil { return configs; } - private static void selectTrack(ExoPlayer player, int group, int track, List trackIndices) { - if (group >= player.getCurrentTracks().getGroups().size()) return; - Tracks.Group trackGroup = player.getCurrentTracks().getGroups().get(group); - for (int i = 0; i < trackGroup.length; i++) { - if (i == track || trackGroup.isTrackSelected(i)) trackIndices.add(i); - } - } - - private static void deselectTrack(ExoPlayer player, int group, int track, List trackIndices) { - if (group >= player.getCurrentTracks().getGroups().size()) return; - Tracks.Group trackGroup = player.getCurrentTracks().getGroups().get(group); - for (int i = 0; i < trackGroup.length; i++) { - if (i != track && trackGroup.isTrackSelected(i)) trackIndices.add(i); - } + public static void selectTrack(ExoPlayer player, int groupIndex, int trackIndex) { + Tracks currentTracks = player.getCurrentTracks(); + if (groupIndex >= currentTracks.getGroups().size()) return; + Tracks.Group trackGroupInfo = currentTracks.getGroups().get(groupIndex); + if (trackIndex < 0 || trackIndex >= trackGroupInfo.length) return; + TrackSelectionOverride override = new TrackSelectionOverride(trackGroupInfo.getMediaTrackGroup(), trackIndex); + player.setTrackSelectionParameters(player.getTrackSelectionParameters().buildUpon().setOverrideForType(override).build()); } - private static void setTrackParameters(ExoPlayer player, int group, List trackIndices) { - if (group >= player.getCurrentTracks().getGroups().size()) return; - player.setTrackSelectionParameters(player.getTrackSelectionParameters().buildUpon().setOverrideForType(new TrackSelectionOverride(player.getCurrentTracks().getGroups().get(group).getMediaTrackGroup(), trackIndices)).build()); + public static void deselectTrack(ExoPlayer player, int groupIndex, int trackIndex) { + Tracks currentTracks = player.getCurrentTracks(); + if (groupIndex >= currentTracks.getGroups().size()) return; + Tracks.Group trackGroupInfo = currentTracks.getGroups().get(groupIndex); + List trackIndices = new ArrayList<>(); + for (int i = 0; i < trackGroupInfo.length; i++) if (i != trackIndex && trackGroupInfo.isTrackSelected(i)) trackIndices.add(i); + TrackSelectionOverride override = new TrackSelectionOverride(trackGroupInfo.getMediaTrackGroup(), trackIndices); + player.setTrackSelectionParameters(player.getTrackSelectionParameters().buildUpon().setOverrideForType(override).build()); } } diff --git a/app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java b/app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java index 9142bba6d..9f3d71436 100644 --- a/app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java +++ b/app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java @@ -114,7 +114,6 @@ public final class TrackDialog extends BaseDialog implements TrackAdapter.OnClic if (trackGroup.getType() != type) continue; for (int j = 0; j < trackGroup.length; j++) { Track item = new Track(type, provider.getTrackName(trackGroup.getTrackFormat(j))); - item.setAdaptive(trackGroup.isAdaptiveSupported()); item.setSelected(trackGroup.isTrackSelected(j)); item.setGroup(i); item.setTrack(j); @@ -126,7 +125,6 @@ public final class TrackDialog extends BaseDialog implements TrackAdapter.OnClic @Override public void onItemClick(Track item) { player.setTrack(Arrays.asList(item.key(player.getKey()).save())); - if (item.isAdaptive()) return; dismiss(); }