gloss-mc/modules/myth_tv_player/myth_tv_player.py

104 lines
3.2 KiB
Python
Raw Normal View History

import gst
import pygtk
import pygst
import os
import clutter
2007-08-14 18:10:53 -07:00
from clutter import cluttergst
from modules.myth_tv_player.MythBackendConn import MythBackendConnection
2008-01-30 05:02:07 -08:00
#from Menu import Menu
from VideoController import VideoController
2007-08-14 18:10:53 -07:00
2007-11-19 03:38:15 -08:00
class Module:
title = "TV"
2007-08-14 18:10:53 -07:00
2007-12-21 03:39:50 -08:00
def __init__(self, glossMgr, dbMgr):
self.stage = glossMgr.get_stage()
2008-01-06 04:11:17 -08:00
self.glossMgr = glossMgr
self.setup_ui()
self.videoController = VideoController(glossMgr)
self.dbMgr = dbMgr
self.isRunning = False
2008-01-06 04:11:17 -08:00
def setup_ui(self):
self.menu_image = self.glossMgr.themeMgr.get_texture("mythtv_menu_image", None, None)
2007-11-19 03:38:15 -08:00
#Action to take when menu item is selected
def action(self):
return self
2007-08-14 18:10:53 -07:00
def begin(self, menuMgr):
self.menuMgr = menuMgr
#self.buffer_file_reader = open("test.mpg","r")
menuMgr.get_selector_bar().set_spinner(True)
(server, port) = self.dbMgr.get_backend_server()
self.myConn = MythBackendConnection(self, server, port)
2007-08-14 18:10:53 -07:00
self.myConn.start()
#vid.begin(self.stage)
self.isRunning = True
def begin_playback(self, fd):#buffer_file):
self.menuMgr.get_selector_bar().set_spinner(False)
#uri = "file://" + os.getcwd() +"/" + buffer_file
#f = open(os.getcwd() +"/" + buffer_file, 'r')
uri = "fd://" + str(fd)
2007-12-11 02:50:45 -08:00
#uri = str(fd)
#print uri
self.videoController.play_video(uri, self)
2007-08-14 18:10:53 -07:00
def stop(self):
self.videoController.stop_video()
self.myConn.stop() # Stops the backend / frontend streaming
def stop_video(self):
self.myConn.stop()
2007-08-14 18:10:53 -07:00
def on_key_press_event (self, stage, event):
if self.isRunning:
self.videoController.on_key_press_event(event)
if event.keyval == clutter.keysyms.Escape:
return True
2007-08-14 18:10:53 -07:00
#print event.hardware_keycode
2007-08-14 18:10:53 -07:00
"""if event.keyval == clutter.keysyms.p:
if self.paused:
self.unpause()
else:
self.pause()
if event.keyval == clutter.keysyms.q:
clutter.main_quit()"""
#The following generates a menu with an option for each of the slideshows in the base menu
def generateMenu(self):
2008-01-30 05:02:07 -08:00
tempMenu = self.glossMgr.create_menu() #Menu(self.MenuMgr)
self.dbMgr.get_channels()
file_list = os.listdir(self.baseDir)
for directoryEntry in file_list:
subdir = self.baseDir + "/" + directoryEntry
if os.path.isdir(subdir):
imgPath = subdir + "/" + os.listdir(subdir)[0]
#print imgPath
tempItem = tempMenu.addItem(directoryEntry, "/home/josh/.mythtv/MythVideo/0088763.jpg")
tempItem.setAction(self)
return tempMenu
class channel:
def __init__(self, chanID, channum, name, iconLocation, xmltvid):
self.chanID = chanID
self.channum = channum
self.name = name
self.iconLocation = iconLocation
self.xmltvid = xmltvid
def get_name():
return self.name