This repository has been archived by the owner on Jan 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WatchFile.cs
73 lines (56 loc) · 2.09 KB
/
WatchFile.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
using MetroFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WMPLib;
using WolfWatch.Properties;
using WolfLib;
namespace WolfWatch
{
public class WatchFile
{
public String Name { get; set; }
public String Extension { get; set; }
public String Path { get; }
public String Description { get; set; }
public String Duration { get; set; }
public WatchFile(String name, String extension)
{
try
{
this.Name = name;
this.Extension = extension;
this.Path = Reference.PlaylistsPath + Program.mainForm.playlistsList.Text + "\\" + name;
if (Extension != ".web")
{
var player = new WindowsMediaPlayer();
var clip = player.newMedia(this.Path + this.Extension);
this.Duration = TimeSpan.FromSeconds(clip.duration).ToString();
}
Rasu VideoInfo = new Rasu(this.Path + ".info");
// Check updates
if (VideoInfo.Get("video_file_version") != Application.ProductVersion)
{
Rasu VideoInfoTemplate = new Rasu(Resources.video);
VideoInfo.MergeFile(VideoInfoTemplate);
VideoInfoTemplate.Set("video_file_version", Application.ProductVersion);
File.WriteAllText(VideoInfo.GetFilePath(), VideoInfoTemplate.GetFileContent());
VideoInfo.ReloadFile();
}
this.Description = VideoInfo.Get("video_description");
}
catch (Exception ex)
{
MetroMessageBox.Show(Program.mainForm, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public override string ToString()
{
return Name;
}
}
}