Pass numbers in JS interface
parent
4928eef556
commit
0705924227
|
@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private var player: ExoPlayer? = null
|
private var player: ExoPlayer? = null
|
||||||
private var playerUris: Array<Uri>? = null
|
private var playerUris: Array<Uri>? = null
|
||||||
private var playerUid: String? = null
|
private var playerUid: Long? = null
|
||||||
private var playWhenReady = true
|
private var playWhenReady = true
|
||||||
private var mediaItemIndex = 0
|
private var mediaItemIndex = 0
|
||||||
private var playbackPosition = 0L
|
private var playbackPosition = 0L
|
||||||
|
@ -199,9 +199,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initializePlayer(uris: Array<Uri>, uid: String) {
|
fun initializePlayer(uris: Array<Uri>, uid: Long) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (playerUid.equals(uid)) return
|
if (playerUid == uid) return
|
||||||
player?.release()
|
player?.release()
|
||||||
player = null
|
player = null
|
||||||
}
|
}
|
||||||
|
@ -265,8 +265,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroyPlayer(uid: String) {
|
fun destroyPlayer(uid: Long) {
|
||||||
if (playerUid.equals(uid)) {
|
if (playerUid == uid) {
|
||||||
releasePlayer()
|
releasePlayer()
|
||||||
|
|
||||||
// Reset vars
|
// Reset vars
|
||||||
|
|
|
@ -118,9 +118,7 @@ class NativeX(private val mCtx: MainActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun playVideo(auid: String?, fileid: String?, urlsArray: String?) {
|
fun playVideo(auid: Long, fileid: Long, urlsArray: String) {
|
||||||
if (auid == null || fileid == null || urlsArray == null) return
|
|
||||||
|
|
||||||
mCtx.threadPool.submit {
|
mCtx.threadPool.submit {
|
||||||
// Get URI of remote videos
|
// Get URI of remote videos
|
||||||
val urls = JSONArray(urlsArray)
|
val urls = JSONArray(urlsArray)
|
||||||
|
@ -129,7 +127,7 @@ class NativeX(private val mCtx: MainActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get URI of local video
|
// Get URI of local video
|
||||||
val videos = query.getSystemImagesByAUIDs(arrayListOf(auid.toLong()))
|
val videos = query.getSystemImagesByAUIDs(arrayListOf(auid))
|
||||||
|
|
||||||
// Play with exoplayer
|
// Play with exoplayer
|
||||||
mCtx.runOnUiThread {
|
mCtx.runOnUiThread {
|
||||||
|
@ -143,8 +141,7 @@ class NativeX(private val mCtx: MainActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun destroyVideo(fileid: String?) {
|
fun destroyVideo(fileid: Long) {
|
||||||
if (fileid == null) return;
|
|
||||||
mCtx.runOnUiThread {
|
mCtx.runOnUiThread {
|
||||||
mCtx.destroyPlayer(fileid)
|
mCtx.destroyPlayer(fileid)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue