Sound related queries...

Technical | Application Development | patash | 1 month | 8 Replies | 1,703 Views

*

patash

  • ****
  • 491
  • 5165 Points
  • Tizen is better than iOS.
Sound related queries...
« On:August 16, 2015, 08:01:26 PM »
Hello all,
How to play sound from the rear speaker?
Is there a way to switch on the Rear speaker in stead of playing the sound from the Audio Jack.
And how ?

Also how do i decrease volume of my application by 0.5 unit ?
the below code is not working for me.

   int iSetVol = cur_vol - 0.5;
   ret = sound_manager_set_volume (typeSnd, &iSetVol);

Also how to mute the Volume ?



Ashish P
« Last Edit: August 16, 2015, 11:49:29 PM by patash »



*

Praveen Chikkappaiah

  • **
  • 34
  • 305 Points
    • View Website
Re: Sound related queries...
« Reply #1 On:August 17, 2015, 12:40:01 PM »
Hi Ashish,
Your queries finally abstract to 2 questions:
1. Is it possible to set the current sound device type?
2. how do i decrease volume of my application by 0.5 unit ?

Answer are:
1. Nope. Thrid party apps currently cannot set the current sound device type.

2. Nope you cannot set (increase/decrease) the volume in fractions. only integers are allowed.
And the code snippet you pasted has a bug.


int iSetVol = cur_vol - 0.5;
ret = sound_manager_set_volume (typeSnd, &iSetVol);

you are passing the address. just pass the value.

change it to :

int iSetVol = cur_vol - 1;
ret = sound_manager_set_volume (typeSnd, iSetVol);


Cheers,
Praveen C

*

patash

  • ****
  • 491
  • 5165 Points
  • Tizen is better than iOS.
Re: Sound related queries...
« Reply #2 On:August 17, 2015, 01:26:40 PM »
Hey Praveen,
Well its sad that 3rd party apps cannot play sound from rear speaker.
And BTW thanks for pointing out the bug in the code.


Regards,
Ashish Patil

*

Zed Zapped

  • *****
  • 2,259
  • 29545 Points
    • View Website
Re: Sound related queries...
« Reply #3 On:August 17, 2015, 01:38:57 PM »
@Ashish - what is the use case for which you want to set the audio output specifically from the app.
Usually in any platform, audio output is set to default device and based on connected device(earphones, BT HS) & scenario(call, music), audio managers would route it automatically.

*

patash

  • ****
  • 491
  • 5165 Points
  • Tizen is better than iOS.
Re: Sound related queries...
« Reply #4 On:August 17, 2015, 05:32:02 PM »
@Praveen - I can reduce the volume but increasing the volume does not work for me. Strange.

@Hello Zed...
I am developing music player and FM Radio apps. And wanted the feature for the user to switch to the rear speaker, instead of the usual option available that is the only headphones.
Also, in FM Radio app(not the streaming radio which requires internet) the Head Phones or earphones acts like the Antenna. So this is the default device, which is the listening device. But surely i would some times at least like to switch to the Rear Speaker.
Can we please have this feature in the Next SDK please.  ;)


Cheers,
Ashish Patil
« Last Edit: August 17, 2015, 06:35:59 PM by patash »

*

Praveen Chikkappaiah

  • **
  • 34
  • 305 Points
    • View Website
Re: Sound related queries...
« Reply #5 On:August 18, 2015, 09:28:52 AM »
Hi Ashish,
Can you paste your code snippet ?
Also could you print the return value of sound_manager_set_volume api and paste the log ?

Cheers,
Praveen C


*

patash

  • ****
  • 491
  • 5165 Points
  • Tizen is better than iOS.
Re: Sound related queries...
« Reply #6 On:August 18, 2015, 11:50:19 AM »
Hello Praveen,
For decreasing the volume the below code works for me:
ret = sound_manager_get_volume (typeSnd, &cur_vol);
   if(0 == cur_vol)
   {
         //Super low level(Show Toast)
         return;
   }
   int iSetVol = cur_vol - 0.5;
   ret = sound_manager_set_volume (typeSnd, iSetVol);

For increasing the volume below code works but if i increase by  0.5 it does not work:
ret = sound_manager_get_volume (typeSnd, &cur_vol);

   int iSetVol = cur_vol + 1;
   ret = sound_manager_set_volume (typeSnd, iSetVol);
   ret = sound_manager_get_volume (typeSnd, &cur_vol);

If i can decrease by 0.5 it should increase by 0.5 as well.
As increasing or decreasing by 1 unit it too much change in sound volume.


Cheers,
Ashish

*

Praveen Chikkappaiah

  • **
  • 34
  • 305 Points
    • View Website
Re: Sound related queries...
« Reply #7 On:August 18, 2015, 02:34:49 PM »
Hi Ashish,
As I mentioned in my first reply to this thread, the value is of type int.

so fractions will be ignored.

int a = 1;
a = a + 0.5;

value of 'a' will remain 1.

int a = 2;
a = a - 0.5;

value of 'a' will become 1.

Thats the reason why decrease works and increase doesnt work if you use 0.5 as increment.
Please use integer values as your increment / decerement value.

Hope its clear now.

Cheers,
Praveen C

*

patash

  • ****
  • 491
  • 5165 Points
  • Tizen is better than iOS.
Re: Sound related queries...
« Reply #8 On:August 18, 2015, 04:19:00 PM »
got it.


AP

Tags:
 


Facebook Comments




anything