123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- //
- // JXStartSoundView.m
- // shiku_im
- //
- // Created by 123 on 2020/6/12.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXStartSoundView.h"
- @interface JXStartSoundView()
- @end
- @implementation JXStartSoundView
- -(instancetype)initWithFrame:(CGRect)frame{
-
- if (self=[super initWithFrame:frame]) {
-
-
- }
-
- return self;
- }
- -(void)createSoundStrUrl2:(NSString *)strURl valueInt:(int )value{
-
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];///横向移动
-
- animation.toValue = [NSNumber numberWithInt:value];
-
- animation.duration = .5;
-
- animation.removedOnCompletion = YES;//yes的话,又返回原位置了。
-
- animation.repeatCount = 2;
- animation.fillMode = kCAFillModeForwards;
- //抖一抖铃声
- //播放音效
-
- NSError *error = nil;
- NSURL *moveMP3=[NSURL fileURLWithPath:[[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"抖一抖铃声.mp3"]];
- _player=[[AVAudioPlayer alloc]initWithContentsOfURL:moveMP3 error:&error];
- [self.player prepareToPlay];
-
-
- [self.player play];
-
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
- AudioServicesPlaySystemSound(1521);
- [g_window.layer addAnimation:animation forKey:nil];
-
-
- }
- -(void)createSoundStrUrl2:(NSString *)strURl messageText:(UITextView *)messageText valueInt:(int )value{
-
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];///横向移动
-
- animation.toValue = [NSNumber numberWithInt:value];
-
- animation.duration = .5;
-
- animation.removedOnCompletion = YES;//yes的话,又返回原位置了。
-
- animation.repeatCount = 2;
- animation.fillMode = kCAFillModeForwards;
- //抖一抖铃声
- //播放音效
-
- NSURL *url = [NSURL fileURLWithPath:strURl];
- NSError *error = nil;
- _player=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
-
- [self.player prepareToPlay];
-
-
- [self.player play];
- // 添加振动
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
- AudioServicesPlaySystemSound(1521);
- [messageText.inputView.superview.layer addAnimation:animation forKey:nil];
- [g_window.layer addAnimation:animation forKey:nil];
-
-
- }
- +(void)createSoundStrUrl:(NSString *)strURl valueInt:(int )value{
-
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];///横向移动
-
- animation.toValue = [NSNumber numberWithInt:value];
-
- animation.duration = .5;
-
- animation.removedOnCompletion = YES;//yes的话,又返回原位置了。
-
- animation.repeatCount = 2;
- animation.fillMode = kCAFillModeForwards;
- //抖一抖铃声
- //播放音效
-
-
-
- SystemSoundID soundID;
- NSURL *filePath = [NSURL fileURLWithPath:strURl isDirectory:NO];
- AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
- AudioServicesPlaySystemSound(soundID);
- // 添加振动
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
- AudioServicesPlaySystemSound(1521);
- [g_window.layer addAnimation:animation forKey:nil];
-
-
- }
- +(void)createSoundStrUrl:(NSString *)strURl messageText:(UITextView *)messageText valueInt:(int )value{
-
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];///横向移动
-
- animation.toValue = [NSNumber numberWithInt:value];
-
- animation.duration = .5;
-
- animation.removedOnCompletion = YES;//yes的话,又返回原位置了。
-
- animation.repeatCount = 2;
- animation.fillMode = kCAFillModeForwards;
- //抖一抖铃声
- //播放音效
- SystemSoundID soundID;
- NSURL *filePath = [NSURL fileURLWithPath:strURl isDirectory:NO];
- AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
- AudioServicesPlaySystemSound(soundID);
- // 添加振动
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
- AudioServicesPlaySystemSound(1521);
- [messageText.inputView.superview.layer addAnimation:animation forKey:nil];
- [g_window.layer addAnimation:animation forKey:nil];
-
-
- }
- -(void)setStrURL:(NSString *)strURL{
-
- [self.player pause];
- [self.player stop];
- }
- @end
|