Giter Club home page Giter Club logo

Comments (8)

aareeph avatar aareeph commented on June 29, 2024

Also, the BOOL finished variable is returning false.

from cephalopod.

evgenyneu avatar evgenyneu commented on June 29, 2024

Hello @aareeph, thanks for reporting. I have just tested Cephalopod with ObjC for the first time, and it seems to work for me. Please see the sample project attached.

UsingCephalopodInObjC.zip

ViewController.h

@interface ViewController : UIViewController

@property (strong, nonatomic) AVAudioPlayer *audioPlayer;
@property (strong, nonatomic) Cephalopod *cep;

@end

ViewController.m

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  NSError *error;
  NSString *soundFilePath = [NSString stringWithFormat:@"%@/squid.mp3",
                             [[NSBundle mainBundle] resourcePath]];
  NSURL *url = [NSURL fileURLWithPath:soundFilePath];
  self.audioPlayer = [[AVAudioPlayer alloc]
                      initWithContentsOfURL:url
                      error:&error];
  NSLog(@"Error %@",error);
  [self.audioPlayer prepareToPlay];
  [self.audioPlayer play];

  self.cep = [[Cephalopod alloc] initWithPlayer:self.audioPlayer];

  [self.cep fadeFromVolume:0 toVolume:1 duration:2 velocity:2 onFinished:^(BOOL finished) {
    if (finished) {
      NSLog(@"Fading Done Finished");
    } else {
      NSLog(@"Fading Done NOT finished");
    }
  }];
}

@end

Let me know how it goes.

from cephalopod.

aareeph avatar aareeph commented on June 29, 2024

Hello @evgenyneu you're awesome. It worked very well for me. Here is the problematic line in my code. I was creating the object in the method instead of making it a strong nonatomic property.

Cephalopod *cep = [[Cephalopod alloc] initWithPlayer:self.BackgroundMusicPlayer];

Your library is also amazing.

Thanks!
Arif

from cephalopod.

evgenyneu avatar evgenyneu commented on June 29, 2024

No worries, good luck with everything.

from cephalopod.

aareeph avatar aareeph commented on June 29, 2024

Hi, me again :)

I need your suggestion regarding the following method. In my case I am creating an Audio Player that has Play/Pause toggle button. If the user continuously tap on this button while the fading effect is in progress eventually the sound goes off. Repeatedly pausing/resuming the audio isn’t typical user behavior but I would like to know if there's any method in the SDK that invalidates the following method so I can call it on Pause.

[self.cep fadeFromVolume:1 toVolume:0 duration:5 velocity:2 onFinished:^(BOOL finished) {
if (finished) {
NSLog(@"Fading Done Finished");
} else {
NSLog(@"Fading Done NOT finished");
}
}];

What do you suggest?

Thanks!

from cephalopod.

evgenyneu avatar evgenyneu commented on June 29, 2024

Hi @aareeph, good question. Yes, there is a stop() method that cancells the ongoing volume change. Thank you for bringing this up, I just realized that I forgot to mention this method in the readme. Let me know if it works for you.

from cephalopod.

aareeph avatar aareeph commented on June 29, 2024

Hi @evgenyneu it worked very well for me. Thanks!

from cephalopod.

evgenyneu avatar evgenyneu commented on June 29, 2024

Awesome πŸ‘

from cephalopod.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.