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 package org.lindoor.ui.player
import android.graphics.SurfaceTexture
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.view.TextureView
import android.view.View import android.view.View
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
...@@ -14,6 +16,8 @@ import org.lindoor.R ...@@ -14,6 +16,8 @@ import org.lindoor.R
import org.lindoor.databinding.ActivityPlayerBinding import org.lindoor.databinding.ActivityPlayerBinding
import org.lindoor.linphonecore.extensions.historyEvent import org.lindoor.linphonecore.extensions.historyEvent
import org.linphone.core.AudioDevice import org.linphone.core.AudioDevice
import org.linphone.core.Player
import org.linphone.core.tools.Log
class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) { class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
...@@ -49,29 +53,33 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) { ...@@ -49,29 +53,33 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
} }
} }
LindoorApplication.coreContext.core.createLocalPlayer( LindoorApplication.coreContext.core.createLocalPlayer(
speakerCard ?: earpieceCard, speakerCard ?: earpieceCard,
"MSAndroidTextureDisplay", null,
if (event.hasVideo) binding.root.video.surfaceTexture else null null
)?.also { player -> )?.also { player ->
playerViewModel = playerViewModel =
ViewModelProvider( ViewModelProvider(
this, this@PlayerActivity,
PlayerViewModelFactory(callId, player) PlayerViewModelFactory(callId, player)
)[PlayerViewModel::class.java] )[PlayerViewModel::class.java]
binding.model = playerViewModel binding.model = playerViewModel
binding.root.cancel.setOnClickListener { binding.root.cancel.setOnClickListener {
binding.root.cancel.alpha = 0.3f binding.root.cancel.alpha = 0.3f
finish() finish()
}
setupPlayerControl(binding.root, playerViewModel)
if (event.hasVideo) {
setTextureView(binding.root.video,player)
}
} }
setupPlayerControl(binding.root, playerViewModel)
}
} }
} ?: run { } ?: run {
this.finish() this.finish()
} }
} }
private fun setupPlayerControl(view: View, model: PlayerViewModel) { private fun setupPlayerControl(view: View, model: PlayerViewModel) {
model.playing.observe(this, Observer { playing -> model.playing.observe(this, Observer { playing ->
if (playing) { if (playing) {
...@@ -92,4 +100,34 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) { ...@@ -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 { buildscript {
ext.kotlin_version = '1.3.72' 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 { repositories {
google() 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