123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // YOUPAILZAudioPlayer.m
- // VQU
- //
- // Created by CY on 2021/9/22.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZAudioPlayer.h"
- static YOUPAILZAudioPlayer *instance = nil;
- @implementation YOUPAILZAudioPlayer
- + (instancetype)sharedInstance {
-
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- instance = [[YOUPAILZAudioPlayer alloc] init];
- });
- return instance;
- }
- - (instancetype)init {
-
- self = [super init];
- if (!self) {
- return nil;
- }
- [self youpaifinitPlayer];
- return self;
- }
- - (void)youpaifinitPlayer {
-
- [self.youpaipplayer prepareToPlay];
- }
- - (AVAudioPlayer *)youpaipplayer {
-
- if (!_youpaipplayer) {
- NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"SomethingJustLikeThis" withExtension:@"mp3"];
- AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
- audioPlayer.numberOfLoops = NSUIntegerMax;
- _youpaipplayer = audioPlayer;
- }
- return _youpaipplayer;
- }
- @end
|