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 Mon 20 Oct 2014, 06:15
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 [4 Posts]  
Author Message
sc0ttman


Joined: 16 Sep 2009
Posts: 2385
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: 2385
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: 2385
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 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Thu 08 May 2014, 05:09    Post subject:  

some more controls

Code:
add XYZ  . . . . . . . . . . . . add XYZ to playlist
enqueue XYZ  . . . . . . . . . queue XYZ to playlist
playlist . . . . .  show items currently in playlist
play . . . . . . . . . . . . . . . . . . play stream
stop . . . . . . . . . . . . . . . . . . stop stream
next . . . . . . . . . . . . . .  next playlist item
prev . . . . . . . . . . . .  previous playlist item
goto . . . . . . . . . . . . . .  goto item at index
repeat [on|off] . . . .  toggle playlist item repeat
loop [on|off] . . . . . . . . . toggle playlist loop
random [on|off] . . . . . . .  toggle random jumping
clear . . . . . . . . . . . . . . clear the playlist
status . . . . . . . . . . . current playlist status
title [X]  . . . . . . set/get title in current item
title_n  . . . . . . . .  next title in current item
title_p  . . . . . .  previous title in current item
chapter [X]  . . . . set/get chapter in current item
chapter_n  . . . . . .  next chapter in current item
chapter_p  . . . .  previous chapter in current item
seek X . . . seek in seconds, for instance `seek 12'
pause  . . . . . . . . . . . . . . . .  toggle pause
fastforward  . . . . . . . .  .  set to maximum rate
rewind  . . . . . . . . . . . .  set to minimum rate
faster . . . . . . . . . .  faster playing of stream
slower . . . . . . . . . .  slower playing of stream
normal . . . . . . . . . .  normal playing of stream
frame. . . . .  . . . . . . . .  play frame by frame
f [on|off] . . . . . . . . . . . . toggle fullscreen
info . . . . .  information about the current stream
stats  . . . . . . . .  show statistical information
get_time . . seconds elapsed since stream's beginning
is_playing . . . .  1 if a stream plays, 0 otherwise
get_title . . . . .  the title of the current stream
get_length . . . .  the length of the current stream
volume [X] . . . . . . . . . .  set/get audio volume
volup [X]  . . . . . . .  raise audio volume X steps
voldown [X]  . . . . . .  lower audio volume X steps
adev [device]  . . . . . . . .  set/get audio device
achan [X]. . . . . . . . . .  set/get audio channels
atrack [X] . . . . . . . . . . . set/get audio track
vtrack [X] . . . . . . . . . . . set/get video track
vratio [X]  . . . . . . . set/get video aspect ratio
vcrop [X]  . . . . . . . . . . .  set/get video crop
vzoom [X]  . . . . . . . . . . .  set/get video zoom
snapshot . . . . . . . . . . . . take video snapshot
strack [X] . . . . . . . . .  set/get subtitle track
key [hotkey name] . . . . . .  simulate hotkey press
help . . . . . . . . . . . . . . . this help message
logout . . . . . . .  exit (if in socket connection)
quit . . . . . . . . . . . . . . . . . . .  quit vlc

shortcut keys are here:
http://repo.or.cz/w/vlc.git/blob/HEAD:/include/vlc_keys.h
... but they are hex numbers with no comment as to the corresponding readable keys

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 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.0714s ][ Queries: 12 (0.0042s) ][ GZIP on ]