# USAGE: gst-crash.py a.mp3

import gi
import sys
import os

gi.require_version("Gst", "1.0")
from gi.repository import Gst, GLib

def stop_playbin(element):
    element.set_state(Gst.State.NULL)
    return False

def create_playbin(uri):
    element = Gst.ElementFactory.make("playbin", None)
    print(element)
    element.props.uri = uri
    element.set_state(Gst.State.PLAYING)
    GLib.idle_add(stop_playbin, element)
    return True

def main(argv):
    Gst.init(None)
    loop = GLib.MainLoop()
    uri = GLib.filename_to_uri(os.path.abspath(argv[1]), None)
    GLib.idle_add(create_playbin, uri)
    loop.run()

main(sys.argv)
