-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScreenWindow.xaml.cs
88 lines (76 loc) · 2.66 KB
/
ScreenWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.ComponentModel;
using System.IO;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Animation;
using Vlc.DotNet.Forms;
namespace 素材合成
{
/// <summary>
/// ScreenWindow.xaml 的交互逻辑
/// </summary>
public partial class ScreenWindow
{
#region 构造函数
string _Path;
Model.ScreenNode screenNode;
public ScreenWindow(Model.ScreenNode _screenNode)
{
InitializeComponent();
screenNode = _screenNode;
this.Left = screenNode.ScreenItem.Bounds.X;
this.Top = screenNode.ScreenItem.Bounds.Y;
_Path = screenNode.VideoPath;
VlcPlayer.Playing += VlcPlayer_Playing;
this.Loaded += ScreenWindow_Loaded;
}
private void VlcPlayer_Playing(object sender, Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs e)
{
var time = VlcPlayer.Length / 1000;
}
private void ScreenWindow_Loaded(object sender, RoutedEventArgs e)
{
var senderWindow = sender as ScreenWindow;
senderWindow.Left = screenNode.ScreenItem.Bounds.X;
senderWindow.Top = screenNode.ScreenItem.Bounds.Y;
senderWindow.Width = screenNode.ScreenItem.Bounds.Width;
senderWindow.Height = screenNode.ScreenItem.Bounds.Height;
new Thread(Play).Start();
//VlcPlayer.Position = pos;
}
void Play()
{
// Thread.Sleep(1000);
this.Dispatcher.BeginInvoke(new Action(() => {
VlcPlayer.Play(new FileInfo(_Path));
}));
}
#endregion
private void VlcPlayer_VlcLibDirectoryNeeded(object sender, VlcLibDirectoryNeededEventArgs e)
{
var vlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine("libvlc", "win-x86"));//Environment.Is64BitProcess ? "win-x64" : "win-x86"
e.VlcLibDirectory = vlcLibDirectory;
}
private void HideWindow(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.Close();
}
private void Header_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
//Max_MouseLeftButtonDown(null, null);
e.Handled = true;
return;
}
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
}
}