Sound pool volume level
Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.
i tried with
soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);
and it was still at the same sound level, i also tried with
int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
soundPool.setVolume(streamId, 0.5f, 0.5f);
and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.
EDIT:
i initialize with following constructor
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();
soundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes)
.setMaxStreams(2)
.build();
else
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
android soundpool
add a comment |
Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.
i tried with
soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);
and it was still at the same sound level, i also tried with
int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
soundPool.setVolume(streamId, 0.5f, 0.5f);
and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.
EDIT:
i initialize with following constructor
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();
soundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes)
.setMaxStreams(2)
.build();
else
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
android soundpool
add a comment |
Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.
i tried with
soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);
and it was still at the same sound level, i also tried with
int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
soundPool.setVolume(streamId, 0.5f, 0.5f);
and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.
EDIT:
i initialize with following constructor
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();
soundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes)
.setMaxStreams(2)
.build();
else
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
android soundpool
Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.
i tried with
soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);
and it was still at the same sound level, i also tried with
int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
soundPool.setVolume(streamId, 0.5f, 0.5f);
and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.
EDIT:
i initialize with following constructor
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();
soundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes)
.setMaxStreams(2)
.build();
else
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
android soundpool
android soundpool
edited Nov 13 '18 at 11:27
HyperX
asked Nov 13 '18 at 10:00
HyperXHyperX
3932926
3932926
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You should start using ExoPlayer, it has more rigid API then MediaPlayer
and SoundPool
You can find it here, ExoPlayer.
It has setVolume(float)
api
See more here
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
add a comment |
Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
If Builder using, what AudioAttributes passed into initialization ?
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278396%2fsound-pool-volume-level%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should start using ExoPlayer, it has more rigid API then MediaPlayer
and SoundPool
You can find it here, ExoPlayer.
It has setVolume(float)
api
See more here
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
add a comment |
You should start using ExoPlayer, it has more rigid API then MediaPlayer
and SoundPool
You can find it here, ExoPlayer.
It has setVolume(float)
api
See more here
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
add a comment |
You should start using ExoPlayer, it has more rigid API then MediaPlayer
and SoundPool
You can find it here, ExoPlayer.
It has setVolume(float)
api
See more here
You should start using ExoPlayer, it has more rigid API then MediaPlayer
and SoundPool
You can find it here, ExoPlayer.
It has setVolume(float)
api
See more here
answered Nov 13 '18 at 10:40
Haroun HajemHaroun Hajem
18519
18519
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
add a comment |
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.
– HyperX
Nov 13 '18 at 11:05
add a comment |
Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
If Builder using, what AudioAttributes passed into initialization ?
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
add a comment |
Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
If Builder using, what AudioAttributes passed into initialization ?
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
add a comment |
Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
If Builder using, what AudioAttributes passed into initialization ?
Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
If Builder using, what AudioAttributes passed into initialization ?
answered Nov 13 '18 at 11:23
OnixOnix
4378
4378
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
add a comment |
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Using both updated my question with my constructor
– HyperX
Nov 13 '18 at 11:27
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
Which Android model and Android version using for testing ?
– Onix
Nov 13 '18 at 11:32
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
This does not answer the question.
– greeble31
Nov 13 '18 at 20:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278396%2fsound-pool-volume-level%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown