Add touch sound api
parent
4205a65b87
commit
a2765eef60
|
@ -17,7 +17,7 @@ import androidx.media3.exoplayer.hls.HlsMediaSource
|
|||
import gallery.memories.databinding.ActivityMainBinding
|
||||
|
||||
@UnstableApi class MainActivity : AppCompatActivity() {
|
||||
private val binding by lazy(LazyThreadSafetyMode.NONE) {
|
||||
val binding by lazy(LazyThreadSafetyMode.NONE) {
|
||||
ActivityMainBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.Color
|
|||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.view.SoundEffectConstants
|
||||
import android.view.View
|
||||
import android.view.WindowInsetsController
|
||||
import android.webkit.JavascriptInterface
|
||||
|
@ -104,6 +105,13 @@ import java.net.URLDecoder
|
|||
mDlService!!.queue(url, filename)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun playTouchSound() {
|
||||
mActivity.runOnUiThread {
|
||||
mActivity.binding.webview.playSoundEffect(SoundEffectConstants.CLICK)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun playVideoLocal(fileId: String?) {
|
||||
if (fileId == null) return;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:soundEffectsEnabled="true"
|
||||
/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue