Version 5 of basic snack stream player

Updated 2004-10-08 17:53:36 by kroc

Kroc - 8 Oct 2004 : This is very simple ogg/mp3 stream player. It might require snack 2.2.8.

 ################################################################################
 #
 # Basic Snack stream player
 #
 # Copyright © 2004 - Kroc & rmax
 #
 # Shared under NOL licence : http://wiki.tcl.tk/nol
 #
 # Version 1.0 - October 2004
 #
 ################################################################################

 package require Tk
 package require snack 2.2
 package require snackogg
 package require http

 wm title . "Snack 2.2.8 stream player"

 wm protocol . WM_DELETE_WINDOW {
    quit
 }

 proc quit {} {
    ::snack::audio stop
    s stop
    exit
 }

 proc playstream { socket token } {
    fileevent $socket readable ""
    set ::status "Buffering..."
    grid [label .l1 -text "Playing [lindex $::argv 0]"] -sticky ew
    grid [label .l2 -textvariable ::status -justify left] -sticky w
    grid [button .b -text Quit -command quit] -sticky ew
    update
    list http::cleanup $token
    ::snack::sound s -channel $socket
    for {set i 0} {$i < 30} {incr i} {
        after 100
        append ::status .
        update
    }
    set ::status "stream type is [s info]"
    update
    s play -blocking 0
    return 0
 }

 if { $argc != 1 } {
    puts stdout "\n\
            Usage: \n\t$argv0 URL\n\
            Example:\n\t$argv0 http://64.62.252.140:8628/soulfm.ogg\n"
    ::snack::audio stop
    exit
 } else {
    set url [lindex $argv 0]
    http::geturl $url -handler playstream
 }

There is some streamed radios you can try here: [L1 ]

I tested it successfully under linux with http://64.62.252.140:8628/soulfm.ogg and http://64.62.252.140:8672/divaradio.ogg