Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 17 Apr 2014, 03:12
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to embed VLC playback windows in Gtkdialog!
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
sc0ttman


Joined: 16 Sep 2009
Posts: 2363
Location: UK

PostPosted: Fri 31 Aug 2012, 07:16    Post subject:  How to embed VLC playback windows in Gtkdialog!
Subject description: (or embed VLC in other windows, generally...)
 

You can use the --drawable-xid option in VLC to embed it into other windows...

You just need to give the window ID, which you get using 'xwininfo'.

Here is an example script 'vlc_embed'. It embeds playback of the given into a gtkdialog window:

Code:
#!/bin/bash

# save this code as vlc_embed

gtkdialog -s <<< '<window title="VLC Playback" width-request="640" height-request="480">
<vbox>
<button><action>killall vlc</action><action type="exit">EXIT_NOW</action></button>
</vbox>
</window>' &
sleep 2

OSC_WID="$(xwininfo -name "VLC Playback" | grep -m1 'Window id: ' | cut -f4 -d' ')"

vlc -I dummy --drawable-xid  $OSC_WID "$@" &

exit 0


Usage of the above:

vlc_embed /path/to/file.avi

EDIT: No idea how to send playback control to VLC once its embedded thoough...

If anyone knows how I can send play/stop/next/prev/fullscreen/etc commands to VLC when it's embedded, I will be VERY grateful!

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2363
Location: UK

PostPosted: Sat 01 Sep 2012, 07:03    Post subject:  

Here is how you add controls:

Essentially, use this option with vlc:

--extraintf rc --rc-host localhost:123

VLC will then listen on localhost:123 for commands...

Then you can send the VLC commands to localhost:123, like so:

echo pause | nc localhost 123

(where 'pause' is any valid VLC playback command)

Here is a simple script, save it as 'vlc_embed', make it exec, and run like so:

./vlc_embed "path/to/file"

Code:
#!/bin/bash

gtkdialog -s <<< '<window title="VLC Controls" width-request="600" height-request="450">
<vbox>
<button><label>Play/Stop</label><action>echo pause | nc localhost 123</action></button>
<button><label>Quit</label><action>echo quit | nc localhost 123</action><action type="exit">EXIT_NOW</action></button>
</vbox>
</window>' &
sleep 1

OSC_WID="$(xwininfo -name "VLC Controls" | grep -m1 'Window id: ' | cut -f4 -d' ')"
echo OSC_WID = $OSC_WID
export OSC_WID
vlc --extraintf rc --rc-host localhost:123 --drawable-xid  $OSC_WID "$@"
exit 0

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2363
Location: UK

PostPosted: Fri 13 Sep 2013, 04:06    Post subject:  

Updated: supports playback of files and dirs...

Save the code as a script:

Code:
#!/bin/bash

cd /mnt
[ "$1" = "" ] && FILE="$(Xdialog --stdout --title 'Choose a file' --fselect /mnt 0 0)" || FILE="$@"

if [ -e "$FILE" ];then

echo 'style "vlc_embed"
{ bg[NORMAL]      = "#000000"
  fg[NORMAL]        = "#000000"
  base[NORMAL]      = "#ffffff" 
  text[NORMAL]      = "#ffffff"
}
class "GtkButton" style "vlc_embed"
class "*" style "vlc_embed"' > /tmp/gtkrc
#export GTK2_RC_FILES=/tmp/gtkrc:/root/.gtkrc-2.0 ## uncomment to change the theme of the gtkdialog window

   if [ -d "$FILE" ];then
      FILE="`find "$FILE" -maxdepth 1`"
      echo "$FILE" > /tmp/vlc_embed_playlist.m3u
      FILE=/tmp/vlc_embed_playlist.m3u
   fi

   echo "$FILE"
   gtkdialog -s <<< '<window title="VLC Controls" width-request="520" height-request="350">
      <vbox>
         <hbox height-request="28">
            <button><input file stock="gtk-media-previous"></input><label>Prev</label><action>echo prev | nc localhost 12345</action></button>
            <button><input file stock="gtk-media-play"></input><label>Play/Stop</label><action>echo pause | nc localhost 12345</action></button>
            <button><input file stock="gtk-media-next"></input><label>Next</label><action>echo next | nc localhost 12345</action></button>
            <button><input file stock="gtk-fullscreen"></input><label>FS</label><action>echo f | nc localhost 12345</action></button>
            <button><input file stock="gtk-go-up"></input><label>Vol Up</label><action>echo volup 5 | nc localhost 12345</action></button>
            <button><input file stock="gtk-go-down"></input><label>Vol Dwn</label><action>echo voldown 5 | nc localhost 12345</action></button>
            <button><input file stock="gtk-info"></input><label>Info</label><action>echo show_time 5 | nc localhost 12345</action></button>
            <button><input file stock="gtk-quit"></input><label>Quit</label><action>echo quit | nc localhost 12345</action><action type="exit">EXIT_NOW</action></button>
         </hbox>
         <text height-request="280"><label>""</label></text>
         <text><label>"VLC version '$(vlc --version 2>&1| grep '^VLC media player' | cut -f4 -d' ')'"</label></text>
      </vbox>
   </window>' &
   sleep 1

   OSC_WID=''
   export OSC_WID="$(xwininfo -name "VLC Controls" | grep -m1 'Window id: ' | cut -f4 -d' ')"
   [ "$OSC_WID" != '' ] && vlc --vout xcb_xv --extraintf oldrc --rc-host localhost:12345 --drawable-xid  $OSC_WID "$FILE" vlc://quit

else
   Xdialog --msgbox "Not found: $FILE" 0 0
fi
exit 0


Screenshot:


_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0521s ][ Queries: 12 (0.0040s) ][ GZIP on ]