2部分问题:
我只是试图使用终端上的AppleScript来运行程序,所以我尝试了:
$ osascript tell application "iTunes" to activate
Run Code Online (Sandbox Code Playgroud)
并得到错误:
osascript: tell: No such file or directory
Run Code Online (Sandbox Code Playgroud)
提供该计划的完整途径也不起作用.我错过了什么?问题的第二部分是我最终想要使用applescript的内容.我想用它来打开我使用py2app构建的应用程序.Apple可以打开任何mac应用程序或只是已经兼容的某些应用程序.
谢谢
我正在尝试使用AVMutableComposition在精确的时间播放一系列声音文件.
当视图加载时,我创建合成,目的是在1秒内均匀地播放4个声音.声音的长短不应该无关紧要,我只想在0,0.25,0.5和0.75秒时将它们发射:
AVMutableComposition *composition = [[AVMutableComposition alloc] init];
NSDictionary *options = @{AVURLAssetPreferPreciseDurationAndTimingKey : @YES};
for (NSInteger i = 0; i < 4; i++)
{
AVMutableCompositionTrack* track = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
NSURL *url = [[NSBundle mainBundle] URLForResource:[NSString stringWithFormat:@"sound_file_%i", i] withExtension:@"caf"];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:options];
AVAssetTrack *assetTrack = [asset tracksWithMediaType:AVMediaTypeAudio].firstObject;
CMTimeRange timeRange = [assetTrack timeRange];
Float64 t = i * 0.25;
NSError *error;
BOOL success = [track insertTimeRange:timeRange ofTrack:assetTrack atTime:CMTimeMakeWithSeconds(t, 1) error:&error];
if (!success)
{
NSLog(@"unsuccesful creation of composition");
} …Run Code Online (Sandbox Code Playgroud) core-audio avfoundation ios avcomposition avmutablecomposition