小编rom*_*her的帖子

Spritekit停止声音

我目前正在使用Apple的SpriteKit库开发游戏,但是在开始播放之后我无法停止声音.我已经尝试使用文档中列出的方法来阻止Skaction运行,但似乎没有任何东西阻止播放声音.这些是我试图阻止声音的尝试.

//Playing sound action:

SKAction *music = [SKAction playSoundFileNamed:@"menu.wav" waitForCompletion:YES];
    [musicNode runAction:[SKAction repeatActionForever:[SKAction sequence:@[
                                                    music,
                                                    [SKAction waitForDuration:0],
                                                    ]]] withKey:@"MUSIC_PLAYING"];

//Later when i want to stop the sound:

[musicNode removeActionForKey:@"MUSIC_PLAYING"]; //Removing the action from the node
[musicNode runAction:[SKAction waitForDuration:0] withKey:@"MUSIC_PLAYING"]; //"Overriding" with another action with the same key
[musicNode removeAllActions]; //Removing all actions from the node
[musicNode removeFromParent]; //Removing the node from the parent
Run Code Online (Sandbox Code Playgroud)

musicNode只是一个运行动作的SkpriteNode,虽然我直接从场景中尝试了相同的方法,即:场景播放声音,然后尝试删除它.或者,由于waitForCompletion设置为YES,动作不会停止,但是再次尝试使用NO和相同的结果.有没有办法使用AVaudioSession的sharedInstante来停止声音?我也试过以下方法但也失败了:

 [[AVAudioSession sharedInstance]setActive:FALSE error:nil];
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!

audio avaudiosession sprite-kit skaction

5
推荐指数
1
解决办法
2444
查看次数

Bash pwd并打开管道不工作

我正在学习如何在bash中使用I/O重定向,并尝试使用管道的一些示例:

pwd | say
ls -l | grep "staff" > out.txt
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用两者pwdopen使用管道重定向时,命令失败,我只是收到open使用情况.

我正在尝试的是: pwd | open

从bash打开当前目录的正确方法是什么?

unix macos bash terminal

2
推荐指数
2
解决办法
510
查看次数

标签 统计

audio ×1

avaudiosession ×1

bash ×1

macos ×1

skaction ×1

sprite-kit ×1

terminal ×1

unix ×1