Finally some movement on the Video Player interface.

Cover Viewer is now playing nice with z coords and has changed from a left/right grouping to an up/down.
Also the basics of a video description group are in place.
This commit is contained in:
noisymime 2007-09-03 13:13:34 +00:00
parent f1aa179451
commit cbe0defd12
3 changed files with 76 additions and 60 deletions

View File

@ -125,16 +125,17 @@ class VideoController:
self.overlay.set_pixbuf(pixbuf) self.overlay.set_pixbuf(pixbuf)
self.overlay.set_width(self.stage.get_width()) self.overlay.set_width(self.stage.get_width())
self.overlay.set_height(self.stage.get_height()) self.overlay.set_height(self.stage.get_height())
self.stage.add(self.overlay)
self.overlay.set_opacity(0) self.overlay.set_opacity(0)
self.overlay.show() self.overlay.show()
self.stage.add(self.overlay)
#self.video_texture.lower_actor(self.overlay) #self.video_texture.lower_actor(self.overlay)
#self.overlay.raise_actor(self.video_texture) #self.overlay.raise_actor(self.video_texture)
#Fade the overlay in #Fade the overlay in
timeline_overlay = clutter.Timeline(10,30) timeline_overlay = clutter.Timeline(10,30)
alpha = clutter.Alpha(timeline_overlay, clutter.ramp_inc_func) alpha = clutter.Alpha(timeline_overlay, clutter.ramp_inc_func)
overlay_behaviour = clutter.BehaviourOpacity(alpha, 0, 230) overlay_behaviour = clutter.BehaviourOpacity(alpha, 0, 200)
#video_behaviour = clutter.BehaviourOpacity(alpha, 255, 80) #video_behaviour = clutter.BehaviourOpacity(alpha, 255, 80)
overlay_behaviour.apply(self.overlay) overlay_behaviour.apply(self.overlay)
#video_behaviour.apply(self.video_texture) #video_behaviour.apply(self.video_texture)
@ -147,7 +148,7 @@ class VideoController:
#Fade the backdrop in #Fade the backdrop in
timeline_unpause = clutter.Timeline(10,30) timeline_unpause = clutter.Timeline(10,30)
alpha = clutter.Alpha(timeline_unpause, clutter.ramp_inc_func) alpha = clutter.Alpha(timeline_unpause, clutter.ramp_inc_func)
overlay_behaviour = clutter.BehaviourOpacity(alpha, 230, 0) overlay_behaviour = clutter.BehaviourOpacity(alpha, 200, 0)
#video_behaviour = clutter.BehaviourOpacity(alpha, 80, 255) #video_behaviour = clutter.BehaviourOpacity(alpha, 80, 255)
overlay_behaviour.apply(self.overlay) overlay_behaviour.apply(self.overlay)
#video_behaviour.apply(self.video_texture) #video_behaviour.apply(self.video_texture)

View File

