import android.content.Context
import android.content.res.Resources
import android.graphics.Bitmap
import android.net.Uri
import android.view.View
import android.widget.MediaController
import android.widget.VideoView
import io.flutter.plugin.platform.PlatformView
internal class NativeView(context: Context, id: Int, creationParams: Map<String?, Any?>?) : PlatformView {
private val videoView: VideoView = VideoView(context)
private val mediaController: MediaController = MediaController(context)
override fun getView(): View {
return videoView
}
override fun dispose() {}
init {
mediaController.setAnchorView(videoView)
videoView.setMediaController(mediaController)
print(creationParams?.entries)
videoView.layoutParams.height= Resources.getSystem().displayMetrics.widthPixels
//displayMetrics.heightPixels
videoView.layoutParams.width=Resources.getSystem().displayMetrics.heightPixels
val offUri= Uri.parse("/storage/emulated/0/bee.mp4")
Bitmap.Config.ARGB_8888
videoView.setVideoPath(offUri.path)
videoView.requestFocus()
videoView.start()
// val u=Uri.parse("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4")
}
}
我正在将 kotlin 用于 videoView。但是我无法设置高度和宽度......,我需要将参数flutter传递给kotlin。但我不知道如何访问我的 kotlin 端。我需要执行手势识别。但我不知道如何实施。