2007-08-21 14:49:29 -07:00
|
|
|
import gst
|
|
|
|
import pygtk
|
|
|
|
import pygst
|
|
|
|
import os
|
2007-08-23 04:50:05 -07:00
|
|
|
import clutter
|
2008-02-13 13:11:17 -08:00
|
|
|
import gobject
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2007-08-14 18:10:53 -07:00
|
|
|
from clutter import cluttergst
|
2007-11-15 02:38:00 -08:00
|
|
|
from modules.myth_tv_player.MythBackendConn import MythBackendConnection
|
2008-02-11 13:33:45 -08:00
|
|
|
from modules.myth_tv_player.tv_db_controller import tv_db_controller
|
2008-02-15 02:48:03 -08:00
|
|
|
from SplashScr import SplashScr
|
2008-01-30 05:02:07 -08:00
|
|
|
#from Menu import Menu
|
2007-08-31 07:55:09 -07:00
|
|
|
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
|
2008-02-11 13:33:45 -08:00
|
|
|
self.dbMgr = dbMgr
|
2008-01-06 04:11:17 -08:00
|
|
|
self.setup_ui()
|
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
self.osd = osd()
|
2008-01-21 03:09:17 -08:00
|
|
|
self.videoController = VideoController(glossMgr)
|
2008-02-11 13:33:45 -08:00
|
|
|
self.dbController = tv_db_controller(dbMgr)
|
2008-02-13 13:11:17 -08:00
|
|
|
#self.dbController.get_current_show(1033)
|
|
|
|
self.channels = self.dbController.get_channels()
|
|
|
|
self.currentChannel = 0
|
2008-02-11 13:33:45 -08:00
|
|
|
|
2007-08-29 06:35:13 -07:00
|
|
|
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):
|
2007-08-23 04:50:05 -07:00
|
|
|
self.menuMgr = menuMgr
|
|
|
|
#self.buffer_file_reader = open("test.mpg","r")
|
|
|
|
menuMgr.get_selector_bar().set_spinner(True)
|
2008-02-17 03:23:38 -08:00
|
|
|
(self.server, self.port) = self.dbMgr.get_backend_server()
|
|
|
|
self.myConn = MythBackendConnection(self, self.server, self.port)
|
2007-08-14 18:10:53 -07:00
|
|
|
self.myConn.start()
|
2007-08-28 14:55:50 -07:00
|
|
|
#vid.begin(self.stage)
|
2007-08-29 06:35:13 -07:00
|
|
|
|
|
|
|
self.isRunning = True
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2007-11-22 02:41:29 -08:00
|
|
|
def begin_playback(self, fd):#buffer_file):
|
2007-08-23 04:50:05 -07:00
|
|
|
self.menuMgr.get_selector_bar().set_spinner(False)
|
2007-11-22 02:41:29 -08:00
|
|
|
#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)
|
2007-11-22 02:41:29 -08:00
|
|
|
#print uri
|
2007-11-13 05:03:39 -08:00
|
|
|
self.videoController.play_video(uri, self)
|
2007-08-14 18:10:53 -07:00
|
|
|
|
2007-08-23 04:50:05 -07:00
|
|
|
def stop(self):
|
2007-08-31 07:55:09 -07:00
|
|
|
self.videoController.stop_video()
|
2008-02-13 13:11:17 -08:00
|
|
|
if self.myConn:
|
|
|
|
self.myConn.stop() # Stops the backend / frontend streaming
|
2007-11-13 05:03:39 -08:00
|
|
|
|
|
|
|
def stop_video(self):
|
2007-11-20 02:57:49 -08:00
|
|
|
self.myConn.stop()
|
2007-08-14 18:10:53 -07:00
|
|
|
|
|
|
|
def on_key_press_event (self, stage, event):
|
2007-08-29 06:35:13 -07:00
|
|
|
if self.isRunning:
|
2008-02-13 13:11:17 -08:00
|
|
|
#Handle up/down presses for OSD
|
2008-02-15 02:48:03 -08:00
|
|
|
if (event.keyval == clutter.keysyms.Up) or (event.keyval == clutter.keysyms.Down):
|
2008-02-13 13:11:17 -08:00
|
|
|
self.osd.on_key_press_event(self.stage, event, self)
|
|
|
|
|
2007-08-31 07:55:09 -07:00
|
|
|
self.videoController.on_key_press_event(event)
|
2008-02-15 02:48:03 -08:00
|
|
|
|
|
|
|
if (event.keyval == clutter.keysyms.Return):
|
|
|
|
if self.osd.on_screen:
|
|
|
|
self.loading_scr = SplashScr(self.stage)
|
2008-02-17 03:23:38 -08:00
|
|
|
self.loading_scr.set_msg("Loading Channel ")
|
|
|
|
self.loading_scr.set_details(self.osd.currentChannel.name)
|
|
|
|
self.loading_scr.backdrop.set_opacity(180)
|
|
|
|
self.loading_scr.display_elegant()
|
|
|
|
self.videoController.pause_video(False)
|
|
|
|
self.myConn.stop()
|
|
|
|
self.myConn = None
|
|
|
|
self.myConn = MythBackendConnection(self, self.server, self.port)
|
|
|
|
self.myConn.chanNum = self.osd.currentChannel.channum
|
|
|
|
self.myConn.start()
|
|
|
|
self.videoController.unpause_video()
|
|
|
|
#self.loading_scr.remove()
|
|
|
|
#self.myConn.change_channel(self.currentChannel.name)
|
2008-02-15 02:48:03 -08:00
|
|
|
|
2007-09-05 03:16:17 -07:00
|
|
|
if event.keyval == clutter.keysyms.Escape:
|
|
|
|
return True
|
2007-08-14 18:10:53 -07:00
|
|
|
#print event.hardware_keycode
|
2007-08-23 04:50:05 -07:00
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
|
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:
|
2007-08-21 14:49:29 -07:00
|
|
|
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)
|
2007-08-21 14:49:29 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
class osd:
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
def __init__(self):
|
|
|
|
self.background = clutter.Texture()
|
|
|
|
self.text = clutter.Label()
|
|
|
|
self.text.set_font_name("Mono 40")
|
|
|
|
self.text.show()
|
|
|
|
|
|
|
|
self.on_screen = False
|
|
|
|
self.channelOffset = 0
|
2008-02-17 03:23:38 -08:00
|
|
|
self.input_count = 0
|
2008-02-13 13:11:17 -08:00
|
|
|
|
|
|
|
def on_key_press_event(self, stage, event, tv_player):
|
|
|
|
if self.on_screen:
|
|
|
|
if (event.keyval == clutter.keysyms.Up):
|
|
|
|
self.channelOffset += 1
|
|
|
|
elif (event.keyval == clutter.keysyms.Down):
|
|
|
|
self.channelOffset -= 1
|
2008-02-14 05:01:06 -08:00
|
|
|
|
2008-02-17 03:23:38 -08:00
|
|
|
#Increment the input counter (Only when this reaches 0 will the osd be removed from screen
|
|
|
|
self.input_count += 1
|
2008-02-13 13:11:17 -08:00
|
|
|
else:
|
|
|
|
stage.add(self.text)
|
|
|
|
self.channelOffset = 0
|
|
|
|
|
|
|
|
self.currentChannel = tv_player.channels[tv_player.currentChannel+self.channelOffset]
|
|
|
|
|
2008-02-14 05:01:06 -08:00
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
self.text.set_text(self.currentChannel.name)
|
|
|
|
self.on_screen = True
|
2008-02-14 05:01:06 -08:00
|
|
|
self.timeout_id = gobject.timeout_add(3000, self.exit, stage)
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2008-02-13 13:11:17 -08:00
|
|
|
def exit(self, stage):
|
2008-02-17 03:23:38 -08:00
|
|
|
#First check the input counter, we only remove the osd from screen if this is 0
|
|
|
|
if self.input_count > 0:
|
|
|
|
self.input_count -= 1
|
|
|
|
return False
|
|
|
|
|
|
|
|
if self.on_screen:
|
|
|
|
stage.remove(self.text)
|
|
|
|
self.on_screen = False
|
|
|
|
|
2008-02-14 05:01:06 -08:00
|
|
|
return False
|