diff --git a/app/src/main/java/gallery/memories/MainActivity.kt b/app/src/main/java/gallery/memories/MainActivity.kt index 2bf9d853..7a732c8d 100644 --- a/app/src/main/java/gallery/memories/MainActivity.kt +++ b/app/src/main/java/gallery/memories/MainActivity.kt @@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity() { private var player: ExoPlayer? = null private var playerUris: Array? = null - private var playerUid: String? = null + private var playerUid: Long? = null private var playWhenReady = true private var mediaItemIndex = 0 private var playbackPosition = 0L @@ -199,9 +199,9 @@ class MainActivity : AppCompatActivity() { return false } - fun initializePlayer(uris: Array, uid: String) { + fun initializePlayer(uris: Array, uid: Long) { if (player != null) { - if (playerUid.equals(uid)) return + if (playerUid == uid) return player?.release() player = null } @@ -265,8 +265,8 @@ class MainActivity : AppCompatActivity() { } } - fun destroyPlayer(uid: String) { - if (playerUid.equals(uid)) { + fun destroyPlayer(uid: Long) { + if (playerUid == uid) { releasePlayer() // Reset vars diff --git a/app/src/main/java/gallery/memories/NativeX.kt b/app/src/main/java/gallery/memories/NativeX.kt index 21f2634b..dcbe416a 100644 --- a/app/src/main/java/gallery/memories/NativeX.kt +++ b/app/src/main/java/gallery/memories/NativeX.kt @@ -118,9 +118,7 @@ class NativeX(private val mCtx: MainActivity) { } @JavascriptInterface - fun playVideo(auid: String?, fileid: String?, urlsArray: String?) { - if (auid == null || fileid == null || urlsArray == null) return - + fun playVideo(auid: Long, fileid: Long, urlsArray: String) { mCtx.threadPool.submit { // Get URI of remote videos val urls = JSONArray(urlsArray) @@ -129,7 +127,7 @@ class NativeX(private val mCtx: MainActivity) { } // Get URI of local video - val videos = query.getSystemImagesByAUIDs(arrayListOf(auid.toLong())) + val videos = query.getSystemImagesByAUIDs(arrayListOf(auid)) // Play with exoplayer mCtx.runOnUiThread { @@ -143,8 +141,7 @@ class NativeX(private val mCtx: MainActivity) { } @JavascriptInterface - fun destroyVideo(fileid: String?) { - if (fileid == null) return; + fun destroyVideo(fileid: Long) { mCtx.runOnUiThread { mCtx.destroyPlayer(fileid) }