From 9035e15c3eccf3d7d05e46c649a090cf5a7c8878 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 16 Aug 2019 08:04:54 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/help/MediaHelp.kt | 20 ++++++++++++++++++ .../io/legado/app/service/ReadAloudService.kt | 2 ++ app/src/main/res/raw/silent_sound.mp3 | Bin 0 -> 6336 bytes 3 files changed, 22 insertions(+) create mode 100644 app/src/main/java/io/legado/app/help/MediaHelp.kt create mode 100644 app/src/main/res/raw/silent_sound.mp3 diff --git a/app/src/main/java/io/legado/app/help/MediaHelp.kt b/app/src/main/java/io/legado/app/help/MediaHelp.kt new file mode 100644 index 000000000..377fd5fbd --- /dev/null +++ b/app/src/main/java/io/legado/app/help/MediaHelp.kt @@ -0,0 +1,20 @@ +package io.legado.app.help + +import android.content.Context +import android.media.MediaPlayer +import io.legado.app.R + +object MediaHelp { + + + fun playSilentSound(mContext: Context) { + try { + // Stupid Android 8 "Oreo" hack to make media buttons work + val mMediaPlayer = MediaPlayer.create(mContext, R.raw.silent_sound) + mMediaPlayer.setOnCompletionListener { it.release() } + mMediaPlayer.start() + } catch (ignored: Exception) { + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/ReadAloudService.kt b/app/src/main/java/io/legado/app/service/ReadAloudService.kt index bc798a77b..bd48eefed 100644 --- a/app/src/main/java/io/legado/app/service/ReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/ReadAloudService.kt @@ -17,6 +17,7 @@ import io.legado.app.base.BaseService import io.legado.app.constant.AppConst import io.legado.app.constant.Bus import io.legado.app.constant.Status +import io.legado.app.help.MediaHelp import io.legado.app.help.PendingIntentHelp import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.utils.postEvent @@ -206,6 +207,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage * @return 音频焦点 */ private fun requestFocus(): Boolean { + MediaHelp.playSilentSound(this) val request: Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { audioManager.requestAudioFocus(mFocusRequest) } else { diff --git a/app/src/main/res/raw/silent_sound.mp3 b/app/src/main/res/raw/silent_sound.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..ce236a279400c386632265b9e43395e1c37e5f9f GIT binary patch literal 6336 zcmeI0dr*@{zkuIdNkYH?0U`t&LcoYza>amF69{R-%@7b{QJWBm1VOnfUTPCA5in># zkULEPK@<^{3R-Ll1mqGZ2%=c6h=7-3KU-|8_IA`W_WS32XTIr~bLPx<&NH*KJF~m< z?(RJE+kJn3JjgQw?-1;g?|$80_PU?|0M`vHe+T_fLjFYlC(1vm_>+r&$MlYczw^gC zUVqCsgcBM__wr?>g2?Zdf@PDSdLjU@->jo^>R!#ej{mR!SDnBgZ~WOEnbal>%fP}u z<*;=^zEX*y`Ve{cz)YfzZGp)J1BPls^f|EJ_@0@>D5Uz92+LL~g~pq_LR?E!Ax=j| zpkUBEB$4l8F~8~SojaGIRJS0_m>m|Wt5z2dNgENBitVLw*A#&R6oXe4g3~WPo5%MG zzrg7U zP5=keHd@<-&&mM{ZVz_`2S zCd>;85L7sfaH-_$~v^XAAU-8{=$LTT)d-V`_N44S6&fE6Vm~4 zeqZbRcW$zoDo_rn&*i5Z65~vU_c_e0_1BjXYfye;UCOtq58p# zeyc4_#v}|5lk+<##Re+ydJ(R@A7_2b10u9TW3cXYwUdADhw#fE_vc(O&(uola}6|t z!kNus2c0#8eM~(m9vE-3Yb_{D>e@)Y-hZqKg{vQaKj^ar_N9Vtr5>Vi@ZVOYr1b+( z5>jgkjh4fG#DIAY7=#vc38YAoSjzE~4DmyhxZYsVul|fpSXzLL7#NhzB|x*wpEVa^ z5r?mF`fD}u)dRq_hQh>0qevi2ZY_=zKnCE88X0oI1}k@!wYW9L?8xdbULjNRaNX!| zLI(UyMY!}r*imbwy5e`F&gfY5xcN%O1h9x8uQP1|8Rcy5-sf)JFOr+(CuUO;+^{9d zV{RY26WMEU5mFF?K=;S`bWCt7nW8k~F1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