fix another crash in PlayerActivity

This commit is contained in:
jmir1 2022-01-05 03:27:19 +01:00
parent 6dd72b3d12
commit cc457815c9
2 changed files with 1 additions and 80 deletions

View file

@ -1,79 +0,0 @@
package eu.kanade.tachiyomi.ui.player;
// Mapping between Android and mpv keycodes (special keys)
import android.util.SparseArray;
import static android.view.KeyEvent.*;
public class KeyMapping {
public static final SparseArray<String> map = new SparseArray<>();
static {
// cf. https://github.com/mpv-player/mpv/blob/master/input/keycodes.h
map.put(KEYCODE_SPACE, "SPACE");
map.put(KEYCODE_ENTER, "ENTER");
map.put(KEYCODE_TAB, "TAB");
map.put(KEYCODE_DEL, "BS");
map.put(KEYCODE_FORWARD_DEL, "DEL");
map.put(KEYCODE_INSERT, "INS");
map.put(KEYCODE_MOVE_HOME, "HOME");
map.put(KEYCODE_MOVE_END, "END");
map.put(KEYCODE_PAGE_UP, "PGUP");
map.put(KEYCODE_PAGE_DOWN, "PGDWN");
map.put(KEYCODE_ESCAPE, "ESC");
map.put(KEYCODE_SYSRQ, "PRINT");
map.put(KEYCODE_DPAD_RIGHT, "RIGHT");
map.put(KEYCODE_DPAD_LEFT, "LEFT");
map.put(KEYCODE_DPAD_DOWN, "DOWN");
map.put(KEYCODE_DPAD_UP, "UP");
// not bound, let the OS handle these:
//map.put(KEYCODE_POWER, "POWER");
//map.put(KEYCODE_MENU, "MENU");
//map.put(KEYCODE_VOLUME_UP, "VOLUME_UP");
//map.put(KEYCODE_VOLUME_DOWN, "VOLUME_DOWN");
//map.put(KEYCODE_VOLUME_MUTE, "MUTE");
//map.put(KEYCODE_HOME, "HOMEPAGE");
//map.put(KEYCODE_SLEEP, "SLEEP");
//map.put(KEYCODE_ENVELOPE, "MAIL");
//map.put(KEYCODE_SEARCH, "SEARCH");
map.put(KEYCODE_MEDIA_PLAY, "PLAYONLY");
map.put(KEYCODE_MEDIA_PAUSE, "PAUSEONLY");
map.put(KEYCODE_MEDIA_PLAY_PAUSE, "PLAYPAUSE");
map.put(KEYCODE_MEDIA_STOP, "STOP");
map.put(KEYCODE_MEDIA_FAST_FORWARD, "FORWARD");
map.put(KEYCODE_MEDIA_REWIND, "REWIND");
map.put(KEYCODE_MEDIA_NEXT, "NEXT");
map.put(KEYCODE_MEDIA_PREVIOUS, "PREV");
map.put(KEYCODE_MEDIA_RECORD, "RECORD");
map.put(KEYCODE_CHANNEL_UP, "CHANNEL_UP");
map.put(KEYCODE_CHANNEL_DOWN, "CHANNEL_DOWN");
map.put(KEYCODE_F1, "F1");
map.put(KEYCODE_F2, "F2");
map.put(KEYCODE_F3, "F3");
map.put(KEYCODE_F4, "F4");
map.put(KEYCODE_F5, "F5");
map.put(KEYCODE_F6, "F6");
map.put(KEYCODE_F7, "F7");
map.put(KEYCODE_F8, "F8");
map.put(KEYCODE_F9, "F9");
map.put(KEYCODE_F11, "F11");
map.put(KEYCODE_F12, "F12");
map.put(KEYCODE_NUMPAD_0, "KP0");
map.put(KEYCODE_NUMPAD_1, "KP1");
map.put(KEYCODE_NUMPAD_2, "KP2");
map.put(KEYCODE_NUMPAD_3, "KP3");
map.put(KEYCODE_NUMPAD_4, "KP4");
map.put(KEYCODE_NUMPAD_5, "KP5");
map.put(KEYCODE_NUMPAD_6, "KP6");
map.put(KEYCODE_NUMPAD_7, "KP7");
map.put(KEYCODE_NUMPAD_8, "KP8");
map.put(KEYCODE_NUMPAD_9, "KP9");
map.put(KEYCODE_NUMPAD_DOT, "KP_DEC");
map.put(KEYCODE_NUMPAD_ENTER, "KP_ENTER");
}
}

View file

@ -118,7 +118,6 @@ class PlayerActivity : AppCompatActivity() {
private lateinit var episode: Episode
private lateinit var anime: Anime
private lateinit var source: AnimeSource
private val defaultUserAgentString = WebSettings.getDefaultUserAgent(this)
private lateinit var uri: String
private var videos = emptyList<Video>()
private var isBuffering = true
@ -250,6 +249,7 @@ class PlayerActivity : AppCompatActivity() {
}
private fun newDataSourceFactory(): DefaultHttpDataSource.Factory {
val defaultUserAgentString = WebSettings.getDefaultUserAgent(baseContext)
return DefaultHttpDataSource.Factory().apply {
val currentHeaders = videos.getOrNull(currentQuality)?.headers
val headers = currentHeaders?.toMultimap()