@ -10,7 +10,7 @@ class VideoPlayer():
def __init__(self, stage, dbMgr): def __init__(self, stage, dbMgr):
self.stage = stage self.stage = stage
self.cover_viewer = coverViewer(self.stage) self.cover_viewer = coverViewer(self.stage, 400, 400)
self.is_playing = False self.is_playing = False
@ -25,9 +25,8 @@ class VideoPlayer():
tempVideo = videoItem() tempVideo = videoItem()
tempVideo.importFromMythObject(record) tempVideo.importFromMythObject(record)
self.cover_viewer.add_video(tempVideo) self.cover_viewer.add_video(tempVideo)
#self.cover_viewer.add_image(tempVideo.getCoverfile())
#dbMgr.close_db()
################################################################################
def on_key_press_event (self, stage, event): def on_key_press_event (self, stage, event):
if event.keyval == clutter.keysyms.p: if event.keyval == clutter.keysyms.p:
@ -66,42 +65,11 @@ class VideoPlayer():
self.cover_viewer.show_all() self.cover_viewer.show_all()
self.cover_viewer.show() self.cover_viewer.show()
self.stage.add(self.cover_viewer) self.stage.add(self.cover_viewer)
self.cover_viewer.toggle_details() #Turns the details group on
begin_behaviour.apply(self.cover_viewer) begin_behaviour.apply(self.cover_viewer)
timeline_begin.start() timeline_begin.start()
"""
video = customBin()
video.get_texture().show()
video.get_texture().set_opacity(255)
self.stage.add(video.get_texture())
video.startPlayback()
self.video_texture = clutter.Texture() #cluttergst.VideoTexture()
self.pipeline = gst.Pipeline("mypipeline")
self.filesrc = gst.element_factory_make("filesrc", "file")
self.filesrc.set_property("location", "/home/josh/clutter/toys/gloss/cast1.avi")
#self.pbin.set_property("uri", "file://cast1.avi")
self.pbin = gst.element_factory_make("decodebin", "pbin")
#self.pbin = gst.element_factory_make("videotestsrc", "video")
self.sink = gst.element_factory_make("xvimagesink", "sink")
#self.sink = cluttergst.video_sink_new(self.video_texture)
#self.sink = cluttergst.VideoSink(self.video_texture)
# add elements to the pipeline
self.pipeline.add(self.pbin)
self.pipeline.add(self.sink)
self.pipeline.add(self.filesrc)
self.pbin.link(self.sink)
self.pbin.link(self.filesrc)
self.pipeline.set_state(gst.STATE_PLAYING)
self.stage.add(self.video_texture)
#self.stage.add(self.sink)
"""
def stop(self): def stop(self):
#Fade everything out #Fade everything out
@ -154,20 +122,37 @@ class videoItem():
class coverViewer(clutter.Group): class coverViewer(clutter.Group):
scaleFactor = 1.4 scaleFactor = 1.4
inactiveOpacity = 150
def __init__(self, stage): def __init__(self, stage, width, height):
clutter.Group.__init__(self) clutter.Group.__init__(self)
self.stage = stage self.stage = stage
self.videoLibrary = [] self.videoLibrary = []
self.textureLibrary = []
self.current_video_details = video_details_group()
self.num_covers = 0 self.num_covers = 0
self.cover_size = 200 #A cover will be cover_size * cover_size (X * Y) self.cover_size = 200 #A cover will be cover_size * cover_size (X * Y)
self.cover_gap = 1 self.cover_gap = 1
self.set_width(width)
self.set_height(height)
self.num_rows = 3 self.num_rows = 3
self.num_columns = 4 #int(self.stage.get_width() / self.cover_size) self.num_columns = 4 #int(self.stage.get_width() / self.cover_size)
self.currentSelection = 0 self.currentSelection = 0
#self.stage.add(self.current_video_description)
self.current_video_details.show()
self.current_video_details.show_all()
#Turns the description group off and on
def toggle_details(self):
if self.current_video_details.get_parent() == None:
self.stage.add(self.current_video_details)
else:
self.stage.remove(self.current_video_details)
def add_video(self, video): def add_video(self, video):
self.videoLibrary.append(video) self.videoLibrary.append(video)
imagePath = video.getCoverfile() imagePath = video.getCoverfile()
@ -179,30 +164,43 @@ class coverViewer(clutter.Group):
width = int(self.cover_size * xy_ratio) width = int(self.cover_size * xy_ratio)
tempTexture.set_width(width) tempTexture.set_width(width)
tempTexture.set_height(self.cover_size) tempTexture.set_height(self.cover_size)
tempTexture.set_opacity(self.inactiveOpacity)
tempTexture.set_position( (self.num_covers * self.cover_size), 0) tempTexture.set_position( (self.num_covers * self.cover_size), 0)
tempTexture.set_depth(1)
self.textureLibrary.append(tempTexture)
x = (self.cover_gap + self.cover_size) * (self.num_covers/self.num_rows) #x = (self.cover_gap + self.cover_size) * (self.num_covers/self.num_rows)
y = (self.num_covers % self.num_rows) * self.cover_size + ( (self.num_covers % self.num_rows) * self.cover_gap) #y = (self.num_covers % self.num_rows) * self.cover_size + ( (self.num_covers % self.num_rows) * self.cover_gap)
x = (self.num_covers % self.num_columns) * self.cover_size + ( (self.num_covers % self.num_columns) * self.cover_gap)
y = (self.cover_gap + self.cover_size) * (self.num_covers/self.num_columns)
tempTexture.set_position(x, y) tempTexture.set_position(x, y)
self.add(tempTexture) self.add(tempTexture)
self.num_covers = self.num_covers +1 self.num_covers = self.num_covers +1
def select_item(self, incomingItem, outgoingItem): def select_item(self, incomingItem, outgoingItem):
outgoingTexture = self.get_nth_child(outgoingItem) self.current_video_details.set_video(self.videoLibrary[incomingItem])
incomingTexture = self.get_nth_child(incomingItem)
#Make sure the new texture is on the top outgoingTexture = self.textureLibrary[outgoingItem]
#incomingTexture.raise_top() incomingTexture = self.textureLibrary[incomingItem]
self.timeline = clutter.Timeline(20,80) self.timeline = clutter.Timeline(20,80)
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func) alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
behaviourNew = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER) behaviourNew_scale = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
behaviourOld = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER) behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
behaviourNew.apply(incomingTexture) behaviourOld_scale = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
behaviourOld.apply(outgoingTexture) behaviourOld_z = clutter.BehaviourDepth(alpha, 2, 1)
behaviourOld_opacity = clutter.BehaviourOpacity(alpha, 255, self.inactiveOpacity)
behaviourNew_scale.apply(incomingTexture)
behaviourNew_z.apply(incomingTexture)
behaviourNew_opacity.apply(incomingTexture)
behaviourOld_scale.apply(outgoingTexture)
behaviourOld_z.apply(outgoingTexture)
behaviourOld_opacity.apply(outgoingTexture)
self.currentSelection = incomingItem self.currentSelection = incomingItem
@ -211,17 +209,19 @@ class coverViewer(clutter.Group):
def on_cursor_press_event(self, event): def on_cursor_press_event(self, event):
newItem = None newItem = None
if event.keyval == clutter.keysyms.Left: if event.keyval == clutter.keysyms.Left:
newItem = self.currentSelection - self.num_rows if not self.currentSelection == 0:
newItem = self.currentSelection - 1
if event.keyval == clutter.keysyms.Right: if event.keyval == clutter.keysyms.Right:
newItem = self.currentSelection + self.num_rows if not self.currentSelection == (self.get_n_children()-1):
newItem = self.currentSelection + 1
if event.keyval == clutter.keysyms.Down: if event.keyval == clutter.keysyms.Down:
#Check if we're already on the bottom row #Check if we're already on the bottom row
if not ((self.currentSelection % self.num_rows) == (self.num_rows-1)): if not (self.currentSelection > (len(self.textureLibrary)-1 - self.num_columns)):
newItem = self.currentSelection + 1 newItem = self.currentSelection + self.num_columns
if event.keyval == clutter.keysyms.Up: if event.keyval == clutter.keysyms.Up:
#Check if we're already on the top row #Check if we're already on the top row
if not (self.currentSelection % self.num_rows) == 0: if not (self.currentSelection < self.num_columns):
newItem = self.currentSelection - 1 newItem = self.currentSelection - self.num_columns
if (newItem < 0) and (not newItem == None): if (newItem < 0) and (not newItem == None):
newItem = self.currentSelection newItem = self.currentSelection
@ -230,5 +230,20 @@ class coverViewer(clutter.Group):
if not newItem == None: if not newItem == None:
self.select_item(newItem, self.currentSelection) self.select_item(newItem, self.currentSelection)
class video_details_group(clutter.Group):
font = "Lucida Grande "
header_font_size = 30
main_font_size = 24
def __init__(self):
clutter.Group.__init__(self)
self.heading = clutter.Label()
self.heading.set_font_name(self.font + str(self.header_font_size))
self.heading.set_color(clutter.color_parse('White'))
self.add(self.heading)
self.show_all()
def set_video(self, video):
self.heading.set_text(video.title)

Binary file not shown.