Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Casanowow Life for love
VLC-Android
Commits
7a07dc91
Commit
7a07dc91
authored
Aug 23, 2017
by
David Papazian
Committed by
Geoffrey Métais
Aug 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement audio boost
Signed-off-by:
Geoffrey Métais
<
geoffrey.metais@gmail.com
>
parent
55382eda
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
17 deletions
+105
-17
vlc-android/res/layout/player_overlay_info.xml
vlc-android/res/layout/player_overlay_info.xml
+6
-0
vlc-android/res/values/colors.xml
vlc-android/res/values/colors.xml
+1
-0
vlc-android/res/values/strings.xml
vlc-android/res/values/strings.xml
+3
-0
vlc-android/res/xml/preferences_video.xml
vlc-android/res/xml/preferences_video.xml
+5
-0
vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
...d/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+90
-17
No files found.
vlc-android/res/layout/player_overlay_info.xml
View file @
7a07dc91
...
...
@@ -11,6 +11,7 @@
android:layout_width=
"20dp"
android:layout_height=
"100dp"
>
<LinearLayout
android:id=
"@+id/verticalbar_linearlayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"4dp"
...
...
@@ -18,6 +19,11 @@
android:weightSum=
"100"
android:gravity=
"bottom"
>
<View
android:id=
"@+id/verticalbar_boost_progress"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:background=
"@color/red500transparent"
/>
<View
android:id=
"@+id/verticalbar_progress"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
...
...
vlc-android/res/values/colors.xml
View file @
7a07dc91
...
...
@@ -19,6 +19,7 @@
<color
name=
"orange800"
>
#ff610a
</color>
<color
name=
"orange900"
>
#ff5014
</color>
<color
name=
"red500transparent"
>
#b4ff0000
</color>
<color
name=
"orange500transparent"
>
#b4ff8800
</color>
<color
name=
"orange200transparent"
>
#64ffca7d
</color>
...
...
vlc-android/res/values/strings.xml
View file @
7a07dc91
...
...
@@ -144,6 +144,7 @@
<string
name=
"brightness"
>
Brightness
</string>
<string
name=
"navmenu"
>
navigation menu
</string>
<string
name=
"advanced"
>
advanced options
</string>
<string
name=
"audio_boost_warning"
>
Slide up again to go beyond 100%
</string>
<plurals
name=
"track_channels_info_quantity"
>
<item
quantity=
"one"
>
1 channel\n
</item>
...
...
@@ -345,6 +346,8 @@
<string
name=
"audio_title_alignment_marquee"
>
Marquee
</string>
<string
name=
"audio_save_repeat_title"
>
Save repeat mode
</string>
<string
name=
"audio_save_repeat_summary"
>
Remember repeat mode when loading audio playlists
</string>
<string
name=
"audio_boost_title"
>
Audio-boost
</string>
<string
name=
"audio_boost_summary"
>
Enable volume up to 200%
</string>
<string
name=
"headset_prefs_category"
>
Headset
</string>
<string
name=
"enable_headset_detection"
>
Detect headset
</string>
<string
name=
"enable_headset_detection_summary"
>
Detect headset insertion and removal
</string>
...
...
vlc-android/res/xml/preferences_video.xml
View file @
7a07dc91
...
...
@@ -42,6 +42,11 @@
android:summary=
"@string/video_app_switch_summary"
android:title=
"@string/video_app_switch_title"
/>
<PreferenceCategory
android:title=
"@string/controls_prefs_category"
>
<CheckBoxPreference
android:defaultValue=
"false"
android:key=
"audio_boost"
android:summary=
"@string/audio_boost_summary"
android:title=
"@string/audio_boost_title"
/>
<CheckBoxPreference
android:defaultValue=
"false"
android:key=
"force_play_all"
...
...
vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
View file @
7a07dc91
...
...
@@ -247,6 +247,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private
View
mOverlayInfo
;
private
View
mVerticalBar
;
private
View
mVerticalBarProgress
;
private
View
mVerticalBarBoostProgress
;
private
boolean
mIsLoading
;
private
boolean
mIsPlaying
=
false
;
private
ImageView
mLoading
;
...
...
@@ -301,9 +302,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
//Volume
private
AudioManager
mAudioManager
;
private
int
mAudioMax
;
private
boolean
audioBoostEnabled
;
private
boolean
mMute
=
false
;
private
int
mVolSave
;
private
float
mVol
;
private
float
mOriginalVol
;
private
Toast
warningToast
;
//Touch Events
private
static
final
int
TOUCH_NONE
=
0
;
...
...
@@ -390,6 +394,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
/* Services and miscellaneous */
mAudioManager
=
(
AudioManager
)
getApplicationContext
().
getSystemService
(
AUDIO_SERVICE
);
mAudioMax
=
mAudioManager
.
getStreamMaxVolume
(
AudioManager
.
STREAM_MUSIC
);
audioBoostEnabled
=
mSettings
.
getBoolean
(
"audio_boost"
,
false
);
mEnableCloneMode
=
mSettings
.
getBoolean
(
"enable_clone_mode"
,
false
);
createPresentation
();
...
...
@@ -1322,12 +1327,32 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
delaySubs
(
50000
l
);
return
true
;
case
KeyEvent
.
KEYCODE_VOLUME_DOWN
:
if
(
mMute
)
{
updateMute
();
}
else
{
int
vol
;
if
(
mService
.
getVolume
()
>
100
)
vol
=
Math
.
round
(((
float
)
mService
.
getVolume
())*
mAudioMax
/
100
-
1
);
else
vol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
)
-
1
;
vol
=
Math
.
min
(
Math
.
max
(
vol
,
0
),
mAudioMax
*
(
audioBoostEnabled
?
2
:
1
));
mOriginalVol
=
vol
;
setAudioVolume
(
vol
);
}
return
true
;
case
KeyEvent
.
KEYCODE_VOLUME_UP
:
if
(
mMute
)
{
updateMute
();
return
true
;
}
else
return
false
;
}
else
{
int
vol
;
if
(
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
)
<
mAudioMax
)
vol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
)
+
1
;
else
vol
=
Math
.
round
(((
float
)
mService
.
getVolume
())*
mAudioMax
/
100
+
1
);
vol
=
Math
.
min
(
Math
.
max
(
vol
,
0
),
mAudioMax
*
(
audioBoostEnabled
?
2
:
1
));
setAudioVolume
(
vol
);
}
return
true
;
case
KeyEvent
.
KEYCODE_CAPTIONS
:
selectSubtitles
();
return
true
;
...
...
@@ -1517,13 +1542,26 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
* @param duration
* @param barNewValue new volume/brightness value (range: 0 - 15)
*/
private
void
showInfoWithVerticalBar
(
String
text
,
int
duration
,
int
barNewValue
)
{
private
void
showInfoWithVerticalBar
(
String
text
,
int
duration
,
int
barNewValue
,
int
max
)
{
showInfo
(
text
,
duration
);
if
(
mVerticalBarProgress
==
null
)
return
;
LinearLayout
.
LayoutParams
layoutParams
=
(
LinearLayout
.
LayoutParams
)
mVerticalBarProgress
.
getLayoutParams
();
layoutParams
.
weight
=
barNewValue
;
mVerticalBarProgress
.
setLayoutParams
(
layoutParams
);
LinearLayout
.
LayoutParams
layoutParams
;
if
(
barNewValue
<=
100
)
{
layoutParams
=
(
LinearLayout
.
LayoutParams
)
mVerticalBarProgress
.
getLayoutParams
();
layoutParams
.
weight
=
barNewValue
*
100
/
max
;
mVerticalBarProgress
.
setLayoutParams
(
layoutParams
);
layoutParams
=
(
LinearLayout
.
LayoutParams
)
mVerticalBarBoostProgress
.
getLayoutParams
();
layoutParams
.
weight
=
0
;
mVerticalBarBoostProgress
.
setLayoutParams
(
layoutParams
);
}
else
{
layoutParams
=
(
LinearLayout
.
LayoutParams
)
mVerticalBarProgress
.
getLayoutParams
();
layoutParams
.
weight
=
100
*
100
/
max
;
mVerticalBarProgress
.
setLayoutParams
(
layoutParams
);
layoutParams
=
(
LinearLayout
.
LayoutParams
)
mVerticalBarBoostProgress
.
getLayoutParams
();
layoutParams
.
weight
=
(
barNewValue
-
100
)
*
100
/
max
;
mVerticalBarBoostProgress
.
setLayoutParams
(
layoutParams
);
}
mVerticalBar
.
setVisibility
(
View
.
VISIBLE
);
}
...
...
@@ -1550,6 +1588,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mOverlayInfo
=
findViewById
(
R
.
id
.
player_overlay_info
);
mVerticalBar
=
findViewById
(
R
.
id
.
verticalbar
);
mVerticalBarProgress
=
findViewById
(
R
.
id
.
verticalbar_progress
);
mVerticalBarBoostProgress
=
findViewById
(
R
.
id
.
verticalbar_boost_progress
);
}
}
...
...
@@ -2125,7 +2164,13 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case
MotionEvent
.
ACTION_DOWN
:
// Audio
mTouchY
=
mInitTouchY
=
event
.
getRawY
();
mVol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
);
if
(
mService
.
getVolume
()
<=
100
)
{
mVol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
);
mOriginalVol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
);
}
else
{
mVol
=
((
float
)
mService
.
getVolume
())
*
mAudioMax
/
100
;
}
mTouchAction
=
TOUCH_NONE
;
// Seek
mTouchX
=
event
.
getRawX
();
...
...
@@ -2231,25 +2276,51 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
return
;
float
delta
=
-
((
y_changed
/
(
float
)
mScreen
.
heightPixels
)
*
mAudioMax
);
mVol
+=
delta
;
int
vol
=
(
int
)
Math
.
min
(
Math
.
max
(
mVol
,
0
),
mAudioMax
);
int
vol
=
(
int
)
Math
.
min
(
Math
.
max
(
mVol
,
0
),
mAudioMax
*
(
audioBoostEnabled
?
2
:
1
));
if
(
delta
<
0
)
mOriginalVol
=
vol
;
if
(
delta
!=
0
f
)
{
setAudioVolume
(
vol
);
if
(
vol
>
mAudioMax
)
{
if
(
audioBoostEnabled
)
{
if
(
mOriginalVol
<
mAudioMax
)
{
displayWarningToast
();
setAudioVolume
(
mAudioMax
);
}
else
{
setAudioVolume
(
vol
);
}
}
}
else
{
setAudioVolume
(
vol
);
}
}
}
//Toast that appears only once
public
void
displayWarningToast
()
{
if
(
warningToast
!=
null
)
warningToast
.
cancel
();
warningToast
=
Toast
.
makeText
(
getApplication
(),
R
.
string
.
audio_boost_warning
,
Toast
.
LENGTH_SHORT
);
warningToast
.
show
();
}
private
void
setAudioVolume
(
int
vol
)
{
if
(
vol
<=
0
&&
AndroidUtil
.
isNougatOrLater
)
return
;
//Android N+ throws "SecurityException: Not allowed to change Do Not Disturb state"
/* Since android 4.3, the safe volume warning dialog is displayed only with the FLAG_SHOW_UI flag.
* We don't want to always show the default UI volume, so show it only when volume is not set. */
int
newVol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
);
if
(
vol
!=
newVol
)
mAudioManager
.
setStreamVolume
(
AudioManager
.
STREAM_MUSIC
,
vol
,
0
);
if
(
vol
<=
mAudioMax
)
{
mService
.
setVolume
(
100
);
int
newVol
=
mAudioManager
.
getStreamVolume
(
AudioManager
.
STREAM_MUSIC
);
if
(
vol
!=
newVol
)
mAudioManager
.
setStreamVolume
(
AudioManager
.
STREAM_MUSIC
,
vol
,
0
);
vol
=
Math
.
round
(
vol
*
100
/
mAudioMax
);
}
else
{
vol
=
Math
.
round
(
vol
*
100
/
mAudioMax
);
mService
.
setVolume
(
Math
.
round
(
vol
));
}
mTouchAction
=
TOUCH_VOLUME
;
vol
=
vol
*
100
/
mAudioMax
;
showInfoWithVerticalBar
(
getString
(
R
.
string
.
volume
)
+
"\n"
+
Integer
.
toString
(
vol
)
+
'%'
,
1000
,
vol
);
showInfoWithVerticalBar
(
getString
(
R
.
string
.
volume
)
+
"\n"
+
Integer
.
toString
(
vol
)
+
'%'
,
1000
,
vol
,
audioBoostEnabled
?
200
:
100
);
}
private
void
mute
(
boolean
mute
)
{
...
...
@@ -2309,7 +2380,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
float
brightness
=
Math
.
min
(
Math
.
max
(
lp
.
screenBrightness
+
delta
,
0.01f
),
1
f
);
setWindowBrightness
(
brightness
);
brightness
=
Math
.
round
(
brightness
*
100
);
showInfoWithVerticalBar
(
getString
(
R
.
string
.
brightness
)
+
"\n"
+
(
int
)
brightness
+
'%'
,
1000
,
(
int
)
brightness
);
showInfoWithVerticalBar
(
getString
(
R
.
string
.
brightness
)
+
"\n"
+
(
int
)
brightness
+
'%'
,
1000
,
(
int
)
brightness
,
100
);
}
private
void
setWindowBrightness
(
float
brightness
)
{
...
...
@@ -3652,6 +3723,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mHandler
.
sendEmptyMessage
(
START_PLAYBACK
);
mSwitchingView
=
false
;
mSettings
.
edit
().
putBoolean
(
PreferencesActivity
.
VIDEO_RESTORE
,
false
).
apply
();
if
(
mService
.
getVolume
()
>
100
&&
!
audioBoostEnabled
)
mService
.
setVolume
(
100
);
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment