From: Rob on
Under Linux, I want to play audio files using 'mplayer' (a command line
media player) in a terminal window with the output from mplayer being
written to a file, and at the same time being able to see the status line
info.

I tried writing the whole thing in tcl, but came up against the problem of
not being able to see the status line info being displayed during the play
session. This means that there is no visual feedback if I change volume or
manually change where in the file I want to listen.

I came up with a solution of actually running mplayer from a bash script,
but calling a number of tcl scripts to get various bits of info used in
working out which files to play.

The actual code which invokes mplayer is:

mplayer "$filename" | tee "$logname"

This means that the stdout data is written simultaneously to both the
logfile and back to the terminal.

Is such functionality possible in a pure tcl environment?

TIA

Rob.
From: Craig on
I suspect I'm not getting exactly what you after, but something along these
lines may be what you're looking for:

set logfile [open logfile w+]
set handle [open "|mplayer $filename" r]
fileevent $handle readable readmystuff

proc readmystuff {} {global handle logfile; set out [read $handle]; puts $out;
puts $logfile $out}



On 8/3/2010 2:48 PM, Rob wrote:
> Under Linux, I want to play audio files using 'mplayer' (a command line
> media player) in a terminal window with the output from mplayer being
> written to a file, and at the same time being able to see the status line
> info.
>
> I tried writing the whole thing in tcl, but came up against the problem of
> not being able to see the status line info being displayed during the play
> session. This means that there is no visual feedback if I change volume or
> manually change where in the file I want to listen.
>
> I came up with a solution of actually running mplayer from a bash script,
> but calling a number of tcl scripts to get various bits of info used in
> working out which files to play.
>
> The actual code which invokes mplayer is:
>
> mplayer "$filename" | tee "$logname"
>
> This means that the stdout data is written simultaneously to both the
> logfile and back to the terminal.
>
> Is such functionality possible in a pure tcl environment?
>
> TIA
>
> Rob.
From: Robert Heller on
At Wed, 04 Aug 2010 07:48:38 +1000 Rob <dislexic_wobmat(a)NOSPAMyahoo.com> wrote:

>
> Under Linux, I want to play audio files using 'mplayer' (a command line
> media player) in a terminal window with the output from mplayer being
> written to a file, and at the same time being able to see the status line
> info.
>
> I tried writing the whole thing in tcl, but came up against the problem of
> not being able to see the status line info being displayed during the play
> session. This means that there is no visual feedback if I change volume or
> manually change where in the file I want to listen.
>
> I came up with a solution of actually running mplayer from a bash script,
> but calling a number of tcl scripts to get various bits of info used in
> working out which files to play.
>
> The actual code which invokes mplayer is:
>
> mplayer "$filename" | tee "$logname"
>
> This means that the stdout data is written simultaneously to both the
> logfile and back to the terminal.
>
> Is such functionality possible in a pure tcl environment?

if {[catch {open "|mplayer $filename" r} pipefp]} {
error "$pipefp";# could use tk_essageBox in a GUI -- man tk_messageBox
}

fileevent $pipefp readable [list tee $pipefp SomeFunction]

proc tee {infp processFn} {
if {[gets $infp line] < 0} {
catch {close $infp}
} else {
puts $line
$processFn $line
}
}

proc SomeFunction {line} {
# Do whatever to $line
# Could be puts $somechanneltoalogfile "$line"
}

# if not in the GUI you need this.
vwait forever

>
> TIA
>
> Rob.
>

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/

 | 
Pages: 1
Prev: highlight the whole line
Next: ANNOUNCE: TkDND 2.2