Slider volume question (edited)

Hello. I have had a rejection because some Samsung devices cannot control the volume with the device buttons. I found this code which I have added. I do not have a Samsung device but a few other Android devices and when I set the return to “false” the OS volume graphics comes up with the volume slider and the volume changes. When I set to “true” the OS volume graphics does not appear but the volume changes still. On a previous app I made without any extra code the OS volume graphics appears as usual. So now I am really confused. If the OS volume graphics appear does it mean the code below is not doing anything and that if the OS volume graphics do not appear that is a good thing? I am working blind so is this code correct to make the devices volume control work from the side buttons? 

local function onKeyEvent( event )

   local phase = event.phase

   local keyName = event.keyName

   print( event.phase, event.keyName )

   if ( “back” == keyName and phase == “up” ) then

    

               native.requestExit()

      

   end

  

   if ( keyName == “volumeUp” and phase == “down” ) then

      local masterVolume = audio.getVolume()

      print( “volume:”, masterVolume )

      if ( masterVolume < 1.0 ) then

         masterVolume = masterVolume + 0.1

         audio.setVolume( masterVolume )

      end

   elseif ( keyName == “volumeDown” and phase == “down” ) then

      local masterVolume = audio.getVolume()

      print( “volume:”, masterVolume )

      if ( masterVolume > 0.0 ) then

         masterVolume = masterVolume - 0.1

         audio.setVolume( masterVolume )

      end

   end

   return false 

end

–add the key callback

Runtime:addEventListener( “key”, onKeyEvent )

@BeatsnBobs, I just did a very quick test.  First without return false, second with return false.  I did super quick test, so it’s not thorough, but this is what I found:

Whether OS volume graphics comes up seems to make no difference in how it behaves.  

With Nexus 10, it appears to do what it’s supposed to do.  

With Nexus 7, I can turn the volume down, but not up.  I exit the Corona app and turn up the volume, then relaunch the app, and I can get the sound back.

With Samsung Galaxy S3, I can turn the volume down, but not up.  I exit the Corona app, check the volume (which seems to be intact, actually), go ahead and turn up the volume a little more, then relaunch  the app, but the app no longer plays sound.  I exit the app again, force quit the app, relaunch the app, still no sound.  I delete the app, reinstall the app, relaunch the app – still no sound. I power off the device, turn it back on, relaunch the app, STILL NO SOUND.  Is it gone forever?  I hear beeps for message alerts and other sound from the device, but nothing from Corona app.  This is super disturbing.

And… I was about to delete and install a new version of the app without the onKeyEvent for volume control to see if it helps, but I didn’t have to.  What got my sound back for my app on Samsung Galaxy S3 was the Vungle video ad.  While it was playing, I tried upping the volume, and it worked.  Great sigh of relief there.

Anyway, something is awfully wrong with the volume control.  I am not including any of the related code in my onKeyEvent function.  (I cannot possibly rely on users changing the volume when Vungle video ads play, can I?)

Naomi 

Wow you are having more fun with this than me then :) 

For me I have just disabled the devices from Samsung (They seemed to be old Arm v6 anyway)

It is still odd how the volume on my cheap Android device still works but the graphics dont. Like its controlling the app volume but not the system volume i guess.

Looking at what you have found is very bizarre. I would never have thought the Nexus 7 and 10 act differently. I would have expected them to have the same key event. I wonder if key events are being changed. Is there a way you can do a quick test and print/debug display text the key events on the device screen? See if they are sending the same? Thats what i would do. Also you could set all channels volume to 1 at beginning to make sure they start ok.

You know, I’m just not going to deal with it right now.  But it would be really great if you could file a bug report (and include this forum thread) regarding this – especially if you want this looked at sooner than later?  Without it, it may not be looked at or fixed at all.  And if you could post a case number after you submit the report, that would be helpful.

Naomi

Done

Thanks!  Let’s hope it will be taken care of soon.

Naomi

What Corona build are you seeing this issue on? We made some internal changes to the key event code since build 1137 and I wonder if this is causing problems. Can you verify with build 1137 (if you haven’t already)?

Thanks,

Tom

Hi Tom. I am using 1161

Cheers

Rob

@Rob, can you verify with build 1137?

Hey, Tom, I think Rob @BeatsnBobs does not have the device with which he could verify this (or at least that’s what it sounds like to me from his first post.)  So, I’m on it.  I’m downloading the 1137 now and will post back.

Naomi

I just need to finish a couple of things Im working on then will do a test with that version

