Comments (8)
Also, the BOOL finished variable is returning false.
from cephalopod.
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.
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.
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.
No worries, good luck with everything.
from cephalopod.
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.
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.
Hi @evgenyneu it worked very well for me. Thanks!
from cephalopod.
Awesome π
from cephalopod.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cephalopod.