24
24
import android .graphics .Typeface ;
25
25
import android .graphics .drawable .Icon ;
26
26
import android .media .AudioManager ;
27
+ import android .media .audiofx .AudioEffect ;
27
28
import android .media .audiofx .LoudnessEnhancer ;
28
29
import android .net .Uri ;
29
30
import android .os .Build ;
@@ -926,13 +927,13 @@ public void onAnimationEnd(Animator animation) {
926
927
loudnessEnhancer .release ();
927
928
}
928
929
try {
929
- int audioSessionId = C .generateAudioSessionIdV21 (this );
930
- loudnessEnhancer = new LoudnessEnhancer (audioSessionId );
931
- player .setAudioSessionId (audioSessionId );
930
+ loudnessEnhancer = new LoudnessEnhancer (player .getAudioSessionId ());
932
931
} catch (RuntimeException e ) {
933
932
e .printStackTrace ();
934
933
}
935
934
935
+ notifyAudioSessionUpdate (true );
936
+
936
937
videoLoading = true ;
937
938
938
939
updateLoading (true );
@@ -974,6 +975,8 @@ public void onAnimationEnd(Animator animation) {
974
975
975
976
public void releasePlayer () {
976
977
if (player != null ) {
978
+ notifyAudioSessionUpdate (false );
979
+
977
980
mediaSession .setActive (false );
978
981
mediaSession .release ();
979
982
@@ -1013,6 +1016,7 @@ public void onAudioSessionIdChanged(int audioSessionId) {
1013
1016
} catch (RuntimeException e ) {
1014
1017
e .printStackTrace ();
1015
1018
}
1019
+ notifyAudioSessionUpdate (true );
1016
1020
}
1017
1021
1018
1022
@ Override
@@ -1742,4 +1746,15 @@ void skipToNext() {
1742
1746
initializePlayer ();
1743
1747
}
1744
1748
}
1749
+
1750
+ void notifyAudioSessionUpdate (final boolean active ) {
1751
+ final Intent intent = new Intent (active ? AudioEffect .ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION
1752
+ : AudioEffect .ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION );
1753
+ intent .putExtra (AudioEffect .EXTRA_AUDIO_SESSION , player .getAudioSessionId ());
1754
+ intent .putExtra (AudioEffect .EXTRA_PACKAGE_NAME , getPackageName ());
1755
+ if (active ) {
1756
+ intent .putExtra (AudioEffect .EXTRA_CONTENT_TYPE , AudioEffect .CONTENT_TYPE_MOVIE );
1757
+ }
1758
+ sendBroadcast (intent );
1759
+ }
1745
1760
}
0 commit comments