我使用的是NSSound,我可以让声音正确地播放/暂停,但是由于某种原因,我不能让currentTime方法返回除0以外的任何值。
下面是我遇到问题的代码:
NSSound* sound = [[NSSound alloc] initWithContentsOfFile:@"path_to_sound.mp3" byReference:NO];
[sound play];
sleep(1);
NSLog(@"Current time: %f", [sound currentTime]);声音会播放,但NSLog始终返回零。有什么想法吗?
发布于 2012-07-24 15:22:15
默认情况下,NSSound使用默认的声音设备。您可以使用NSSound类的setPlaybackDeviceIdentifier:方法来更改输出设备。
查看用于获取声音输出设备的唯一标识符的this和how to get Audio Device UID to pass into NSSound's setPlaybackDeviceIdentifier:
发布于 2012-07-24 16:40:17
我没有一台机器来测试东西,但我希望你能从以下方面学到你需要的东西:
NSLog(@"Playback on %@, current time: %@ / %@",
[sound playbackDeviceIdentifier], [sound currentTime], [sound duration]);https://stackoverflow.com/questions/11624164
复制相似问题