- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Xcode 开发一个 iOS 应用程序。我还是编程新手。我试图在使用 AVPlayer
播放时设置音轨的音量。如果将时间设置为 kCMTimeZero
效果很好,但我希望它在按下按钮一秒后设置音量。
不工作
- (IBAction)maxVolButtonPressed:(id)sender {
[audioInputParams1 setVolume:1 atTime:time1];
[self applyAudioMix];
}
工作
- (IBAction)minVolButtonPressed:(id)sender {
[audioInputParams1 setVolume:0 atTime:kCMTimeZero];
[self applyAudioMix];
}
atTime
后要延迟一秒应该怎么写?
回答:好的,所以我想通了。您必须添加当前项目所在的时间。我使用时间间隔非常短的 setVolumeRampFromStartVolume 而不是 setVolume。由于某种原因,setVolume 逐渐淡化到给定的音量,我还没有弄明白为什么。它像这样对我有用:
CMTime time1 = CMTimeMake(1000, 1000); //2s
CMTime time2 = CMTimeMake(1001, 1000); //3s
CMTime timeCurrent = [player currentTime];
CMTime time1Added = CMTimeAdd(timeCurrent, time1);
CMTime time2Added = CMTimeAdd(timeCurrent, time2);
CMTimeRange fadeInTimeRange = CMTimeRangeFromTimeToTime(time1Added, time2Added);
[audioInputParams1 setVolumeRampFromStartVolume:0 toEndVolume:1 timeRange:fadeInTimeRange];
[self applyAudioMix];
最佳答案
你应该这样做:
- (IBAction)maxVolButtonPressed:(id)sender {
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(setVolume:) userInfo:nil repeats:NO];
}
- (void)setVolume:(id)sender{
[audioInputParams1 setVolume:1 atTime:kCMTimeZero];
[self applyAudioMix];
}
在第一种方法中,您说:WAITING 1 秒,然后调用方法 setVolume:。
关于ios - AVMutableAudioMixInputParameters setVolume atTime 仅适用于 kCMTimeZero,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16217715/
我正在尝试将多个音频文件与多个剪辑合并。我已成功添加多个视频,但我无法添加多个音频文件。我尝试了以下方式并收到错误“__NSArrayM insertObject:atIndex:]:对象不能为零”。
我正在使用 Xcode 开发一个 iOS 应用程序。我还是编程新手。我试图在使用 AVPlayer 播放时设置音轨的音量。如果将时间设置为 kCMTimeZero 效果很好,但我希望它在按下按钮一秒后
类AVMutableCompositionTrack的insertTimeRange:ofTrack:atTime:error:在iPhone(但不是模拟器)上返回NO且错误“无法完成操作”。错误消息
我用它来获取视频的预览缩略图: - (void)createThumb { NSInteger paddingLeft = 22; NSInteger paddingTop = 22; CGFloat
期待: 当 audioplayer.play(atTime: 1) 被调用时,定时器重置为 0,音频播放器在第 1 秒播放 现实: 我试过 delay = 0.000000001, 1, 100000
首先我必须说我喜欢这个论坛,它帮助了我很多时间。我有一个问题,但我在任何地方都找不到答案,所以这是我在这里的第一个问题。 我的问题是: 我有一个由 AVPlayerItem 表示的视频,用户可以使用将
我转换了 -(float) addNewValue:(float) newVal atTime:(double) time { 到 func addNewValue(newVal: CFloat, a
我是一名优秀的程序员,十分优秀!