Hello All,
I've got a question about the MPV video player and possible Tk bindings...
From their page, there is a link to the language bindings: https://github.com/mpv-player/mpv/wiki/Language-bindings
Would it be possible to implement a player in Tcl/Tk?
Thanks
Also seems like something you could bind with either cffi or ffidl
without too much effort.
/Ashok
Hello All,A snit player is documented in the WIKI. It uses mplayer. sample code follows employing version from www.mplayerhq.hu
I've got a question about the MPV video player and possible Tk bindings...
From their page, there is a link to the language bindings: https://github.com/mpv-player/mpv/wiki/Language-bindings
Would it be possible to implement a player in Tcl/Tk?
Thanks
On Monday, June 27, 2022 at 10:25:19 PM UTC-7, Westermeyer wrote:
Hello All,
I've got a question about the MPV video player and possible Tk bindings...
From their page, there is a link to the language bindings: https://github.com/mpv-player/mpv/wiki/Language-bindings
Would it be possible to implement a player in Tcl/Tk?
ThanksA snit player is documented in the WIKI. It uses mplayer. sample code follows employing version from www.mplayerhq.hu
frame .tMPlayer.$f -class Mplayer -background yellow -container yes {*}$options
set bOK [button .tMPlayer.bOK -text OK]
pack $bOK .tMPlayer.$f -side left
pack propagate .tMPlayer 0
set wid [winfo id .tMPlayer.$f]
# have -colorkey match window background
set channel \
[open [concat | ../shared/snitMP/mplayer.exe -quiet -idle -slave -vo directx -colorkey 0xff0000 -wid $wid $args] r+]
flush $channel
bind .tMPlayer.$f <Destroy> [subst {
catch {
rename .tMPlayer.$f ""
puts $channel quit
flush $channel
close $channel
}
}]
#rename $f "_$f"
proc $f {cmd args} [subst -nocommand {
puts \$cmd
puts \$args
if {\$cmd eq "cmd"} then {
puts $channel \$args
flush $channel
} else {
_$f \$cmd [list \$args]
}
}]
If you don't mind running an external program to handle the video, I
would recommend the VLC media player. I've written a remote controller
in tcl/tk for it that runs on windows but I'm sure you could also use
linux. Many of the functions you might want to use are available through their http interface.
Being an http interface, one could even direct it from another machine.
I use a portable version, and the documentation for how to control it is found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to
enable the http interface and I think you need to set a password too.
If you're interested, I can post a bit of the code I use to send http requests to VLC.
Westermeyer schrieb am Samstag, 2. Juli 2022 um 07:05:15 UTC+2:Tcl really lacks a ready to use solution for playing movies in an embeded way.
On Friday, July 1, 2022 at 3:06:13 PM UTC-7, et4 wrote:
If you don't mind running an external program to handle the video, I would recommend the VLC media player. I've written a remote controller
in tcl/tk for it that runs on windows but I'm sure you could also use linux. Many of the functions you might want to use are available through their http interface.
Being an http interface, one could even direct it from another machine.
I use a portable version, and the documentation for how to control it is found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to enable the http interface and I think you need to set a password too.
Setting up VLC to accept http requests is rather complicated: Activate http, restart VLC, setup a password...If you're interested, I can post a bit of the code I use to send http requests to VLC.That''s a pretty interesting approach, using the portable version might mean a cross-platform solution - I'd be interested to see your code...
As a personal solution no problem. As part of a public software, no go.
On Friday, July 1, 2022 at 3:06:13 PM UTC-7, et4 wrote:
If you don't mind running an external program to handle the video, I
would recommend the VLC media player. I've written a remote controller
in tcl/tk for it that runs on windows but I'm sure you could also use linux. Many of the functions you might want to use are available through their http interface.
Being an http interface, one could even direct it from another machine.
I use a portable version, and the documentation for how to control it is found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to
enable the http interface and I think you need to set a password too.
If you're interested, I can post a bit of the code I use to send http requests to VLC.That''s a pretty interesting approach, using the portable version might mean a cross-platform solution - I'd be interested to see your code...
Alexandru schrieb am Samstag, 2. Juli 2022 um 09:43:50 UTC+2:
Setting up VLC to accept http requests is rather complicated: Activate http, restart VLC, setup a password...Tcl really lacks a ready to use solution for playing movies in an embeded way.
As a personal solution no problem. As part of a public software, no go.
On Friday, July 1, 2022 at 3:06:13 PM UTC-7, et4 wrote:
If you don't mind running an external program to handle the video, I
would recommend the VLC media player. I've written a remote controller
in tcl/tk for it that runs on windows but I'm sure you could also use
linux. Many of the functions you might want to use are available through
their http interface.
Being an http interface, one could even direct it from another machine.
I use a portable version, and the documentation for how to control it is
found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to
enable the http interface and I think you need to set a password too.
If you're interested, I can post a bit of the code I use to send http
requests to VLC.
That''s a pretty interesting approach, using the portable version might mean a cross-platform solution - I'd be interested to see your code...
On 7/1/2022 10:05 PM, Westermeyer wrote:
On Friday, July 1, 2022 at 3:06:13 PM UTC-7, et4 wrote:
If you don't mind running an external program to handle the video, I
would recommend the VLC media player. I've written a remote controller
in tcl/tk for it that runs on windows but I'm sure you could also use
linux. Many of the functions you might want to use are available through >> their http interface.
Being an http interface, one could even direct it from another machine. >>
I use a portable version, and the documentation for how to control it is >> found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to
enable the http interface and I think you need to set a password too.
If you're interested, I can post a bit of the code I use to send http
requests to VLC.
That''s a pretty interesting approach, using the portable version might mean a cross-platform solution - I'd be interested to see your code...Christian and Alexandru have excellent points.
Being retired, I write boss-free dangerous code for my own personal pleasure. With that caveat clearly understood:
Here's a tk example. The comments show how to get the VLC settings right. If you startup a single VLC with some video, the script has 3 buttons to skip and pause. It uses localhost ip and default port built in is 8080.
VLC portable (on windows, I don't use on linux) is self contained in it's own directory tree. The config is there, not in some windows directory. That's how it's portable. (I get the win vlc portable from portableapps.com)
I only run vlc on a fire-walled lan, and so I don't worry about hard-coding in the password, since it's not very secure anyway. Change it below in the argument {password xyz}. Leave username blank.
# vlc example http
# console show
# see this to set config https://wiki.videolan.org/Documentation:Modules/http_intf/
# for pref's all prefs -> main interfaces -> turn on Web, and enter http as shown
# Also, under main interfaces -> Lua, under lua http enter a password, example: xyz
# The username needs to be sent in, but must be blank
#
package require http
package require base64 ;#There's a built-in command now to do this, this code is old
set playerhost 127.0.0.1
set port 8080 ;# vlc default
button .b1 -text "\u2190 3s" -command {skip -1 3} -font {TkDefaultFont 24} button .b2 -text "\u23f8/\u25b6" -command {pause} -font {TkDefaultFont 24} button .b3 -text "3s \u2192" -command {skip 1 3} -font {TkDefaultFont 24}
pack .b1 .b2 .b3 -fill both -expand true -side left
proc http_geturl_auth {url {username {}} {password xyz}} { ;# blank user, and password xyz
set auth "Basic [base64::encode $username:$password]"
set headerl [list Authorization $auth]
set tok [http::geturl $url -headers $headerl -timeout 200]
set result [http::data $tok]
http::cleanup $tok
# puts "result= |$result| " ;# lots of player status returned here
return $result
}
proc pause {} {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=pl_pause" ;# toggle pause/play
}
proc skip {direction secs} {
if { $direction < 0 } {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=-${secs}s"
} else {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=%2B${secs}s"
}
}
The closest that I've come to a solution is simply using the default movie player on the user's machine, and this is launched with either auto_execok (win), open (mac), or xdg-open (linux). While not elegant, it is strangely robust...
On Saturday, July 2, 2022 at 2:31:16 AM UTC-7, et4 wrote:
On 7/1/2022 10:05 PM, Westermeyer wrote:
On Friday, July 1, 2022 at 3:06:13 PM UTC-7, et4 wrote:
If you don't mind running an external program to handle the video, I
would recommend the VLC media player. I've written a remote controller >> in tcl/tk for it that runs on windows but I'm sure you could also use >> linux. Many of the functions you might want to use are available through
their http interface.
Being an http interface, one could even direct it from another machine. >>
I use a portable version, and the documentation for how to control it is
found in the readme here:
C:\PortableApps\VLCPortable\App\vlc\lua\http\requests\readme.txt
I wrote mine long ago, and I forget some details. You would have to
enable the http interface and I think you need to set a password too. >>
If you're interested, I can post a bit of the code I use to send http >> requests to VLC.
That''s a pretty interesting approach, using the portable version might mean a cross-platform solution - I'd be interested to see your code...Christian and Alexandru have excellent points.
Being retired, I write boss-free dangerous code for my own personal pleasure. With that caveat clearly understood:
Here's a tk example. The comments show how to get the VLC settings right. If you startup a single VLC with some video, the script has 3 buttons to skip and pause. It uses localhost ip and default port built in is 8080.
VLC portable (on windows, I don't use on linux) is self contained in it's own directory tree. The config is there, not in some windows directory. That's how it's portable. (I get the win vlc portable from portableapps.com)
I only run vlc on a fire-walled lan, and so I don't worry about hard-coding in the password, since it's not very secure anyway. Change it below in the argument {password xyz}. Leave username blank.
overwhelming, but it becomes a bit much when the solution looks to involve sophisticated C programming (the cffi package looks promising, and might be a solution, thanks Ashok!).# vlc example http
# console show
# see this to set config https://wiki.videolan.org/Documentation:Modules/http_intf/
# for pref's all prefs -> main interfaces -> turn on Web, and enter http as shown
# Also, under main interfaces -> Lua, under lua http enter a password, example: xyz
# The username needs to be sent in, but must be blank
#
package require http
package require base64 ;#There's a built-in command now to do this, this code is old
set playerhost 127.0.0.1
set port 8080 ;# vlc default
button .b1 -text "\u2190 3s" -command {skip -1 3} -font {TkDefaultFont 24} button .b2 -text "\u23f8/\u25b6" -command {pause} -font {TkDefaultFont 24} button .b3 -text "3s \u2192" -command {skip 1 3} -font {TkDefaultFont 24}
pack .b1 .b2 .b3 -fill both -expand true -side left
proc http_geturl_auth {url {username {}} {password xyz}} { ;# blank user, and password xyz
set auth "Basic [base64::encode $username:$password]"
set headerl [list Authorization $auth]
set tok [http::geturl $url -headers $headerl -timeout 200]
set result [http::data $tok]
http::cleanup $tok
# puts "result= |$result| " ;# lots of player status returned here
return $result
}
proc pause {} {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=pl_pause" ;# toggle pause/play
}
proc skip {direction secs} {Thanks very much for the suggestions, they're more than I was anticipating. I'm looking for a solution that is cross-platform and part of an educational package, so widely available. I'm not trained as a computer scientist, so I find that Tcl/Tk a bit
if { $direction < 0 } {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=-${secs}s"
} else {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=%2B${secs}s"
}
}
The closest that I've come to a solution is simply using the default movie player on the user's machine, and this is launched with either auto_execok (win), open (mac), or xdg-open (linux). While not elegant, it is strangely robust...
Hello All,the educational solution you seem to be seeking is an all tcl\tk training solution which can be seen at www.verbaltransacrions.com. It leverages the simulation training package developed by Advertech, Ltd. It provides for the needs you have described
I've got a question about the MPV video player and possible Tk bindings...
From their page, there is a link to the language bindings: https://github.com/mpv-player/mpv/wiki/Language-bindings
Would it be possible to implement a player in Tcl/Tk?
Thanks
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 714 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 135:49:00 |
| Calls: | 12,087 |
| Files: | 14,997 |
| Messages: | 6,517,370 |