全屏视频自定义
This commit is contained in:
@@ -9,6 +9,7 @@ import com.example.defenseapplication.databinding.ActivityStartBinding
|
|||||||
import com.example.defenseapplication.login.LoginActivity
|
import com.example.defenseapplication.login.LoginActivity
|
||||||
import com.example.defenseapplication.utils.ApiConfig
|
import com.example.defenseapplication.utils.ApiConfig
|
||||||
import com.example.defenseapplication.utils.UserinfoUtil
|
import com.example.defenseapplication.utils.UserinfoUtil
|
||||||
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
class StartActivity : AppCompatActivity() {
|
class StartActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityStartBinding
|
private lateinit var binding: ActivityStartBinding
|
||||||
@@ -17,6 +18,10 @@ class StartActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityStartBinding.inflate(layoutInflater)
|
binding = ActivityStartBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
ImmersionBar.with(this)
|
||||||
|
.statusBarDarkFont(true)
|
||||||
|
.titleBar(null)
|
||||||
|
.init()
|
||||||
|
|
||||||
// 延迟2秒后再判断登录状态
|
// 延迟2秒后再判断登录状态
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
|||||||
import com.bigkoo.pickerview.builder.TimePickerBuilder
|
import com.bigkoo.pickerview.builder.TimePickerBuilder
|
||||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener
|
import com.bigkoo.pickerview.listener.OnTimeSelectListener
|
||||||
import com.example.defenseapplication.view.MyGSYVideoPlayer
|
import com.example.defenseapplication.view.MyGSYVideoPlayer
|
||||||
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@@ -48,6 +49,10 @@ class AlarmLogActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = AlarmLogActivityBinding.inflate(layoutInflater)
|
binding = AlarmLogActivityBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
ImmersionBar.with(this)
|
||||||
|
.statusBarDarkFont(true)
|
||||||
|
.titleBar(null)
|
||||||
|
.init()
|
||||||
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
|
|
||||||
deviceId = intent.getStringExtra("device_id")
|
deviceId = intent.getStringExtra("device_id")
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package com.example.defenseapplication.view
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.example.defenseapplication.R
|
||||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||||
|
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
|
||||||
|
|
||||||
class MyGSYVideoPlayerLive @JvmOverloads constructor(
|
class MyGSYVideoPlayerLive @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null
|
context: Context, attrs: AttributeSet? = null
|
||||||
@@ -17,4 +20,66 @@ class MyGSYVideoPlayerLive @JvmOverloads constructor(
|
|||||||
override fun updateStartImage() {
|
override fun updateStartImage() {
|
||||||
startButton.visibility = View.GONE
|
startButton.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
override fun startWindowFullscreen(
|
||||||
|
context: Context?,
|
||||||
|
actionBar: Boolean,
|
||||||
|
statusBar: Boolean
|
||||||
|
): GSYBaseVideoPlayer {
|
||||||
|
|
||||||
|
val player = super.startWindowFullscreen(
|
||||||
|
context,
|
||||||
|
actionBar,
|
||||||
|
statusBar
|
||||||
|
) as MyGSYVideoPlayerLive
|
||||||
|
|
||||||
|
// 隐藏GSY自带UI
|
||||||
|
player.backButton.visibility = View.GONE
|
||||||
|
player.titleTextView.visibility = View.GONE
|
||||||
|
player.startButton.visibility = View.GONE
|
||||||
|
player.fullscreenButton.visibility = View.GONE
|
||||||
|
|
||||||
|
player.findViewById<View>(
|
||||||
|
com.shuyu.gsyvideoplayer.R.id.current
|
||||||
|
)?.visibility = View.GONE
|
||||||
|
|
||||||
|
player.findViewById<View>(
|
||||||
|
com.shuyu.gsyvideoplayer.R.id.total
|
||||||
|
)?.visibility = View.GONE
|
||||||
|
|
||||||
|
player.findViewById<View>(
|
||||||
|
com.shuyu.gsyvideoplayer.R.id.progress
|
||||||
|
)?.visibility = View.GONE
|
||||||
|
|
||||||
|
player.findViewById<View>(
|
||||||
|
com.shuyu.gsyvideoplayer.R.id.layout_bottom
|
||||||
|
)?.visibility = View.GONE
|
||||||
|
|
||||||
|
player.findViewById<View>(
|
||||||
|
com.shuyu.gsyvideoplayer.R.id.layout_top
|
||||||
|
)?.visibility = View.GONE
|
||||||
|
|
||||||
|
// 加载你的全屏覆盖层
|
||||||
|
val overlay = LayoutInflater.from(context)
|
||||||
|
.inflate(
|
||||||
|
R.layout.layout_my_player,
|
||||||
|
player,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
player.addView(overlay)
|
||||||
|
|
||||||
|
// 找按钮
|
||||||
|
overlay.findViewById<View>(R.id.btnAi)
|
||||||
|
?.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay.findViewById<View>(R.id.btnCapture)
|
||||||
|
?.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return player
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
70
app/src/main/res/layout/layout_my_player.xml
Normal file
70
app/src/main/res/layout/layout_my_player.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- GSY视频显示区域 -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@id/surface_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<!-- 顶部栏 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:id="@+id/topBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="实时监控"
|
||||||
|
android:textColor="#fff" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|start"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:src="@mipmap/ky"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnAi"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:src="@mipmap/ky"/>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnCapture"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:src="@mipmap/qiang"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
BIN
app/src/main/res/mipmap-xhdpi/ky.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ky.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/qiang.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/qiang.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/vide_back.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/vide_back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Reference in New Issue
Block a user