Commit 42b0858d authored by Pedro Castro's avatar Pedro Castro

Fix #130 Video area not cleared after closing it

parent 0d8f0940
/*
* This file is part of Gnome Subtitles.
* Copyright (C) 2007-2018 Pedro Castro
* Copyright (C) 2007-2019 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -23,6 +23,7 @@ using Gtk;
using SubLib.Core.Domain;
using System;
using SubLib.Util;
using Gdk;
namespace GnomeSubtitles.Ui.VideoPreview {
......
/*
* This file is part of Gnome Subtitles.
* Copyright (C) 2006-2017 Pedro Castro
* Copyright (C) 2006-2019 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -82,8 +82,9 @@ public class PlayerPositionWatcher {
}
private void EmitPositionPulse (TimeSpan position) {
if (PositionPulse != null)
if (PositionPulse != null) {
PositionPulse(position);
}
}
}
......
......@@ -107,6 +107,8 @@ public class Video {
/// <exception cref="PlayerCouldNotOpenVideoException">Thrown if the player could not open the video.</exception>
public void Open (Uri videoUri) {
Close();
frame.Show();
player.Open(videoUri);
}
......@@ -122,20 +124,17 @@ public class Video {
tracker.Close();
overlay.Close();
/* Update the frame */
// frame.Child.Hide();
// frame.Child.Show();
frame.QueueDraw(); //To make sure the frame stops showing the last image from the closed video
frame.Ratio = Player.DefaultAspectRatio;
frame.Hide(); //To keep the frame from showing the last video image that was being played
SilentDisablePlayPauseButton();
UpdateSpeedControls(1);
SetControlsSensitivity(false);
}
public void Quit () {
player.Close();
player.Dispose();
}
public void SetLoopSelectionPlayback (bool enabled){
......@@ -283,8 +282,8 @@ public class Video {
}
}
private void handlePlayerLoading () {
if (isLoaded || (!isPlayerLoadComplete()))
private void HandlePlayerLoading () {
if (isLoaded || (!IsPlayerLoadComplete()))
return;
isLoaded = true;
......@@ -292,7 +291,7 @@ public class Video {
Base.UpdateFromVideoLoaded(player.VideoUri);
}
private bool isPlayerLoadComplete () {
private bool IsPlayerLoadComplete () {
return (player != null) && (player.State != MediaStatus.Unloaded) && (player.HasVideoInfo) && (player.HasDuration);
}
......@@ -318,17 +317,17 @@ public class Video {
}
private void OnPlayerFoundVideoInfo (VideoInfoEventArgs args) {
handlePlayerLoading();
HandlePlayerLoading();
}
private void OnPlayerStateChanged (StateEventArgs args) {
if (args.State == MediaStatus.Loaded) {
handlePlayerLoading();
HandlePlayerLoading();
}
}
private void OnPlayerFoundDuration (TimeSpan duration) {
handlePlayerLoading();
HandlePlayerLoading();
}
private void OnPlayerEndOfStream () {
......@@ -356,11 +355,11 @@ public class Video {
if (!(Base.IsDocumentLoaded))
return;
Subtitle firstSubtitle = Core.Base.Ui.View.Selection.FirstSubtitle;
Subtitle firstSubtitle = Base.Ui.View.Selection.FirstSubtitle;
if (firstSubtitle == null)
return;
Subtitle lastSubtitle = Core.Base.Ui.View.Selection.LastSubtitle;
Subtitle lastSubtitle = Base.Ui.View.Selection.LastSubtitle;
if ((position < firstSubtitle.Times.Start) || (position > lastSubtitle.Times.End))
SeekToSelection();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment