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

  • SEARCH
  • Home
  • 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 7949379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:58:55+00:00 2026-06-04T01:58:55+00:00

I searched everywhere but I couldn’t find an answer for my problem. I play

  • 0

I searched everywhere but I couldn’t find an answer for my problem.

I play multiple sounds on my app and I let the user to adjust the volume with a button. So if the user wants, he can play with .5 volume. So I have this code:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Orchestra" ofType:@"mp3"];
theOrchestras = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error: NULL];
[theOrchestras play];

and to reduce the volume this:

- (IBAction) volumeReduced  {
    theOrchestras.volume = 0.5;
}

When the sounds is playing the volume is reduced, no problem. But when the sounds stops, and plays again, the volume always goes back to 1.

To fix this I tried to save the volume as an Integer, but for some reason the value is always 0, I couldn’t make it work:

.m

 int64_t * volumeSaved;

.h

- (IBAction) volumeReduced  {
    volumeSaved = .5;
}

NSString *path = [[NSBundle mainBundle] pathForResource:@"Orchestra" ofType:@"mp3"];
theOrchestras = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error: NULL];
theOrchestras.volume = volumeSaved;
[theOrchestras play];

But the audio now always plays with 0 volume, muted.

Is there any way to do this with a button?

Thanks!

  • 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-04T01:58:56+00:00Added an answer on June 4, 2026 at 1:58 am

    You’re declaring volumeSaved as a pointer to an integer instead of an integer, but then assigning to it like it’s an integer. That’s one oddity.

    But your real problem is that the volume property in AVAudioPlayer is a float, not a int64_t. So change the type to:

    float volumeSaved;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched everywhere but I couldn't find my answer, is there a way
Searched everywhere but couldn't find anything. My question is: is it possible to programmatically
Ive searched everywhere for this but cant find the answer. I have used the
I searched everywhere but didn't find the solution. I have image 1. How can
I searched everywhere but can't find it. So I'm asking it here. I want
I have searched everywhere but can't find a simple example of paging in MySQL
I've searched everywhere for this, but I can't seem to find a solution. Perhaps
Searched a lot about this problem but never found a answer, that solved it.
I searched type convertion table between PostgreSQL and C#, but I couldn't find anything.
I have looked everywhere but couldn't find it anywhere. I installed it successfully but

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.