News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
access to media files on a LAN server
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: access to media files on a LAN server

Did some fixin'
Keyboard control should be halfway decent now.
The menu file is flexible, but i don't know if that is actually helpful.
Access is granted via double-click rather than having to click to select and then click a button to play.

EDIT: fixed crash if menu_file is not getted.
Still want to look into supporting subdirectories, but it feels complicated at the moment.

Code:
#!/usr/bin/env murgaLua

-- access media files on a file server & stream in a player
-- mikshaw 2010

--> USER CONFIGURATION <--

--player="C:\\Progra~1\\SMPlayer\\smplayer.exe" -- Windows
player="mplayer" -- Linux
host="http://localhost/videos"
menu_file=host.."/lua_menu"

--> END USER CONFIGURATION <--

label={}; url={}
-- retrieve the menu from server
menufile,c,h=socket.http.request(menu_file)
if c~=200 then
fltk.fl_alert("could not find "..menu_file)
os.exit() end
assert(loadstring(menufile))()

function get_menu()
box:clear()
for i,v in pairs(label) do
  box:add(v)
end
fresh:deactivate()
go:label("Show files")
box:value(1)
end

function get_files()
box:clear()
body,code,header=socket.http.request(dir)
for l in string.gmatch(body,"<a href=\"(.-)\"") do
  if not string.find(l,"\.srt$") and not string.find(l,"\/") then
  box:add(l)
  end
end
fresh:activate()
go:label("Play")
box:value(1)
end

function play(self)
if box:value() > 0 then
  if self:label()=="Play" then
    win:hide()
    Fl:check()
    os.execute(player.." "..dir.."/"..box:text(box:value()))
--    os.exit()
    win:show()
  else
    dir=host..url[box:value()]
    get_files()
  end
end
end

function dubbleclik()
if Fl:event() == fltk.FL_RELEASE and Fl:event_clicks() > 0 then
go:do_callback()
end
end

ww,wh,bh=420,400,25
bw=ww/3
win=fltk:Fl_Window(ww,wh,"Movies")
box=fltk:Fl_Hold_Browser(0,0,ww,wh-bh); box:callback(dubbleclik)
go=fltk:Fl_Return_Button(0,wh-bh,bw,bh,"Play"); go:callback(play)
fresh=fltk:Fl_Button(bw,wh-bh,bw,bh,"&Menu"); fresh:callback(get_menu)
no=fltk:Fl_Button(bw*2,wh-bh,bw,bh,"&Quit"); no:callback(function() os.exit() end)

--table.sort(menu)
get_menu()

--win:resizable(box)
win:show()
Fl:run()

This post was last modified: 01-13-2010 02:14 PM by mikshaw.

01-12-2010 03:01 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
RE: access to media files on a LAN server - mikshaw - 01-12-2010 03:01 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: