YunMusicSoundEffectVC.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // YunMusicSoundEffectVC.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 16/11/14.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "YunMusicSoundEffectVC.h"
  9. @interface YunMusicSoundEffectVC ()<UIGestureRecognizerDelegate>
  10. @end
  11. @implementation YunMusicSoundEffectVC
  12. - (void)viewDidLoad
  13. {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view from its nib.
  16. [self loadTapGes];
  17. //旋转 90
  18. self.bgm_Slider.transform = CGAffineTransformMakeRotation(-M_PI/2);
  19. self.mic_Slider.transform = CGAffineTransformMakeRotation(-M_PI/2);
  20. [self setMicSlider];
  21. [self setBgmSlider];
  22. [self addEffectOfFrostedGlassOnView:_soundEffect_BG_View
  23. effectType:0];
  24. }
  25. #pragma mark - 设置 bgm Slider
  26. - (void)setBgmSlider{
  27. _bgm_Slider.minimumValue = 0.0;////设置最小数
  28. _bgm_Slider.maximumValue = 2.0;///腾讯默认人声为1 0-2
  29. _bgm_Slider.value = _bgmNowValue_CGFloat;//设置起始位置
  30. _bgm_Slider.backgroundColor = [UIColor clearColor];//设置背景颜色
  31. [_bgm_Slider addTarget:self
  32. action:@selector(updateBGMValue)
  33. forControlEvents:UIControlEventValueChanged];
  34. }
  35. - (void)updateBGMValue{
  36. self.bgmNowValue_CGFloat = self.bgm_Slider.value;
  37. //调代理
  38. if([_delegate respondsToSelector:@selector(setBGMValue:)]){
  39. [_delegate setBGMValue:_bgmNowValue_CGFloat];
  40. }
  41. }
  42. #pragma mark - 设置 Mic Slider
  43. - (void)setMicSlider{
  44. _mic_Slider.minimumValue = 0.0;////设置最小数
  45. _mic_Slider.maximumValue = 2.0;///腾讯默认人声为1 0-2
  46. _mic_Slider.value = _micNowValue_CGFloat;//设置起始位置
  47. _mic_Slider.backgroundColor = [UIColor clearColor];//设置背景颜色
  48. [_mic_Slider addTarget:self action:@selector(updateMicValue) forControlEvents:UIControlEventValueChanged];
  49. }
  50. - (void)updateMicValue{
  51. self.micNowValue_CGFloat = self.mic_Slider.value;
  52. //调代理
  53. if([_delegate respondsToSelector:@selector(setMicValue:)]){
  54. [_delegate setMicValue:_micNowValue_CGFloat];
  55. }
  56. }
  57. #pragma mark - 创建 直播上音效界面
  58. +(YunMusicSoundEffectVC *)showYunMusicSoundEffectVCInVC:(UIViewController *)vc inView:(UIView *)view showFrame:(CGRect)showFrame oldBGMValue:(CGFloat)oldBGMValue oldMicValue:(CGFloat)oldMicValue {
  59. YunMusicSoundEffectVC *soundEffect_VC = [[YunMusicSoundEffectVC alloc]initWithNibName:@"YunMusicSoundEffectVC"
  60. bundle:nil];
  61. // [vc addChild:soundEffect_VC container:soundEffect_VC.view inRect:showFrame animation:^{
  62. // [UIView animateWithDuration:1
  63. // animations:^{
  64. // soundEffect_VC.view.transform = CGAffineTransformMakeTranslation(0, -soundEffect_VC.view.size.height);
  65. // }
  66. //
  67. // completion:^(BOOL finished) {
  68. //
  69. // }];
  70. // }];
  71. // TCShowReLiveViewController *reLive_VC =(TCShowReLiveViewController*) vc;
  72. [vc addChild:soundEffect_VC];
  73. [vc.view addSubview:soundEffect_VC.view];
  74. soundEffect_VC.view.frame =showFrame;
  75. soundEffect_VC.recoedLiveController = (BGTLiveController *)vc;
  76. //动画
  77. // [UIView animateWithDuration:1
  78. // animations:^{
  79. // soundEffect_VC.view.transform = CGAffineTransformMakeTranslation(0, -soundEffect_VC.view.size.height);
  80. // }
  81. // completion:^(BOOL finished) {
  82. //
  83. // }];
  84. // [UIView animateWithDuration:1 animations:^{
  85. // soundEffect_VC.view.transform = CGAffineTransformMakeTranslation(0, -soundEffect_VC.view.size.height);
  86. // }];
  87. soundEffect_VC.bgmNowValue_CGFloat = oldBGMValue;
  88. soundEffect_VC.micNowValue_CGFloat = oldMicValue;
  89. soundEffect_VC.bgm_Slider.value = oldBGMValue;
  90. soundEffect_VC.mic_Slider.value = oldMicValue;
  91. return soundEffect_VC;
  92. }
  93. #pragma mark - 点击X 关闭
  94. - (IBAction)removeFromReliveVC:(UIButton *)sender {
  95. // if([_delegate respondsToSelector:@selector(removeYunMusicSoundEffectVC)]){
  96. // [_delegate removeYunMusicSoundEffectVC];
  97. // }
  98. [self removeYunMusicSoundEffectViewController];
  99. }
  100. #pragma mark - 还原slider value
  101. - (IBAction)recoverDefaultSliderValue:(UIButton *)sender {
  102. _bgm_Slider.value = 1.0;
  103. _mic_Slider.value = 1.0;
  104. [self updateBGMValue];
  105. [self updateMicValue];
  106. }
  107. #pragma nark -高斯处理 (笔记已经扩展3种)
  108. - (void)addEffectOfFrostedGlassOnView:(UIView *)bgView
  109. effectType:(NSInteger)type{
  110. UIBlurEffect *effect = [UIBlurEffect effectWithStyle:type];
  111. UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
  112. effectView.frame =CGRectMake(0, 0,bgView.bounds.size.width,bgView.bounds.size.height);
  113. //bgView.alpha = 0.5;
  114. [bgView addSubview:effectView];
  115. }
  116. - (void)didReceiveMemoryWarning {
  117. [super didReceiveMemoryWarning];
  118. // Dispose of any resources that can be recreated.
  119. }
  120. #pragma mark - gets
  121. - (void)loadTapGes{
  122. _tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self
  123. action:@selector(removeYunMusicSoundEffectViewController)];
  124. _tapGes.delegate =self;
  125. [self.bgView addGestureRecognizer:_tapGes];
  126. }
  127. - (void)removeYunMusicSoundEffectViewController{
  128. if (self&&self.recoedLiveController) {
  129. [self.recoedLiveController removeChild:self];
  130. [self.view removeFromSuperview];
  131. }
  132. }
  133. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
  134. shouldReceiveTouch:(UITouch *)touch{
  135. if (![touch.view isDescendantOfView:self.bgView]) {
  136. return NO;
  137. }
  138. return YES;
  139. }
  140. @end