Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:42:26+00:00 2026-06-18T07:42:26+00:00

I have two AVAudioPlayers, called ‘node’ and ‘zone’. They will sometimes be playing at

  • 0

I have two AVAudioPlayers, called ‘node’ and ‘zone’. They will sometimes be playing at the same time. When this happens I need to volume of ‘zone’ to fall to 0.2. When ‘node’ finishes, I need ‘zone’ to be returned to it’s original volume (pulled in from an array). I have an adjustPlayerVolume method and another method that sets a ‘nodeIsPlaying’ variable to false when the node has finished. both of these work fine.

the following code is being used to detect if the volume needs to go up or down or be left as it is. It is within a loop that runs for as long as the app is running.

            NSLog(@"Zone Volume = %f", zonePlayer.volume);

            if ((nodeIsPlaying == false) && (zonePlayer.volume <= 0.200000)) {
                float maxVolume = [[[locationArray objectAtIndex:1] valueForKey:@"volume"] floatValue];
                [self adjustZoneVolume:maxVolume];
                NSLog(@"adjustZoneVolume called, node isn't playing and zonePlayer volume needs to be raised");
            }

            if ((nodeIsPlaying == true) && (zonePlayer.volume != 0.200000)) {

                float maxVolume = 0.2;
                [self adjustZoneVolume:maxVolume];
                NSLog(@"adjustZoneVolume called, node is playing and zonePlayer volume needs to be lowered");

            }

The log at the top consistently prints a volume of 0.200000 to the console.

When nodeIsPlaying is set to true, the bottom condition is returned, even though the NOT operator should prevent this from happening.

When nodeIsPlaying is set to false, nothing happens.

So there is something wrong with the <= and != operations.

Probably something really stupid…

Any ideas?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:42:27+00:00Added an answer on June 18, 2026 at 7:42 am

    For precision operations use NSDecimalNumber class.

    NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithDecimal:[[NSNumber numberWithFloat:zonePlayer.volume] decimalValue]];
    NSDecimalNumber *number2 = [NSDecimalNumber decimalNumberWithDecimal:[[NSNumber numberWithFloat:0.2f] decimalValue]];
    NSComparisonResult comparisonResult = [number compare:number2];
    
    if ((nodeIsPlaying == false) && (comparisonResult == NSOrderedSame || comparisonResult == NSOrderedDescending)) {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns say Main and Sub . (they can be of same
Have two tables say ABC and XYZ and contain one column which data will
We have two major release branches - 'stable' and 'beta'. Over time, the 'beta'
I have two records with the same fields and one of them has a
I have two gridView the same size. How to do synchronous scrolling. Could I
I have two models, one called Notes and one called Comments. Comments can be
I have two columns, the first column will have the name of a object,
I have two different objects of same entity Community And two objects(community and com)
I have two tables that have the same structure, I need a query to
I have two DataGridViews that have the same column schema (although two different DataViews

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.