You are here

Add new comment

Tutorial : GStreamer audio player under Windows (Vala)

Objectives : play audio files in Windows, using GStreamer and Vala.

GStreamer is a GNOME-related cross-platform multimedia framework. It basically wraps underlying libraries (like mpg123, libx264...) to present an uniform GObject API to the fortunate developer.

I just added GStreamer and plugins packages to the ValaWinPKG repository. We will create a simple yet powerful audio player using these packages.

Prerequisites

If not already present, we'll install the latest Vala bundle for Windows and ValaWinPKG :

- vala-0.20.1_(GTK+-3.6.4)(TARNYKO).exe (74.4 Mb)
- ValaWinPKG_0.9.d.exe (7.76 Mb)

1) Install GStreamer and plugins

We run ValaWinPKG from the Windows start menu.
We then ckeck all GStreamer-related packages and click on "Update !".

PS : It may take some time, as it downloads a whole bunch of dependencies.

2) Compile the Vala code

We will compile the following source code.

The code itself should be self-explanatory ; the most important parts are :

pipeline  = ElementFactory.make ("playbin", "player");
pipeline.set ("uri", args[1]);

which creates a standard "playbin" element, and defines its URI (read : input file) to the first argument from the command line. And then :

pipeline.set_state (State.PLAYING);

starts playing this file.

We compile it using the command :
valac --pkg gstreamer-1.0 gstreamer-player.vala

3) Play an audio file

I tested my GStreamer build with all following formats : WAV, MP3, AAC, FLAC, AC3, OGG (Vorbis). They all worked :-).

We run the program using this type of command :
gstreamer-player.exe file:///C:/myaudiofile.mp3
(if your file is "C:\myaudiofile.mp3")

Here we go !

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.