|
@@ -3,14 +3,15 @@ package top.kikt.ijkplayer
|
|
|
/// create 2019/3/7 by cai
|
|
/// create 2019/3/7 by cai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import android.graphics.Bitmap
|
|
|
import android.util.Base64
|
|
import android.util.Base64
|
|
|
-import android.view.TextureView
|
|
|
|
|
import io.flutter.plugin.common.MethodCall
|
|
import io.flutter.plugin.common.MethodCall
|
|
|
import io.flutter.plugin.common.MethodChannel
|
|
import io.flutter.plugin.common.MethodChannel
|
|
|
import io.flutter.plugin.common.PluginRegistry
|
|
import io.flutter.plugin.common.PluginRegistry
|
|
|
import top.kikt.ijkplayer.entity.Info
|
|
import top.kikt.ijkplayer.entity.Info
|
|
|
import tv.danmaku.ijk.media.player.IjkMediaPlayer
|
|
import tv.danmaku.ijk.media.player.IjkMediaPlayer
|
|
|
import tv.danmaku.ijk.media.player.TextureMediaPlayer
|
|
import tv.danmaku.ijk.media.player.TextureMediaPlayer
|
|
|
|
|
+import java.io.ByteArrayOutputStream
|
|
|
import java.io.File
|
|
import java.io.File
|
|
|
|
|
|
|
|
class Ijk(private val registry: PluginRegistry.Registrar) : MethodChannel.MethodCallHandler {
|
|
class Ijk(private val registry: PluginRegistry.Registrar) : MethodChannel.MethodCallHandler {
|
|
@@ -112,12 +113,11 @@ class Ijk(private val registry: PluginRegistry.Registrar) : MethodChannel.Method
|
|
|
result?.success(true)
|
|
result?.success(true)
|
|
|
}
|
|
}
|
|
|
"getVolume" -> {
|
|
"getVolume" -> {
|
|
|
-
|
|
|
|
|
// result?.success(this.mediaPlayer.setVolume())
|
|
// result?.success(this.mediaPlayer.setVolume())
|
|
|
}
|
|
}
|
|
|
"screenShot" -> {
|
|
"screenShot" -> {
|
|
|
- screenShot()
|
|
|
|
|
- result?.success(byteArrayOf())
|
|
|
|
|
|
|
+ val bytes = screenShot()
|
|
|
|
|
+ result?.success(bytes)
|
|
|
}
|
|
}
|
|
|
else -> {
|
|
else -> {
|
|
|
result?.notImplemented()
|
|
result?.notImplemented()
|
|
@@ -125,11 +125,16 @@ class Ijk(private val registry: PluginRegistry.Registrar) : MethodChannel.Method
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun screenShot() {
|
|
|
|
|
- val textureView = TextureView(registry.activity())
|
|
|
|
|
- textureView.surfaceTexture = textureEntry.surfaceTexture()
|
|
|
|
|
- val bitmap = textureView.bitmap
|
|
|
|
|
- logi("bitmap width = ${bitmap?.width} height = ${bitmap?.height}")
|
|
|
|
|
|
|
+ private fun screenShot(): ByteArray? {
|
|
|
|
|
+ val frameBitmap = mediaPlayer.frameBitmap
|
|
|
|
|
+ return if (frameBitmap != null) {
|
|
|
|
|
+ val outputStream = ByteArrayOutputStream()
|
|
|
|
|
+ frameBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
|
|
|
|
|
+ frameBitmap.recycle()
|
|
|
|
|
+ outputStream.toByteArray()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ null
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fun getInfo(): Info {
|
|
fun getInfo(): Info {
|