0

I try to play sound file using C++ in Ubuntu. I can compile this code in terminal with g++ play.cpp -o play line. It can be compiled well, but when I execute it with ./play , it says Failed to play sound: File or data corrupt . I cannot find where is the problem. Here is my code;

#include <iostream>
#include <stdlib.h>

int main()
{
  system("canberra-gtk-play -f cow.wav");
  return 0;
}
noname59
  • 107
  • 1
  • 10

1 Answers1

2

The output Failed to play sound: File or data corrupt comes from the canberra player launched by your system call and is not a consequence to a problem in your program.

This could mean that this specific file is indeed corrupt. I suggest to download a different example file. The files provided here are playing fine for me.

Using 'exiftool cow.wav' might give you more information on what the problem with the file is.

Patrik H
  • 459
  • 2
  • 8