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
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2007-08-14 18:10:53 -07:00
|
|
|
from clutter import cluttergst
|
|
|
|
from myth.MythBackendConn import MythBackendConnection
|
2007-08-21 14:49:29 -07: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
|
|
|
|
|
|
|
class TVPlayer:
|
|
|
|
|
2007-08-21 14:49:29 -07:00
|
|
|
def __init__(self, stage, dbMgr):
|
2007-08-31 07:55:09 -07:00
|
|
|
self.videoController = VideoController(stage)
|
2007-08-14 18:10:53 -07:00
|
|
|
self.stage = stage
|
2007-08-21 14:49:29 -07:00
|
|
|
self.dbMgr = dbMgr
|
2007-08-29 06:35:13 -07:00
|
|
|
self.isRunning = False
|
|
|
|
|
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)
|
2007-08-21 14:49:29 -07:00
|
|
|
(server, port) = self.dbMgr.get_backend_server()
|
|
|
|
self.myConn = MythBackendConnection(self, server, 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-08-31 07:55:09 -07:00
|
|
|
def begin_playback(self, buffer_file):
|
2007-08-23 04:50:05 -07:00
|
|
|
self.menuMgr.get_selector_bar().set_spinner(False)
|
2007-08-31 07:55:09 -07:00
|
|
|
uri = "file://" + os.getcwd() +"/" + buffer_file
|
|
|
|
self.videoController.play_video(uri)
|
2007-08-14 18:10:53 -07:00
|
|
|
|
2007-08-31 07:55:09 -07:00
|
|
|
"""
|
2007-08-23 04:50:05 -07:00
|
|
|
timeline = clutter.Timeline(15, 25)
|
|
|
|
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
|
|
|
|
behaviour = clutter.BehaviourOpacity(alpha, 0,255)
|
|
|
|
behaviour.apply(self.video)
|
|
|
|
|
2007-08-14 18:10:53 -07:00
|
|
|
self.stage.add(self.video)
|
|
|
|
self.video.set_playing(True)
|
2007-08-23 04:50:05 -07:00
|
|
|
timeline.start()
|
2007-08-28 14:55:50 -07:00
|
|
|
#return None
|
2007-08-31 07:55:09 -07:00
|
|
|
"""
|
2007-08-21 14:49:29 -07:00
|
|
|
|
2007-08-28 14:55:50 -07:00
|
|
|
def video_size_change(self, texture, width, height):
|
|
|
|
self.video.set_property("sync-size", False)
|
|
|
|
self.video.set_position(0, 0)
|
|
|
|
xy_ratio = float(width / height)
|
|
|
|
print "XY Ratio: " + str(xy_ratio)
|
|
|
|
|
|
|
|
width = int(self.stage.get_width())
|
|
|
|
height = int (width / xy_ratio)
|
|
|
|
height = 768
|
|
|
|
|
|
|
|
self.video.set_size(width, height)
|
|
|
|
|
2007-08-23 04:50:05 -07:00
|
|
|
def stop(self):
|
2007-08-31 07:55:09 -07:00
|
|
|
self.videoController.stop_video()
|
|
|
|
self.myConn.stop() # Stops the backend / frontend streaming
|
2007-08-23 04:50:05 -07:00
|
|
|
|
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:
|
2007-08-31 07:55:09 -07:00
|
|
|
self.videoController.on_key_press_event(event)
|
2007-08-14 18:10:53 -07:00
|
|
|
#print event.hardware_keycode
|
2007-08-23 04:50:05 -07: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):
|
|
|
|
|
|
|
|
tempMenu = 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
|