I am doing a task where i have to load the url inside the webview so that i can show the video,everything is works fine but the thing is i need to pause the video inside the web view so video should not autoplay all the time.Any help Appricatied.
MainActivity
class MainActivity : AppCompatActivity() {
private var txvResult: TextView? = null
private lateinit var webView:WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
webView = findViewById(R.id.web_view)
webView.loadUrl("https://www.youtube.com/watch?v=Aeoa5ZsJ02U")
webView.webViewClient = WebViewClient()
val webSettings:WebSettings = webView.settings
webSettings.javaScriptEnabled = true
}
}
layout
<?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=".MainActivity">
<Button
android:onClick="getSpeechInput"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</WebView>
</androidx.constraintlayout.widget.ConstraintLayout>