Yikes, the super quick test I did was totally wrong.  I’m so sorry about the false alert.  onKeyEvent for volume works fine on both 1137 and 1170, so long as we include return false to the key event.  It enables the OS volume slider to appear, and it gets the volume to go up and down properly.  I tested this on Galaxy S3 and Nexus 7.

I looked at my code, and I see the issue now.  When I did the quick test, I first tested without return false, which made the volumeUp and volumeDown to fail.  I then tested with return false, but I ended up having return false in volumeDown event only. 

And with Nexus 10, I have no clue at this point why it worked.  Maybe in my haste, I didn’t install the test app at all.  Ugh.

Again, Tom, I apologize for taking your time on this.

Naomi

Edit:  BTW, I haven’t tested how it behaves with return true.  Since it’s working with return false, I’m not going to worry about it.

Naomi: You quickly stuck it below the wrong “end” I guess. Easy to do. :slight_smile:

Tom: My original question was asking why whether or not the volume slider graphics come up or not the volume still works.  Also when I went back to an older app from a few months ago without any of that android key code, the volume worked anyway together with the graphics as normal. So by me putting the code in didnt seem to make any difference. What is happening if the graphics do not appear? Is this controlling the apps volume and not the system volume?

Do you still need me to do a test now that the major things Naomi mentioned are okay now?

Hey, BeatsnBobs, I don’t think volumeUp or volumeDown would work without OS volume slider.  

At least that’s how it looks to me when I tested it.  Also, with my app, when I do not include key code for volume, I cannot up or down the volume from within the app.  Plus, return true will also cause the code not to work.  I didn’t look carefully at what I was doing with key code earlier, but the thing is, my key code returns true by default.  So when I didn’t add any to volume key event, it was returning true.

I don’t understand why the volume works without android key code with your older app.  What daily build did you use with the app that works that way?

Naomi

@BeatsnBobs, I just did a very quick test.  First without return false, second with return false.  I did super quick test, so it’s not thorough, but this is what I found:

Whether OS volume graphics comes up seems to make no difference in how it behaves.  

With Nexus 10, it appears to do what it’s supposed to do.  

With Nexus 7, I can turn the volume down, but not up.  I exit the Corona app and turn up the volume, then relaunch the app, and I can get the sound back.

With Samsung Galaxy S3, I can turn the volume down, but not up.  I exit the Corona app, check the volume (which seems to be intact, actually), go ahead and turn up the volume a little more, then relaunch  the app, but the app no longer plays sound.  I exit the app again, force quit the app, relaunch the app, still no sound.  I delete the app, reinstall the app, relaunch the app – still no sound. I power off the device, turn it back on, relaunch the app, STILL NO SOUND.  Is it gone forever?  I hear beeps for message alerts and other sound from the device, but nothing from Corona app.  This is super disturbing.

And… I was about to delete and install a new version of the app without the onKeyEvent for volume control to see if it helps, but I didn’t have to.  What got my sound back for my app on Samsung Galaxy S3 was the Vungle video ad.  While it was playing, I tried upping the volume, and it worked.  Great sigh of relief there.

Anyway, something is awfully wrong with the volume control.  I am not including any of the related code in my onKeyEvent function.  (I cannot possibly rely on users changing the volume when Vungle video ads play, can I?)

Naomi 

Wow you are having more fun with this than me then :) 

For me I have just disabled the devices from Samsung (They seemed to be old Arm v6 anyway)

It is still odd how the volume on my cheap Android device still works but the graphics dont. Like its controlling the app volume but not the system volume i guess.

Looking at what you have found is very bizarre. I would never have thought the Nexus 7 and 10 act differently. I would have expected them to have the same key event. I wonder if key events are being changed. Is there a way you can do a quick test and print/debug display text the key events on the device screen? See if they are sending the same? Thats what i would do. Also you could set all channels volume to 1 at beginning to make sure they start ok.

You know, I’m just not going to deal with it right now.  But it would be really great if you could file a bug report (and include this forum thread) regarding this – especially if you want this looked at sooner than later?  Without it, it may not be looked at or fixed at all.  And if you could post a case number after you submit the report, that would be helpful.

Naomi

Done

Thanks!  Let’s hope it will be taken care of soon.

Naomi

What Corona build are you seeing this issue on? We made some internal changes to the key event code since build 1137 and I wonder if this is causing problems. Can you verify with build 1137 (if you haven’t already)?

Thanks,

Tom