Pass numbers in JS interface
parent
4928eef556
commit
0705924227
|
@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private var player: ExoPlayer? = null
|
||||
private var playerUris: Array<Uri>? = 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<Uri>, uid: String) {
|
||||
fun initializePlayer(uris: Array<Uri>, 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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue