Exemple #1
0
    def get_videos(self):
        if sys.platform == 'linux':
            playlist = [
                'ladlaceydanny_2k.wmv', 'ladumawill_2k.wmv', 'rm11026_800.mp4',
                'ultra_hot_big.mp4'
            ]
        else:
            playlist = [
                'sintel_trailer-480p.webm', 'SAM_1297.MP4', 'SAM_1298.MP4',
                'SAM_1300.MP4'
            ]

        info = None

        def get_duration(fname):
            discoverer = GstPbutils.Discoverer.new(Gst.SECOND)
            return discoverer.discover_uri('file:' + fname)

        pixbuf_cell = Gtk.CellRendererPixbuf()
        tvc = Gtk.TreeViewColumn('Pix', pixbuf_cell)
        tvc.set_cell_data_func(pixbuf_cell, self._pixbuf_play_state)

        fname_cell = Gtk.CellRendererText()
        fname_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46,
                                                            blue=0))
        tvc.pack_start(fname_cell, True)
        tvc.set_cell_data_func(fname_cell, self._file_name)

        self.listview.append_column(tvc)

        time_cell = Gtk.CellRendererText()
        time_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc = Gtk.TreeViewColumn('time', time_cell, text=1)
        tvc.set_alignment(1.0)
        tvc.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)

        self.listview.append_column(tvc)

        for filename in playlist:
            full_filename = os.path.abspath(
                os.path.join(os.path.curdir, filename))
            print(full_filename)
            if os.path.isfile(full_filename):
                info = get_duration(pathname2url(full_filename))
                #self.playlist.append(filename)
                print(info.get_uri())
                print(info.get_duration())
                self.playlist.append([filename, info.get_duration()])
                self.store.append([filename, nsec2time(info.get_duration())])
                info = None

        self._init_controller()
        del playlist
        return True
Exemple #2
0
 def _update_slider(self):
     if not self.is_playing:
         return False
     else:
         success, duration = self._player.query_duration(Gst.Format.TIME)
         if not success:
             raise Exception("Couldn't fetch video duration")
         else:
             self.slider.set_range(0, duration / Gst.SECOND)
             self.lbl_dur.set_text(nsec2time(duration))
         
             success, position = self._player.query_position(Gst.Format.TIME)
             if not success:
                 raise Exception("Couldn't fetch current video position to update slider")
     
         self.slider.handler_block(self._slider_handle_id)
         self.slider.set_value(float(position) / Gst.SECOND)
         self.lbl_pos.set_text(nsec2time(position))
         self.slider.handler_unblock(self._slider_handle_id)
         return True
Exemple #3
0
    def _update_slider(self):
        if not self.is_playing:
            return False
        else:
            success, duration = self._player.query_duration(Gst.Format.TIME)
            if not success:
                raise Exception("Couldn't fetch video duration")
            else:
                self.slider.set_range(0, duration / Gst.SECOND)
                self.lbl_dur.set_text(nsec2time(duration))

                success, position = self._player.query_position(
                    Gst.Format.TIME)
                if not success:
                    raise Exception(
                        "Couldn't fetch current video position to update slider"
                    )

            self.slider.handler_block(self._slider_handle_id)
            self.slider.set_value(float(position) / Gst.SECOND)
            self.lbl_pos.set_text(nsec2time(position))
            self.slider.handler_unblock(self._slider_handle_id)
            return True
Exemple #4
0
    def get_videos(self):
        if sys.platform == 'linux':
            playlist = ['ladlaceydanny_2k.wmv', 'ladumawill_2k.wmv', 'rm11026_800.mp4', 'ultra_hot_big.mp4']
        else:
            playlist = ['sintel_trailer-480p.webm', 'SAM_1297.MP4', 'SAM_1298.MP4', 'SAM_1300.MP4']
        
        info = None
         
        def get_duration(fname):
            discoverer = GstPbutils.Discoverer.new(Gst.SECOND)
            return discoverer.discover_uri('file:'+fname)
        
        pixbuf_cell = Gtk.CellRendererPixbuf()
        tvc = Gtk.TreeViewColumn('Pix', pixbuf_cell)
        tvc.set_cell_data_func(pixbuf_cell, self._pixbuf_play_state)
        
        fname_cell = Gtk.CellRendererText()
        fname_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc.pack_start(fname_cell, True)
        tvc.set_cell_data_func(fname_cell, self._file_name)
        
        self.listview.append_column(tvc)
        
        time_cell = Gtk.CellRendererText()
        time_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc = Gtk.TreeViewColumn('time', time_cell, text=1)
        tvc.set_alignment(1.0)
        tvc.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
        
        self.listview.append_column(tvc)
        
        for filename in playlist:
            full_filename = os.path.abspath(os.path.join(os.path.curdir, filename))
            print(full_filename)
            if os.path.isfile(full_filename):
                info = get_duration(pathname2url(full_filename))
                #self.playlist.append(filename)
                print(info.get_uri())
                print(info.get_duration())
                self.playlist.append([filename, info.get_duration()])
                self.store.append([filename, nsec2time(info.get_duration())])
                info = None

        self._init_controller()
        del playlist
        return True
Exemple #5
0
 def _on_slider_changed(self, slider):
     seek_time = slider.get_value()
     self.lbl_pos.set_text(nsec2time(seek_time * Gst.SECOND))
     self._player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, seek_time * Gst.SECOND)
Exemple #6
0
 def _change_duration(self):
     self.lbl_dur.set_text(nsec2time(self.playlist[self.play_index][1]))
Exemple #7
0
    def get_videos(self, prefix, isDate, period):
        # vid_list = glob.glob(os.path.join(self.app.config['VIDEO_PATH'], prefix+'_*'))
        vid_list = glob.glob(os.path.join('.', prefix+'_*'))

        if len(vid_list) == 0:
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,
                                       Gtk.ButtonsType.CLOSE, self.NOT_EXISTS_VIDEO_TITLE)
            dialog.format_secondary_text(self.NOT_EXISTS_VIDEO_MESSAGE)
            dialog.run()
            print('Error dialog closed')
            dialog.destroy()

            return False

        video_count = 0
        info = None
        create_time = int(time.time())

        def get_duration(fname):
            discoverer = GstPbutils.Discoverer.new(Gst.SECOND)
            return discoverer.discover_uri('file:'+fname)

        pixbuf_cell = Gtk.CellRendererPixbuf()
        tvc = Gtk.TreeViewColumn('Pix', pixbuf_cell)
        tvc.set_cell_data_func(pixbuf_cell, self._pixbuf_play_state)

        fname_cell = Gtk.CellRendererText()
        fname_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc.pack_start(fname_cell, True)
        tvc.set_cell_data_func(fname_cell, self._file_name)

        self.listview.append_column(tvc)

        time_cell = Gtk.CellRendererText()
        time_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc = Gtk.TreeViewColumn('time', time_cell, text=1)
        tvc.set_alignment(1.0)
        tvc.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)

        self.listview.append_column(tvc)

        for filename in vid_list:
            full_filename = os.path.join(self.app.config['VIDEO_PATH'], filename)
            if os.path.isfile(full_filename):
                if (create_time - os.path.getctime(full_filename)) >= 1800:
                    _date, _time = str(filename.split('.')[0]).split('_')[1:]
                    if isDate:
                        if int(_date) >= period[0] and int(_date) <= period[1]:
                            info = get_duration(pathname2url(full_filename))
                    else:
                        if int(_time) >= period[0] and int(_time) <= period[1]:
                            info = get_duration(pathname2url(full_filename))

                    if info is not None and isinstance(info, GstPbutils.DiscovererInfo):
                        video_count = video_count + 1
                        self._playlist.append([filename, info.get_duration()])
                        self.store.append([filename, nsec2time(info.get_duration())])
                        info = None

        if video_count == 0:
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,
                                       Gtk.ButtonsType.CLOSE, self.NOT_EXISTS_VIDEO_TITLE)
            dialog.format_secondary_text(self.NOT_EXISTS_VIDEO_MESSAGE)
            dialog.run()
            print('Error dialog closed')
            dialog.destroy()
            del vid_list
            return False

        del vid_list
        self._init_controller()
        return True
Exemple #8
0
 def _on_slider_changed(self, slider):
     seek_time = slider.get_value()
     self.lbl_pos.set_text(nsec2time(seek_time * Gst.SECOND))
     self._player.seek_simple(Gst.Format.TIME,
                              Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
                              seek_time * Gst.SECOND)
Exemple #9
0
 def _change_duration(self):
     self.lbl_dur.set_text(nsec2time(self._playlist[self._play_index][1]))
Exemple #10
0
    def get_videos(self, prefix, isDate, period):
        # vid_list = glob.glob(os.path.join(self.app.config['VIDEO_PATH'], prefix+'_*'))
        vid_list = glob.glob(os.path.join('.', prefix + '_*'))

        if len(vid_list) == 0:
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,
                                       Gtk.ButtonsType.CLOSE,
                                       self.NOT_EXISTS_VIDEO_TITLE)
            dialog.format_secondary_text(self.NOT_EXISTS_VIDEO_MESSAGE)
            dialog.run()
            print('Error dialog closed')
            dialog.destroy()

            return False

        video_count = 0
        info = None
        create_time = int(time.time())

        def get_duration(fname):
            discoverer = GstPbutils.Discoverer.new(Gst.SECOND)
            return discoverer.discover_uri('file:' + fname)

        pixbuf_cell = Gtk.CellRendererPixbuf()
        tvc = Gtk.TreeViewColumn('Pix', pixbuf_cell)
        tvc.set_cell_data_func(pixbuf_cell, self._pixbuf_play_state)

        fname_cell = Gtk.CellRendererText()
        fname_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46,
                                                            blue=0))
        tvc.pack_start(fname_cell, True)
        tvc.set_cell_data_func(fname_cell, self._file_name)

        self.listview.append_column(tvc)

        time_cell = Gtk.CellRendererText()
        time_cell.set_property('foreground-rgba', Gdk.RGBA(green=0.46, blue=0))
        tvc = Gtk.TreeViewColumn('time', time_cell, text=1)
        tvc.set_alignment(1.0)
        tvc.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)

        self.listview.append_column(tvc)

        for filename in vid_list:
            full_filename = os.path.join(self.app.config['VIDEO_PATH'],
                                         filename)
            if os.path.isfile(full_filename):
                if (create_time - os.path.getctime(full_filename)) >= 1800:
                    _date, _time = str(filename.split('.')[0]).split('_')[1:]
                    if isDate:
                        if int(_date) >= period[0] and int(_date) <= period[1]:
                            info = get_duration(pathname2url(full_filename))
                    else:
                        if int(_time) >= period[0] and int(_time) <= period[1]:
                            info = get_duration(pathname2url(full_filename))

                    if info is not None and isinstance(
                            info, GstPbutils.DiscovererInfo):
                        video_count = video_count + 1
                        self._playlist.append([filename, info.get_duration()])
                        self.store.append(
                            [filename,
                             nsec2time(info.get_duration())])
                        info = None

        if video_count == 0:
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,
                                       Gtk.ButtonsType.CLOSE,
                                       self.NOT_EXISTS_VIDEO_TITLE)
            dialog.format_secondary_text(self.NOT_EXISTS_VIDEO_MESSAGE)
            dialog.run()
            print('Error dialog closed')
            dialog.destroy()
            del vid_list
            return False

        del vid_list
        self._init_controller()
        return True