-
-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathViewController.m
More file actions
94 lines (75 loc) · 2.66 KB
/
Copy pathViewController.m
File metadata and controls
94 lines (75 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Created by Jesse Squires
// https://www.jessesquires.com
//
//
// Documentation
// https://jessesquires.github.io/JSQSystemSoundPlayer
//
//
// GitHub
// https://github.com/jessesquires/JSQSystemSoundPlayer
//
//
// License
// Copyright © 2013-present Jesse Squires
// Released under an MIT license: https://opensource.org/licenses/MIT
//
#import "ViewController.h"
#import <JSQSystemSoundPlayer/JSQSystemSoundPlayer.h>
@implementation ViewController
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.soundSwitch.on = [JSQSystemSoundPlayer sharedPlayer].on;
}
#pragma mark - Actions
- (IBAction)playPredefinedSoundPressed:(UIButton *)sender
{
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];
[sharedPlayer playSoundWithSoundID:1000 // new mail sound
asAlert:YES
completion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
}
- (IBAction)playSystemSoundPressed:(UIButton *)sender
{
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];
[sharedPlayer playSoundWithFilename:@"Basso"
fileExtension:kJSQSystemSoundTypeAIF
completion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
}
- (IBAction)playAlertSoundPressed:(UIButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:@"Funk"
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil];
}
- (IBAction)playVibratePressed:(UIButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] playVibrateSound];
}
- (IBAction)playLongSoundPressed:(UIButton *)sender
{
NSLog(@"Playing long sound...");
[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:@"BalladPiano"
fileExtension:kJSQSystemSoundTypeCAF
completion:^{
NSLog(@"Long sound complete!");
}];
}
- (IBAction)stopPressed:(UIButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] stopAllSounds];
// Stop playing specific sound
// [[JSQSystemSoundPlayer sharedPlayer] stopSoundWithFilename:@"BalladPiano"];
}
- (IBAction)toggleSwitch:(UISwitch *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] toggleSoundPlayerOn:sender.on];
}
@end