Using Omxplayer And System

This will play an audio file but it won’t return until playing is complete.

#include <stdlib.h>

	system("omxplayer /home/pi/projects/my_project/audio/my_audio.wav");


Play On A Background Thread

This will trigger omxplayer on a separate thread and return immediately so your program execution doesn’t stall until the file has finished playing.   You can even use this multiple times and have multiple instances of omxplayer playing on top of each other.

	int pid;
		//printf("I am the child\n");
		execlp("/usr/bin/omxplayer", " ", "/home/pi/projects/my_project/audio/my_file.wav", NULL);		//Execute file: file, arguments (1 or more strings followed by NULL)
		//printf("I am the parent\n");
Closing Player On Background Thread

	system("killall omxplayer.bin");

Adjusting Playback Of Omxplayer On A Background Thread




We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


  1. Prasan Dutt

    9 years ago

    Really helped the closing player command. I can play multiple audio files using this command.


Your email address will not be published. Required fields are marked *