英文:
How can I remove swift process message
问题
以下是您提供的代码的翻译部分:
每当我运行以下代码时,声音播放得很好,但它总是在控制台打印一些内容。
代码:
```swift
let path = Bundle.main.bundlePath
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = ["afplay", path]
let _ = try? task.run()
task.waitUntilExit()
控制台消息:
2023年5月7日 01:18:05.779125+0200 afplay[7755:301446] [plugin] AddInstanceForFactory: 没有为ID注册工厂<CFUUID 0x60000020c1c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2023年5月7日 01:18:05.799089+0200 afplay[7755:301446] [aqme] MEMixerChannel.cpp:1636 客户端<AudioQueueObject@0x10100f200; [0]; play> 在发送格式信息时出现错误2003332927
2023年5月7日 01:18:06.554636+0200 afplay[7755:301448] [aqme] MEMixerChannel.cpp:1636 客户端<AudioQueueObject@x10100f200; [0]; play> 在发送格式信息时出现错误2003332927
您处于第一层生成
我已经提供了您要求的翻译部分,没有包含其他内容。
英文:
Whenever I run the following code, a sound is played perfectly fine but it always prints something to the console.
code:
let path = Bundle.main.bundlePath
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = ["afplay", path]
let _ = try? task.run()
task.waitUntilExit()
console message:
2023-05-07 01:18:05.779125+0200 afplay[7755:301446] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000020c1c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2023-05-07 01:18:05.799089+0200 afplay[7755:301446] [aqme] MEMixerChannel.cpp:1636 client <AudioQueueObject@0x10100f200; [0]; play> got error 2003332927 while sending format information
2023-05-07 01:18:06.554636+0200 afplay[7755:301448] [aqme] MEMixerChannel.cpp:1636 client <AudioQueueObject@0x10100f200; [0]; play> got error 2003332927 while sending format information
You are in First Layer spawn
I've tried clearing the terminal by running a different process with launchPath /usr/bin/clear
but it still doesn't work
答案1
得分: 0
Setting task.standardOutput
和 task.standardError
为 nil
在调用 task.run()
之前,我认为会导致子进程输出到 stdout 和 stderr 的任何内容被忽略。
英文:
Setting task.standardOutput
and task.standardError
to nil
before calling task.run()
, I think will cause anything the subprocess outputs to stdout and stderr to be ignored.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论