#!/usr/bin/perl
use strict;
use warnings;
use GStreamer '-init';
use File::Spec;

my $file=shift;
die "usage : $0 file\n" unless -e $file;
$file=File::Spec->rel2abs($file);

my $player = GStreamer::ElementFactory->make(playbin2 => "player");

#does not hang if this callback is replaced by a simple : sub {warn "@_"}
$player->signal_connect(notify => sub {
	#warn "@_";
	my ($object,$property)=@_;
	my $name=$property->get_name;
	warn "$object $name : ".$object->get($name)."\n";
	});

$player->set(volume => 1);	#does not hang without this line

$player->set(uri => Glib::filename_to_uri($file, "localhost"));

warn "Playing: $file\n";

$player -> set_state("playing") or die "Could not start playing";
my $loop = Glib::MainLoop -> new(undef, 0);
$loop->run;

