Add touch sound api

pull/653/merge
Varun Patil 2023-05-14 17:26:39 -07:00
parent 4205a65b87
commit a2765eef60
3 changed files with 10 additions and 1 deletions

View File

@ -17,7 +17,7 @@ import androidx.media3.exoplayer.hls.HlsMediaSource
import gallery.memories.databinding.ActivityMainBinding import gallery.memories.databinding.ActivityMainBinding
@UnstableApi class MainActivity : AppCompatActivity() { @UnstableApi class MainActivity : AppCompatActivity() {
private val binding by lazy(LazyThreadSafetyMode.NONE) { val binding by lazy(LazyThreadSafetyMode.NONE) {
ActivityMainBinding.inflate(layoutInflater) ActivityMainBinding.inflate(layoutInflater)
} }

View File

@ -5,6 +5,7 @@ import android.graphics.Color
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import android.view.SoundEffectConstants
import android.view.View import android.view.View
import android.view.WindowInsetsController import android.view.WindowInsetsController
import android.webkit.JavascriptInterface import android.webkit.JavascriptInterface
@ -104,6 +105,13 @@ import java.net.URLDecoder
mDlService!!.queue(url, filename) mDlService!!.queue(url, filename)
} }
@JavascriptInterface
fun playTouchSound() {
mActivity.runOnUiThread {
mActivity.binding.webview.playSoundEffect(SoundEffectConstants.CLICK)
}
}
@JavascriptInterface @JavascriptInterface
fun playVideoLocal(fileId: String?) { fun playVideoLocal(fileId: String?) {
if (fileId == null) return; if (fileId == null) return;

View File

@ -17,6 +17,7 @@
android:id="@+id/webview" android:id="@+id/webview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:soundEffectsEnabled="true"
/> />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>