Commit d5c90cb5 authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

SDK update & video playback


Former-commit-id: 9b939aa9528d49fde57d7a8f8895694278f96ac3
parent 9e86ee26
package org.lindoor.ui.player
import android.graphics.SurfaceTexture
import android.os.Bundle
import android.os.SystemClock
import android.view.TextureView
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
......@@ -14,6 +16,8 @@ import org.lindoor.R
import org.lindoor.databinding.ActivityPlayerBinding
import org.lindoor.linphonecore.extensions.historyEvent
import org.linphone.core.AudioDevice
import org.linphone.core.Player
import org.linphone.core.tools.Log
class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
......@@ -49,29 +53,33 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
}
}
LindoorApplication.coreContext.core.createLocalPlayer(
speakerCard ?: earpieceCard,
"MSAndroidTextureDisplay",
if (event.hasVideo) binding.root.video.surfaceTexture else null
)?.also { player ->
playerViewModel =
ViewModelProvider(
this,
PlayerViewModelFactory(callId, player)
)[PlayerViewModel::class.java]
binding.model = playerViewModel
binding.root.cancel.setOnClickListener {
binding.root.cancel.alpha = 0.3f
finish()
LindoorApplication.coreContext.core.createLocalPlayer(
speakerCard ?: earpieceCard,
null,
null
)?.also { player ->
playerViewModel =
ViewModelProvider(
this@PlayerActivity,
PlayerViewModelFactory(callId, player)
)[PlayerViewModel::class.java]
binding.model = playerViewModel
binding.root.cancel.setOnClickListener {
binding.root.cancel.alpha = 0.3f
finish()
}
setupPlayerControl(binding.root, playerViewModel)
if (event.hasVideo) {
setTextureView(binding.root.video,player)
}
}
setupPlayerControl(binding.root, playerViewModel)
}
}
} ?: run {
this.finish()
}
}
private fun setupPlayerControl(view: View, model: PlayerViewModel) {
model.playing.observe(this, Observer { playing ->
if (playing) {
......@@ -92,4 +100,34 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
}
fun setTextureView(textureView: TextureView, player: Player) {
Log.i("[Player] Is TextureView available? ${textureView.isAvailable}")
if (textureView.isAvailable) {
player.setWindowId(textureView.surfaceTexture)
} else {
textureView.surfaceTextureListener = object : TextureView.SurfaceTextureListener {
override fun onSurfaceTextureSizeChanged(
surface: SurfaceTexture?,
width: Int,
height: Int
) { }
override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) { }
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?): Boolean {
return true
}
override fun onSurfaceTextureAvailable(
surface: SurfaceTexture?,
width: Int,
height: Int
) {
Log.i("[Player] Surface texture should be available now")
player.setWindowId(textureView.surfaceTexture)
}
}
}
}
}
\ No newline at end of file
buildscript {
ext.kotlin_version = '1.3.72'
ext.linphone_sdk_version = '4.5.0-alpha.47+db7ac3c'
ext.linphone_sdk_version = '4.5.0-alpha.47+cca1c46'
repositories {
google()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment