Ejemplo n.º 1
0
    def run(self):
        editorstate.PLAYER().jack_output_on()

        time.sleep(1.0)

        Gdk.threads_enter()
        self.window.set_gui_state()
        Gdk.threads_leave()
Ejemplo n.º 2
0
 def set_gui_state(self):
     if editorstate.PLAYER().jack_output_filter != None:
         self.use_button.set_sensitive(False)
         self.dont_use_button.set_sensitive(True)
         self.jack_output_status_value.set_text("<b>ON</b>")
         self.jack_output_status_value.set_use_markup(True)
     else:
         self.dont_use_button.set_sensitive(False)
         self.use_button.set_sensitive(True)
         self.jack_output_status_value.set_text("<b>OFF</b>")
         self.jack_output_status_value.set_use_markup(True)
Ejemplo n.º 3
0
def close_master_meter():
    global _master_volume_meter
    if _master_volume_meter == None:
        return

    editorstate.PLAYER().stop_playback()

    # To avoid crashes we can't actually lose widget object before everything is
    # cleaned up well but _master_volume_meter == None is flag for doing audio updates so we must
    # set that first
    temp_meter = _master_volume_meter
    _master_volume_meter = None

    _destroy_level_filters(False)

    # Close and destroy window when gtk finds time to do it
    GLib.idle_add(_master_meter_destroy, temp_meter)
Ejemplo n.º 4
0
def close_audio_monitor():

    global _monitor_window
    if _monitor_window == None:
        return

    editorstate.PLAYER().stop_playback()

    # We're using _monitor_window as a flag here so we need to set to _monitor_window = None
    # to stop _audio_monitor_update running before destroying resources used by it
    temp_window = _monitor_window
    _monitor_window = None

    _destroy_level_filters(True)

    # Close and destroy window when gtk finds time to do it
    GLib.idle_add(_audio_monitor_destroy, temp_window)
Ejemplo n.º 5
0
    def _draw(self, event, cr, allocation):
        """
        Callback for repaint from CairoDrawableArea.
        We get cairo contect and allocation.
        """
        x, y, w, h = allocation
        
        # Draw bb
        draw_color = BG_COLOR
        if self.disabled:
            draw_color = DISABLED_BG_COLOR
        cr.set_source_rgb(*draw_color)
        cr.rectangle(0,0,w,h)
        cr.fill()
        
        # Draw selected area if marks set
        if self.mark_in_norm >= 0 and self.mark_out_norm >= 0:
            cr.set_source_rgba(*SELECTED_RANGE_COLOR)
            m_in = self._get_panel_pos(self.mark_in_norm)
            m_out = self._get_panel_pos(self.mark_out_norm)
            cr.rectangle(m_in + 1, 0, m_out - m_in - 2, h)
            cr.fill()
                
        # Get area between end pads
        active_width = w - 2 * END_PAD

        # Draw lines
        cr.set_line_width(1.0)
        x_step = float(active_width) / (LINE_COUNT)        
        for i in range(LINE_COUNT + 1):
            cr.move_to(int((i) * x_step) + END_PAD + 0.5, -0.5)
            cr.line_to(int((i) * x_step) + END_PAD + 0.5, LINE_HEIGHT + 0.5)
        for i in range(LINE_COUNT + 1):
            cr.move_to(int((i) * x_step) + END_PAD + 0.5, BAR_HEIGHT)
            cr.line_to(int((i) * x_step) + END_PAD + 0.5, 
                       BAR_HEIGHT - LINE_HEIGHT  + 0.5)
            
        cr.set_source_rgb(*LINE_COLOR)
        cr.stroke()

        # Draw mark in and mark out
        self.draw_mark_in(cr, h)
        self.draw_mark_out(cr, h)

        # Draw position pointer
        if self.disabled:
            return
        cr.set_line_width(2.0)
        cr.set_source_rgb(*POINTER_COLOR)
        cr.move_to(self._pos + 0.5, 0)
        cr.line_to(self._pos + 0.5, BAR_HEIGHT)
        cr.stroke()

        # This only needed when this widget is used in main app, 
        # for gmic.py process self.handle_trimmodes == False.
        if self.handle_trimmodes == True:
            speed = editorstate.PLAYER().producer.get_speed()
            if speed != 1.0 and speed != 0.0:
                cr.set_source_rgb(*SPEED_TEST_COLOR)
                cr.select_font_face ("sans-serif",
                                     cairo.FONT_SLANT_NORMAL,
                                     cairo.FONT_WEIGHT_BOLD)
                cr.set_font_size(11)
                disp_str = str(speed) + "x"
                tx, ty, twidth, theight, dx, dy = cr.text_extents(disp_str)
                cr.move_to( w/2 - twidth/2, 13)
                cr.show_text(disp_str)
Ejemplo n.º 6
0
def display_clip_in_monitor(clip_monitor_currently_active=False):
    """
    Sets mltplayer producer to be video file clip and updates GUI.
    """
    if MONITOR_MEDIA_FILE() == None:
        gui.editor_window.clip_editor_b.set_active(False)
        return

    global save_monitor_frame
    save_monitor_frame = True

    # Opening clip exits trim modes
    if not editorstate.current_is_move_mode():
        set_clip_edit_mode_callback()

    gui.clip_editor_b.set_sensitive(True)
    editorstate._timeline_displayed = False

    # Save timeline pos if so directed.
    if clip_monitor_currently_active == False:
        global saved_timeline_pos
        saved_timeline_pos = PLAYER().current_frame()
        editorstate.tline_shadow_frame = saved_timeline_pos

    # If we're already displaying monitor clip we stop consumer
    # to supress timeline flashing between monitor clips
    if clip_monitor_currently_active == False:
        editorstate.PLAYER().consumer.stop()

    # Clear old clip
    current_sequence().clear_hidden_track()

    # Create and display clip on hidden track
    if MONITOR_MEDIA_FILE(
    ).type == appconsts.PATTERN_PRODUCER or MONITOR_MEDIA_FILE(
    ).type == appconsts.IMAGE_SEQUENCE:
        # pattern producer or image sequence
        clip_producer = current_sequence().display_monitor_clip(
            None, MONITOR_MEDIA_FILE())
    else:
        # File producers
        clip_producer = current_sequence().display_monitor_clip(
            MONITOR_MEDIA_FILE().path)

    # Timeline flash does not happen if we start consumer after monitor clip is
    # already on sequence
    if clip_monitor_currently_active == False:
        editorstate.PLAYER().consumer.start()

    # IMAGE_SEQUENCE files always returns 15000 for get_length from mlt so we have to monkeypatch that method to get correct results
    if MONITOR_MEDIA_FILE().type == appconsts.IMAGE_SEQUENCE:
        clip_producer.get_length = lambda: MONITOR_MEDIA_FILE().length

    clip_producer.mark_in = MONITOR_MEDIA_FILE().mark_in
    clip_producer.mark_out = MONITOR_MEDIA_FILE().mark_out

    # Give IMAGE and PATTERN_PRODUCER media types default mark in and mark out if not already set.
    # This makes them reasonably short and trimmable in both directions.
    if clip_producer.media_type == appconsts.IMAGE or clip_producer.media_type == appconsts.PATTERN_PRODUCER:
        if clip_producer.mark_in == -1 and clip_producer.mark_out == -1:
            center_frame = clip_producer.get_length() / 2
            default_length_half = 75
            mark_in = center_frame - default_length_half
            mark_out = center_frame + default_length_half - 1
            clip_producer.mark_in = mark_in
            clip_producer.mark_out = mark_out
            MONITOR_MEDIA_FILE().mark_in = mark_in
            MONITOR_MEDIA_FILE().mark_out = mark_out

    # Display frame, marks and pos
    gui.pos_bar.update_display_from_producer(clip_producer)

    display_monitor_clip_name()

    if MONITOR_MEDIA_FILE().type == appconsts.IMAGE or \
        MONITOR_MEDIA_FILE().type == appconsts.PATTERN_PRODUCER:
        PLAYER().seek_frame(0)
    else:
        if editorpersistance.prefs.remember_monitor_clip_frame:
            PLAYER().seek_frame(MONITOR_MEDIA_FILE().current_frame)
        else:
            PLAYER().seek_frame(0)

    display_marks_tc()

    gui.pos_bar.widget.grab_focus()
    gui.media_list_view.widget.queue_draw()

    if editorpersistance.prefs.auto_play_in_clip_monitor == True:
        PLAYER().start_playback()

    repaint_tline()
Ejemplo n.º 7
0
    def _draw(self, event, cr, allocation):
        """
        Callback for repaint from CairoDrawableArea.
        We get cairo contect and allocation.
        """
        x, y, w, h = allocation

        # Draw bb
        draw_color = BG_COLOR
        if self.disabled:
            draw_color = DISABLED_BG_COLOR
        cr.set_source_rgb(*draw_color)
        cr.rectangle(0, 0, w, h)
        cr.fill()

        # Draw selected area if marks set
        if self.mark_in_norm >= 0 and self.mark_out_norm >= 0:
            cr.set_source_rgba(*SELECTED_RANGE_COLOR)
            m_in = self._get_panel_pos(self.mark_in_norm)
            m_out = self._get_panel_pos(self.mark_out_norm)
            cr.rectangle(m_in + 1, 0, m_out - m_in - 2, h)
            cr.fill()

        # Get area between end pads
        active_width = w - 2 * END_PAD

        # Draw lines
        cr.set_line_width(1.0)
        x_step = float(active_width) / (LINE_COUNT)
        for i in range(LINE_COUNT + 1):
            cr.move_to(int((i) * x_step) + END_PAD + 0.5, -0.5)
            cr.line_to(int((i) * x_step) + END_PAD + 0.5, LINE_HEIGHT + 0.5)
        for i in range(LINE_COUNT + 1):
            cr.move_to(int((i) * x_step) + END_PAD + 0.5, BAR_HEIGHT)
            cr.line_to(
                int((i) * x_step) + END_PAD + 0.5,
                BAR_HEIGHT - LINE_HEIGHT + 0.5)

        cr.set_source_rgb(*LINE_COLOR)
        cr.stroke()

        # Draw mark in and mark out
        self.draw_mark_in(cr, h)
        self.draw_mark_out(cr, h)

        # Draw timeline markers, monitor media items don't have markers only timeline clips made from them do.markers
        if editorstate.timeline_visible():
            try:  # this gets attempted on load sotimes before current sequence is available.
                markers = editorstate.current_sequence().markers
                for i in range(0, len(markers)):
                    marker_name, marker_frame = markers[i]
                    marker_frame_norm = float(marker_frame) / self.length
                    x = math.floor(self._get_panel_pos(marker_frame_norm))
                    cr.set_source_surface(self.MARKER_ICON, x - 4, 0)
                    cr.paint()
            except:
                pass

        # Draw position pointer
        if self.disabled:
            return
        cr.set_source_surface(self.POINTER_ICON, self._pos - 3, 0)
        cr.paint()

        # This only needed when this widget is used in main app,
        # for gmic.py process self.handle_trimmodes == False.
        if self.handle_trimmodes == True:
            speed = editorstate.PLAYER().producer.get_speed()
            if speed != 1.0 and speed != 0.0:
                cr.set_source_rgb(*SPEED_TEST_COLOR)
                cr.select_font_face("sans-serif", cairo.FONT_SLANT_NORMAL,
                                    cairo.FONT_WEIGHT_BOLD)
                cr.set_font_size(10)
                disp_str = str(speed) + "x"
                tx, ty, twidth, theight, dx, dy = cr.text_extents(disp_str)
                cr.move_to(w / 2 - twidth / 2, 9)
                cr.show_text(disp_str)
Ejemplo n.º 8
0
def create_sdl_2_consumer():
    GObject.source_remove(sdl2_timeout_id)
    print "Creating SDL2 consumer..."
    editorstate.PLAYER().create_sdl2_video_consumer()