使用system()函数在后台播放声音 [英] using system() function to play sound in the background

查看:383
本文介绍了使用system()函数在后台播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu做了一个游戏,其中我使用.wav文件在后台播放声音使用这个功能: -

i made a game in Ubuntu in which i use .wav files to play the sound in the background using this function:-

系统(canebrake-gtk-play -f file_path)

但是当播放声音时,整个游戏停止意味着动画停止,声音的完成,游戏正常开始正常....但这是为我创造了一个混乱,显示非常坏的影响,所以我想删除这个令人毛骨悚然的事情从我的游戏...所以任何帮助将是可感知的..
THANKX

But when the sound is played the whole game stops means the animation stops but after the completion of the sound , the game starts again normally....But this is creating a mess for me and showing a very bad impact , so i want to remove this creepy thing from my game ...so any help would be appreciable.. THANKX

推荐答案

这是一个快速而又脏的方式。

Here's a quick and dirty way.

pid_t pid = fork();

if (pid == 0) {
   system("canebrake-gtk-play -f file_path");
   exit(0);
}

您也可以使用线程代替另一个进程。

You could also use a thread instead of another process.

这篇关于使用system()函数在后台播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