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
Ewout ter Hoeven
VLC-Android
Commits
b5f020a5
Commit
b5f020a5
authored
Jan 24, 2012
by
Sébastien Toque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make headset detection optional
parent
6ae74913
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
10 deletions
+51
-10
vlc-android/res/values-fr/strings.xml
vlc-android/res/values-fr/strings.xml
+2
-0
vlc-android/res/values/strings.xml
vlc-android/res/values/strings.xml
+2
-0
vlc-android/res/xml/preferences.xml
vlc-android/res/xml/preferences.xml
+5
-0
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
+2
-0
vlc-android/src/org/videolan/vlc/android/AudioService.java
vlc-android/src/org/videolan/vlc/android/AudioService.java
+17
-9
vlc-android/src/org/videolan/vlc/android/AudioServiceController.java
.../src/org/videolan/vlc/android/AudioServiceController.java
+9
-0
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
+1
-0
vlc-android/src/org/videolan/vlc/android/PreferencesActivity.java
...oid/src/org/videolan/vlc/android/PreferencesActivity.java
+13
-1
No files found.
vlc-android/res/values-fr/strings.xml
View file @
b5f020a5
...
...
@@ -57,4 +57,6 @@
<string
name=
"enable_iomx"
>
Activer le décodage matériel
</string>
<string
name=
"advanced_debugging"
>
Débogage avancé
</string>
<string
name=
"quit"
>
Quitter l\'application
</string>
<string
name=
"detect_headset"
>
Détecter le casque
</string>
<string
name=
"detect_headset_detail"
>
Pause lors du débranchement du casque, Reprise lors du branchement du casque
</string>
</resources>
vlc-android/res/values/strings.xml
View file @
b5f020a5
...
...
@@ -59,4 +59,6 @@
<string
name=
"enable_iomx"
>
Enable hardware accelerated decoding
</string>
<string
name=
"advanced_debugging"
>
Advanced Debugging
</string>
<string
name=
"quit"
>
Quit Application
</string>
<string
name=
"detect_headset"
>
Detect headset
</string>
<string
name=
"detect_headset_detail"
>
Pause on headset removed, Resume on headset inserted
</string>
</resources>
vlc-android/res/xml/preferences.xml
View file @
b5f020a5
...
...
@@ -24,6 +24,11 @@
android:key=
"enable_iomx"
android:title=
"@string/enable_iomx"
>
</CheckBoxPreference>
<CheckBoxPreference
android:key=
"enable_headset_detection"
android:title=
"@string/detect_headset"
android:summary=
"@string/detect_headset_detail"
>
</CheckBoxPreference>
<PreferenceScreen
android:title=
"@string/advanced_debugging"
>
<Preference
android:title=
"@string/quit"
android:key=
"quit_app"
android:enabled=
"true"
/>
</PreferenceScreen>
...
...
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
View file @
b5f020a5
...
...
@@ -62,6 +62,8 @@ public interface AudioPlayer {
void
setRepeatType
(
RepeatType
t
);
RepeatType
getRepeatType
();
void
detectHeadset
(
boolean
enable
);
}
}
vlc-android/src/org/videolan/vlc/android/AudioService.java
View file @
b5f020a5
...
...
@@ -61,6 +61,7 @@ public class AudioService extends Service {
private
Notification
mNotification
;
private
boolean
mShuffling
=
false
;
private
RepeatType
mRepeating
=
RepeatType
.
None
;
private
boolean
mDetectHeadset
=
false
;
@Override
public
void
onStart
(
Intent
intent
,
int
startId
)
{
...
...
@@ -106,15 +107,17 @@ public class AudioService extends Service {
String
action
=
intent
.
getAction
();
int
state
=
intent
.
getIntExtra
(
"state"
,
0
);
if
(
action
.
equalsIgnoreCase
(
AudioManager
.
ACTION_AUDIO_BECOMING_NOISY
))
{
Log
.
i
(
TAG
,
"Headset Removed."
);
if
(
mLibVLC
.
isPlaying
()
&&
mCurrentMedia
!=
null
)
pause
();
}
else
if
(
action
.
equalsIgnoreCase
(
Intent
.
ACTION_HEADSET_PLUG
)
&&
state
!=
0
)
{
Log
.
i
(
TAG
,
"Headset Inserted."
);
if
(!
mLibVLC
.
isPlaying
()
&&
mCurrentMedia
!=
null
)
play
();
if
(
mDetectHeadset
)
{
if
(
action
.
equalsIgnoreCase
(
AudioManager
.
ACTION_AUDIO_BECOMING_NOISY
))
{
Log
.
i
(
TAG
,
"Headset Removed."
);
if
(
mLibVLC
.
isPlaying
()
&&
mCurrentMedia
!=
null
)
pause
();
}
else
if
(
action
.
equalsIgnoreCase
(
Intent
.
ACTION_HEADSET_PLUG
)
&&
state
!=
0
)
{
Log
.
i
(
TAG
,
"Headset Inserted."
);
if
(!
mLibVLC
.
isPlaying
()
&&
mCurrentMedia
!=
null
)
play
();
}
}
}
};
...
...
@@ -466,6 +469,11 @@ public class AudioService extends Service {
else
return
false
;
}
@Override
public
void
detectHeadset
(
boolean
enable
)
throws
RemoteException
{
mDetectHeadset
=
enable
;
}
};
}
vlc-android/src/org/videolan/vlc/android/AudioServiceController.java
View file @
b5f020a5
...
...
@@ -378,4 +378,13 @@ public class AudioServiceController implements AudioPlayerControl {
return
RepeatType
.
None
;
}
}
@Override
public
void
detectHeadset
(
boolean
enable
)
{
try
{
mAudioServiceBinder
.
detectHeadset
(
enable
);
}
catch
(
RemoteException
e
)
{
Log
.
e
(
TAG
,
"remote procedure call failed: detectHeadset()"
);
}
}
}
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
View file @
b5f020a5
...
...
@@ -46,4 +46,5 @@ interface IAudioService {
Bitmap
getCover
();
void
addAudioCallback
(
IAudioServiceCallback
cb
);
void
removeAudioCallback
(
IAudioServiceCallback
cb
);
void
detectHeadset
(
boolean
enable
);
}
vlc-android/src/org/videolan/vlc/android/PreferencesActivity.java
View file @
b5f020a5
...
...
@@ -24,6 +24,7 @@ import android.app.AlertDialog;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.preference.CheckBoxPreference
;
import
android.preference.Preference
;
import
android.preference.PreferenceActivity
;
import
android.preference.Preference.OnPreferenceClickListener
;
...
...
@@ -72,7 +73,18 @@ public class PreferencesActivity extends PreferenceActivity {
return
true
;
}
});
// Headset detection option
CheckBoxPreference
checkboxHS
=
(
CheckBoxPreference
)
findPreference
(
"enable_headset_detection"
);
checkboxHS
.
setOnPreferenceClickListener
(
new
OnPreferenceClickListener
()
{
public
boolean
onPreferenceClick
(
Preference
preference
)
{
CheckBoxPreference
checkboxHS
=
(
CheckBoxPreference
)
preference
;
AudioServiceController
.
getInstance
().
detectHeadset
(
checkboxHS
.
isChecked
());
return
true
;
}
});
// Attach debugging items
Preference
quitAppPref
=
(
Preference
)
findPreference
(
"quit_app"
);
quitAppPref
.
setOnPreferenceClickListener
(
...
...
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