加入點擊
This commit is contained in:
parent
15475923cb
commit
c3f8366475
@ -11,13 +11,18 @@
|
|||||||
android:theme="@style/Theme.Gstreamer">
|
android:theme="@style/Theme.Gstreamer">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.ray650128.gstreamer_demo_app.ui.mainScreen.MainActivity"
|
android:name="com.ray650128.gstreamer_demo_app.ui.mainScreen.MainActivity"
|
||||||
android:exported="true">
|
android:exported="true"
|
||||||
|
android:screenOrientation="nosensor">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.monitoringScreen.MonitoringActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="nosensor" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.ray650128.gstreamer_demo_app.ui.mainScreen
|
package com.ray650128.gstreamer_demo_app.ui.mainScreen
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@ -10,6 +11,7 @@ import androidx.gridlayout.widget.GridLayout
|
|||||||
import com.ray650128.gstreamer_demo_app.databinding.FragmentSplitViewBinding
|
import com.ray650128.gstreamer_demo_app.databinding.FragmentSplitViewBinding
|
||||||
import com.ray650128.gstreamer_demo_app.dp
|
import com.ray650128.gstreamer_demo_app.dp
|
||||||
import com.ray650128.gstreamer_demo_app.model.Device
|
import com.ray650128.gstreamer_demo_app.model.Device
|
||||||
|
import com.ray650128.gstreamer_demo_app.ui.monitoringScreen.MonitoringActivity
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@ -123,27 +125,32 @@ class SplitViewFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAllUrl()
|
setAllUrl()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isClickable) {
|
if (isClickable) {
|
||||||
for (position in videoViews.indices) {
|
for (position in videoViews.indices) {
|
||||||
videoViews[position].setOnClickListener {
|
videoViews[position].setOnClickListener {
|
||||||
if (position >= data.size) return@setOnClickListener
|
if (position >= data.size) return@setOnClickListener
|
||||||
if (!videoViews[position].isPlaying) {
|
if (!videoViews[position].isPlaying) {
|
||||||
if (!videoViews[position].isLoading) {
|
if (!videoViews[position].isLoading) {
|
||||||
videoViews[position].play()
|
videoViews[position].retryCount = 0
|
||||||
|
videoViews[position].play()
|
||||||
|
}
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
stopAll()
|
||||||
|
val item = data[position]
|
||||||
|
val bundle = Bundle().apply {
|
||||||
|
//putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
|
||||||
|
//putInt(MonitoringActivity.BUNDLE_CHANNEL_ID, item.channelId)
|
||||||
|
putParcelable(MonitoringActivity.BUNDLE_DEVICE, item)
|
||||||
|
}
|
||||||
|
val intent = Intent(requireContext(), MonitoringActivity::class.java)
|
||||||
|
intent.putExtras(bundle)
|
||||||
|
startActivity(intent)
|
||||||
|
//gotoActivity(MonitoringActivity::class.java, bundle)*/
|
||||||
|
//Log.d("${TAG}_$mPageNum", "check: $item")
|
||||||
}
|
}
|
||||||
return@setOnClickListener
|
|
||||||
}
|
}
|
||||||
/*stopAll()
|
|
||||||
val item = data[position]
|
|
||||||
val bundle = Bundle().apply {
|
|
||||||
putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
|
|
||||||
putInt(MonitoringActivity.BUNDLE_CHANNEL_ID, item.channelId)
|
|
||||||
}
|
|
||||||
gotoActivity(MonitoringActivity::class.java, bundle)*/
|
|
||||||
//Log.d("${TAG}_$mPageNum", "check: $item")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,6 +166,7 @@ class SplitViewFragment : Fragment() {
|
|||||||
fun playAll() = MainScope().launch(Dispatchers.Main) {
|
fun playAll() = MainScope().launch(Dispatchers.Main) {
|
||||||
if (videoViews.isEmpty()) return@launch
|
if (videoViews.isEmpty()) return@launch
|
||||||
for (index in data.indices) {
|
for (index in data.indices) {
|
||||||
|
videoViews[index].retryCount = 0
|
||||||
videoViews[index].play()
|
videoViews[index].play()
|
||||||
delay(300)
|
delay(300)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class VideoView : ConstraintLayout, SurfaceHolder.Callback, GstCallback {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
private var retryCount = 0
|
var retryCount = 0
|
||||||
private var retryRunnable = object : Runnable {
|
private var retryRunnable = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
play()
|
play()
|
||||||
@ -94,9 +94,9 @@ class VideoView : ConstraintLayout, SurfaceHolder.Callback, GstCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun play() {
|
fun play() {
|
||||||
if (retryCount == RETRY_OFF) {
|
/*if (retryCount == RETRY_OFF) {
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
videoView.postInvalidate()
|
videoView.postInvalidate()
|
||||||
gstLibrary.play()
|
gstLibrary.play()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.ray650128.gstreamer_demo_app.ui.monitoringScreen
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.WindowManager
|
||||||
|
import com.ray650128.gstreamer_demo_app.databinding.ActivityMainBinding
|
||||||
|
import com.ray650128.gstreamer_demo_app.databinding.ActivityMonitoringBinding
|
||||||
|
|
||||||
|
class MonitoringActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var binding: ActivityMonitoringBinding
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
binding = ActivityMonitoringBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val BUNDLE_DEVICE_ID = "BUNDLE_DEVICE_ID"
|
||||||
|
const val BUNDLE_CHANNEL_ID = "BUNDLE_CHANNEL_ID"
|
||||||
|
const val BUNDLE_DEVICE = "BUNDLE_DEVICE"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/src/main/res/layout/activity_monitoring.xml
Normal file
9
app/src/main/res/layout/activity_monitoring.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.monitoringScreen.MonitoringActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Loading…
Reference in New Issue
Block a user