<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8555848001448535652</id><updated>2012-02-16T16:39:44.362-08:00</updated><title type='text'>Mplayer Gtk Front End Code</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mymplayer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8555848001448535652/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mymplayer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>bince</name><uri>http://www.blogger.com/profile/16765466445064063285</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_zu6CN8Kp9hE/S3VUBObjhlI/AAAAAAAAACI/aFVnnXr7DjY/S220/n1851721029_6005.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8555848001448535652.post-3260869671050550090</id><published>2010-07-23T01:36:00.000-07:00</published><updated>2010-09-29T04:22:29.659-07:00</updated><title type='text'>Mplayer GTK Frontend Code</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;a href="https://sourceforge.net/projects/my-mplayer/"&gt;Download sourceforge code&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zu6CN8Kp9hE/TEljpglDkII/AAAAAAAAADg/Wp0sMXR_xiA/s1600/Screenshot.png"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_zu6CN8Kp9hE/TEljpglDkII/AAAAAAAAADg/Wp0sMXR_xiA/s320/Screenshot.png" alt="" id="BLOGGER_PHOTO_ID_5497034384953544834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hi every one,i am posting this blog regarding the making of an simple Mplayer GUI using pygtk,and i have made this code on Linux based platform(Ubuntu 10 to be exact).&lt;br /&gt;For those who want to compile Mplayer with hardware acceleration,i suggest that you check out the following blog&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.avirtualhome.com/2009/02/10/compile-mplayer-with-vdpau-support-on-ubuntu/"&gt;mplayer vdpau &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The above blog will tell you how to compile mplayer with nvidea hardware acceleration,after that go to the ubuntu software center and install bpython,and make sure that python 2.6 or higher is installed.&lt;/span&gt;       &lt;span style="font-size:100%;"&gt;&lt;br /&gt;I installed bpython to eliminate the need to install certain dependencies one by one,i am using a text editor to make the python codes for the mplayer interface.before continuing with coding,u must understand the basics of pygtk coding language,download the pygtk tutorial from the link below&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/www.pygtk.org/dist/pygtk2-tut.pdf%20%20"&gt;pygtk tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;screenshot:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_zu6CN8Kp9hE/TElkQbnyyxI/AAAAAAAAADo/Mgd39idT0K8/s1600/Screenshot-1.png"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_zu6CN8Kp9hE/TElkQbnyyxI/AAAAAAAAADo/Mgd39idT0K8/s320/Screenshot-1.png" alt="" id="BLOGGER_PHOTO_ID_5497035053637749522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Then create an new document and name it like "mplayer-gui" or something with an extension ".py"&lt;br /&gt;Those who are familier or tried to make an mplayer gui must have confused with the exact line of the code where we actually embeds the mplayer into the pygtk or python code,the code below adds an mplayer plugin into your pygtk file&lt;br /&gt;&lt;br /&gt;"           &lt;/span&gt;&lt;span style="font-size:100%;"&gt;Mplayer = Plugins.importAPI('Mplayer')" this line of code should be after all the import headers&lt;br /&gt;&lt;br /&gt;example:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;import gtk&lt;br /&gt;import sys&lt;br /&gt;import select&lt;br /&gt;import pygtk&lt;br /&gt;import gnome.ui&lt;br /&gt;import time&lt;br /&gt;import os&lt;br /&gt;from subprocess import Popen&lt;br /&gt;import screenlets&lt;br /&gt;from screenlets import DefaultMenuItem&lt;br /&gt;from screenlets.options import BoolOption, StringOption, FontOption, ListOption, IntOption,ColorOption&lt;br /&gt;from screenlets import Plugins&lt;br /&gt;import cairo&lt;br /&gt;import pango&lt;br /&gt;import commands&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Mplayer = Plugins.importAPI('Mplayer')&lt;br /&gt;&lt;br /&gt;this plugin works only if you have screenlets installed otherwise the compiler will show error in "import screenlet", so install screenlets from your synaptic manager.&lt;br /&gt;&lt;br /&gt;now that your code has mplayer plugin added,now you need a set of other lines of code to access the mplayer functions like the play,pause,stop etc&lt;br /&gt;use these following codes wherever you need to access the mplayer funcntionalities&lt;br /&gt;&lt;br /&gt;self.mplayer = Mplayer.Mplayer(self)&lt;br /&gt;self.mplayer.play(files)&lt;br /&gt;&lt;br /&gt;for example the play button when clicked on the mplayer gui will call a function play,which will have the above codes as well as the code to play the selected file&lt;br /&gt;example :&lt;br /&gt;&lt;br /&gt;def play(self,widget):&lt;br /&gt;self.mplayer = Mplayer.Mplayer(self)&lt;br /&gt;global files&lt;br /&gt;self.file_selected&lt;br /&gt;print files&lt;br /&gt;self.mplayer.play(files)&lt;br /&gt;print("Playing Video")&lt;br /&gt;&lt;br /&gt;dont get confuse by the "self.file_selected" i am calling an another function to acces the file explorer widget of pygtk,u will learn about it under filechooser in pygtk tutorial,you can alternativley use the files="/home/user/desktop/vedio.avi"  and use that path to play the file instead of using&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;        global files&lt;br /&gt;self.file_selected&lt;br /&gt;print files&lt;br /&gt;the "self.mplayer.play(files)" is used to play the file,where "files" contain the path of the vedio file,similary u can create functions for pause,stop,progressbar,volume control etc&lt;br /&gt;&lt;br /&gt;example:&lt;br /&gt;&lt;br /&gt;def play(self,widget):&lt;br /&gt;self.mplayer = Mplayer.Mplayer(self)&lt;br /&gt;global files&lt;br /&gt;self.file_selected&lt;br /&gt;print files&lt;br /&gt;self.mplayer.play(files)&lt;br /&gt;print("Playing Video")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def stop(self,widget):&lt;/span&gt;              &lt;span style="font-size:100%;"&gt;&lt;br /&gt;self.mplayer.close()&lt;br /&gt;print("Video Stopped")&lt;br /&gt;def pause(self,widget):&lt;br /&gt;self.mplayer.pause()&lt;br /&gt;print("Video Pause")&lt;br /&gt;def volume(self,widget,event):&lt;br /&gt;self.mplayer = Mplayer.Mplayer(self)&lt;br /&gt;volume='mplayer -af volume=70'&lt;br /&gt;self.mplayer.volume(volume)&lt;br /&gt;&lt;br /&gt;know this,untill and unless you  get a complete or general idea about pygtk and basic python scripting,you are going to keep on scratching your head,so leave the easy going mentality and read the pygtk tutorial,if u wanna get the idea about whats happening in this code :D&lt;br /&gt;&lt;br /&gt;and also visit the mplayer website to get the commandline codes for fullscreen,next,previous etc&lt;br /&gt;&lt;br /&gt;note that there is a lot of header files,imported tht i havent used yet,this is a work in progress,using this code you will get a start in your first step in makig a gui for mplayer in Linux&lt;br /&gt;&lt;br /&gt;here is the full code:&lt;br /&gt;&lt;br /&gt;##############################&lt;br /&gt;#                              #&lt;br /&gt;#author:Bince Mathew           #&lt;br /&gt;#                              #&lt;br /&gt;#e-mail:bincemathew@gmail.com  #&lt;br /&gt;#                              #&lt;br /&gt;##############################&lt;br /&gt;#install bpython via ubuntu software center,to get all the header files working&lt;br /&gt;import gtk&lt;br /&gt;import sys&lt;br /&gt;import select&lt;br /&gt;import pygtk&lt;br /&gt;import gnome.ui&lt;br /&gt;import time&lt;br /&gt;import os&lt;br /&gt;from subprocess import Popen&lt;br /&gt;import screenlets&lt;br /&gt;from screenlets import DefaultMenuItem&lt;br /&gt;from screenlets.options import BoolOption, StringOption, FontOption, ListOption, IntOption,ColorOption&lt;br /&gt;from screenlets import Plugins&lt;br /&gt;import cairo&lt;br /&gt;import pango&lt;br /&gt;import commands&lt;br /&gt;&lt;br /&gt;# importing the mplayer plugin into the code,make sure that you have installed screenlets via synaptic manager&lt;br /&gt;Mplayer = Plugins.importAPI('Mplayer')&lt;br /&gt;filechooser= gtk.FileChooserWidget()&lt;br /&gt;window1=gtk.Window()&lt;br /&gt;vediofile = gtk.Button("OK")&lt;br /&gt;&lt;br /&gt;files=""&lt;br /&gt;class mplayer:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def play(self,widget):&lt;br /&gt;  self.mplayer = Mplayer.Mplayer(self) &lt;br /&gt;  global files&lt;br /&gt;  self.file_selected&lt;br /&gt;  print files&lt;br /&gt;  self.mplayer.play(files)&lt;br /&gt;  print("Playing Video")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def stop(self,widget):&lt;br /&gt;  self.mplayer.close()&lt;br /&gt;  print("Video Stopped")&lt;br /&gt;def pause(self,widget):&lt;br /&gt;  self.mplayer.pause()&lt;br /&gt;  print("Video Pause")&lt;br /&gt;def volume(self,widget,event):&lt;br /&gt;  self.mplayer = Mplayer.Mplayer(self)&lt;br /&gt;  volume='mplayer -af volume=70'&lt;br /&gt;  self.mplayer.volume(volume)&lt;br /&gt;def openfile(self,widget):&lt;br /&gt;&lt;br /&gt;  window1.show_all()&lt;br /&gt;def file_selected(self, widget):&lt;br /&gt;  global files&lt;br /&gt;  window1.hide()&lt;br /&gt;      filenames = filechooser.get_filenames()&lt;br /&gt;      for filename in filenames:&lt;br /&gt;          print ("Selected filepath: %s" % filename)&lt;br /&gt;&lt;br /&gt;# -fs is for fullscreen mode,delete the  '-fs' if you dont wish to get the vedio in full screen mode     &lt;br /&gt;&lt;br /&gt;      files=filename&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def __init__(self):&lt;br /&gt;&lt;br /&gt;  #creating a new window with size 400x200&lt;br /&gt;  window1.set_default_size(400,200)&lt;br /&gt;&lt;br /&gt;  window=gtk.Window()&lt;br /&gt;  window.set_default_size(400,40)&lt;br /&gt;&lt;br /&gt;  #send_command=('mplayer')&lt;br /&gt;  hbox=gtk.HBox(False,5)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  #file chooser is an inbuilt widget in pygtk,to get the file explorer&lt;br /&gt;&lt;br /&gt;  self.filechooser = gtk.FileChooserWidget()&lt;br /&gt;      self.filechooser.set_select_multiple(True)&lt;br /&gt;  button = gtk.Button("OK")&lt;br /&gt;         button.set_size_request(80, -1)&lt;br /&gt;  window1.connect("destroy", lambda w: gtk.main_quit())&lt;br /&gt;  button.connect("clicked", self.file_selected)&lt;br /&gt;  vbox = gtk.VBox(False, 5)&lt;br /&gt;  window1.add(vbox)&lt;br /&gt;  vbox.pack_start(filechooser)&lt;br /&gt;  vbox.pack_end(button, False, False, 0)&lt;br /&gt;&lt;br /&gt;  volumebutton = gtk.VolumeButton()&lt;br /&gt;  volumebutton.set_value(0.5)&lt;br /&gt;  progressbar = gtk.ProgressBar()&lt;br /&gt;  tbtn=gtk.ToggleButton("Mute")&lt;br /&gt;  tbtn.set_active(True)&lt;br /&gt;  lable=gtk.Label("Enter starting time for playback")&lt;br /&gt;  Play=gtk.Button("PLAY")&lt;br /&gt;  Pause=gtk.Button("PAUSE")&lt;br /&gt;  Stop=gtk.Button("STOP")&lt;br /&gt;  Next=gtk.Button("Next")&lt;br /&gt;  txtbox=gtk.Entry()&lt;br /&gt;  txtbox.set_text("enter time")&lt;br /&gt;  Open=gtk.Button("Open")&lt;br /&gt;  window.add(hbox)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  hbox.pack_start(Play)&lt;br /&gt;  hbox.pack_start(Pause)&lt;br /&gt;  hbox.pack_start(Stop)&lt;br /&gt;  hbox.pack_start(Next)&lt;br /&gt;  hbox.pack_start(tbtn)&lt;br /&gt;  hbox.pack_start(Open)&lt;br /&gt;&lt;br /&gt;  hbox.pack_start(progressbar)&lt;br /&gt;  hbox.pack_start(volumebutton)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;  window.connect("destroy",lambda w:gtk.main_quit())&lt;br /&gt;  Play.connect("clicked",self.play) &lt;br /&gt;  Stop.connect("clicked",self.stop)&lt;br /&gt;  Pause.connect("clicked",self.pause)&lt;br /&gt;  Open.connect("clicked",self.openfile)&lt;br /&gt;&lt;br /&gt;  volumebutton.connect("value-changed",self.volume)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  #use this code if u want to import the gui design from a glade file&lt;br /&gt;          #builder = gtk.Builder()&lt;br /&gt;      #builder.add_from_file("mplayer.xml")&lt;br /&gt;      #builder.connect_signals({ "on_window_destroy" : gtk.main_quit })&lt;br /&gt;      #self.window = builder.get_object("mplayer")&lt;br /&gt;      #self.window.show()&lt;br /&gt;&lt;br /&gt;  window.show_all()&lt;br /&gt;&lt;br /&gt;mplayer()&lt;br /&gt;gtk.main()&lt;span style="color: rgb(102, 0, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;three things:&lt;br /&gt;1 learn basic python scritping&lt;br /&gt;2 Atleast read the pygtk tutorial pdf&lt;br /&gt;3 get all the dependencies installed&lt;br /&gt;&lt;br /&gt;save the above code in .py format and compile it in console via python,make sure that you are in the same folder of your code file to compile it via python in console,example "python mplayer.py" this will compile the code and bring the gui,if all dependencies are installed the mplayer gui will emerge,i will post modified codes of my project as it progress,everyone is welcome in modifiying this code,if possible send me the modified code to bincemathew@gmail.com.&lt;br /&gt;so that we both can benefit from each others knowledge :D&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8555848001448535652-3260869671050550090?l=mymplayer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mymplayer.blogspot.com/feeds/3260869671050550090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mymplayer.blogspot.com/2010/07/mplayer-front-end-gui-code.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8555848001448535652/posts/default/3260869671050550090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8555848001448535652/posts/default/3260869671050550090'/><link rel='alternate' type='text/html' href='http://mymplayer.blogspot.com/2010/07/mplayer-front-end-gui-code.html' title='Mplayer GTK Frontend Code'/><author><name>bince</name><uri>http://www.blogger.com/profile/16765466445064063285</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_zu6CN8Kp9hE/S3VUBObjhlI/AAAAAAAAACI/aFVnnXr7DjY/S220/n1851721029_6005.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zu6CN8Kp9hE/TEljpglDkII/AAAAAAAAADg/Wp0sMXR_xiA/s72-c/Screenshot.png' height='72' width='72'/><thr:total>2</thr:total></entry></feed>
