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:
parent
f1aa179451
commit
cbe0defd12
|
@ -125,16 +125,17 @@ class VideoController:
|
|||
self.overlay.set_pixbuf(pixbuf)
|
||||
self.overlay.set_width(self.stage.get_width())
|
||||
self.overlay.set_height(self.stage.get_height())
|
||||
self.stage.add(self.overlay)
|
||||
self.overlay.set_opacity(0)
|
||||
self.overlay.show()
|
||||
|
||||
self.stage.add(self.overlay)
|
||||
|
||||
#self.video_texture.lower_actor(self.overlay)
|
||||
#self.overlay.raise_actor(self.video_texture)
|
||||
#Fade the overlay in
|
||||
timeline_overlay = clutter.Timeline(10,30)
|
||||
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)
|
||||
overlay_behaviour.apply(self.overlay)
|
||||
#video_behaviour.apply(self.video_texture)
|
||||
|
@ -147,7 +148,7 @@ class VideoController:
|
|||
#Fade the backdrop in
|
||||
timeline_unpause = clutter.Timeline(10,30)
|
||||
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)
|
||||
overlay_behaviour.apply(self.overlay)
|
||||
#video_behaviour.apply(self.video_texture)
|
||||
|
|
129
VideoPlayer.py
129
VideoPlayer.py
|
@ -10,7 +10,7 @@ class VideoPlayer():
|
|||
|
||||
def __init__(self, stage, dbMgr):
|
||||
self.stage = stage
|
||||
self.cover_viewer = coverViewer(self.stage)
|
||||
self.cover_viewer = coverViewer(self.stage, 400, 400)
|
||||
|
||||
self.is_playing = False
|
||||
|
||||
|
@ -25,10 +25,9 @@ class VideoPlayer():
|
|||
tempVideo = videoItem()
|
||||
tempVideo.importFromMythObject(record)
|
||||
self.cover_viewer.add_video(tempVideo)
|
||||
#self.cover_viewer.add_image(tempVideo.getCoverfile())
|
||||
#dbMgr.close_db()
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
def on_key_press_event (self, stage, event):
|
||||
if event.keyval == clutter.keysyms.p:
|
||||
if self.paused:
|
||||
|
@ -49,7 +48,7 @@ class VideoPlayer():
|
|||
|
||||
|
||||
def begin(self, MenuMgr):
|
||||
|
||||
|
||||
#Create a backdrop for the player. In this case we just use the same background as the menus
|
||||
self.backdrop = clutter.CloneTexture(MenuMgr.get_skinMgr().get_Background())
|
||||
self.backdrop.set_size(self.stage.get_width(), self.stage.get_height())
|
||||
|
@ -66,42 +65,11 @@ class VideoPlayer():
|
|||
self.cover_viewer.show_all()
|
||||
self.cover_viewer.show()
|
||||
self.stage.add(self.cover_viewer)
|
||||
self.cover_viewer.toggle_details() #Turns the details group on
|
||||
begin_behaviour.apply(self.cover_viewer)
|
||||
|
||||
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):
|
||||
|
||||
#Fade everything out
|
||||
|
@ -154,20 +122,37 @@ class videoItem():
|
|||
|
||||
class coverViewer(clutter.Group):
|
||||
scaleFactor = 1.4
|
||||
inactiveOpacity = 150
|
||||
|
||||
def __init__(self, stage):
|
||||
def __init__(self, stage, width, height):
|
||||
clutter.Group.__init__(self)
|
||||
self.stage = stage
|
||||
self.videoLibrary = []
|
||||
self.textureLibrary = []
|
||||
self.current_video_details = video_details_group()
|
||||
self.num_covers = 0
|
||||
self.cover_size = 200 #A cover will be cover_size * cover_size (X * Y)
|
||||
self.cover_gap = 1
|
||||
|
||||
self.set_width(width)
|
||||
self.set_height(height)
|
||||
|
||||
self.num_rows = 3
|
||||
self.num_columns = 4 #int(self.stage.get_width() / self.cover_size)
|
||||
|
||||
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):
|
||||
self.videoLibrary.append(video)
|
||||
imagePath = video.getCoverfile()
|
||||
|
@ -179,30 +164,43 @@ class coverViewer(clutter.Group):
|
|||
width = int(self.cover_size * xy_ratio)
|
||||
tempTexture.set_width(width)
|
||||
tempTexture.set_height(self.cover_size)
|
||||
tempTexture.set_opacity(self.inactiveOpacity)
|
||||
|
||||
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)
|
||||
y = (self.num_covers % self.num_rows) * self.cover_size + ( (self.num_covers % self.num_rows) * self.cover_gap)
|
||||
#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)
|
||||
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)
|
||||
|
||||
self.add(tempTexture)
|
||||
self.num_covers = self.num_covers +1
|
||||
|
||||
def select_item(self, incomingItem, outgoingItem):
|
||||
outgoingTexture = self.get_nth_child(outgoingItem)
|
||||
incomingTexture = self.get_nth_child(incomingItem)
|
||||
|
||||
#Make sure the new texture is on the top
|
||||
#incomingTexture.raise_top()
|
||||
self.current_video_details.set_video(self.videoLibrary[incomingItem])
|
||||
|
||||
outgoingTexture = self.textureLibrary[outgoingItem]
|
||||
incomingTexture = self.textureLibrary[incomingItem]
|
||||
|
||||
self.timeline = clutter.Timeline(20,80)
|
||||
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
|
||||
behaviourNew = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
|
||||
behaviourOld = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
|
||||
behaviourNew_scale = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
|
||||
behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
|
||||
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
|
||||
|
||||
behaviourNew.apply(incomingTexture)
|
||||
behaviourOld.apply(outgoingTexture)
|
||||
behaviourOld_scale = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
|
||||
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
|
||||
|
||||
|
@ -211,17 +209,19 @@ class coverViewer(clutter.Group):
|
|||
def on_cursor_press_event(self, event):
|
||||
newItem = None
|
||||
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:
|
||||
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:
|
||||
#Check if we're already on the bottom row
|
||||
if not ((self.currentSelection % self.num_rows) == (self.num_rows-1)):
|
||||
newItem = self.currentSelection + 1
|
||||
if not (self.currentSelection > (len(self.textureLibrary)-1 - self.num_columns)):
|
||||
newItem = self.currentSelection + self.num_columns
|
||||
if event.keyval == clutter.keysyms.Up:
|
||||
#Check if we're already on the top row
|
||||
if not (self.currentSelection % self.num_rows) == 0:
|
||||
newItem = self.currentSelection - 1
|
||||
if not (self.currentSelection < self.num_columns):
|
||||
newItem = self.currentSelection - self.num_columns
|
||||
|
||||
if (newItem < 0) and (not newItem == None):
|
||||
newItem = self.currentSelection
|
||||
|
@ -229,6 +229,21 @@ class coverViewer(clutter.Group):
|
|||
#If there is movement, make the scale happen
|
||||
if not newItem == None:
|
||||
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)
|
||||
|
|
BIN
VideoPlayer.pyc
BIN
VideoPlayer.pyc
Binary file not shown.
Loading…
Reference in New Issue