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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using System.IO;
namespace ShiftOS.WinForms.Applications
{
[AppscapeEntry("Video Player", "Play .mp4 files or .wmv files as videos inside ShiftOS! Perfect for a shifted movie night.", 1524, 1000, "file_skimmer", "Entertainment")]
[DefaultTitle("Video Player")]
[Launcher("Video Player", false, null, "Entertainment")]
[WinOpen("video_player")]
public partial class VideoPlayer : UserControl, IShiftOSWindow
{
public VideoPlayer()
{
InitializeComponent();
}
public void OnLoad()
{
tmr.Interval = 50;
tmr.Tick += (o, a) =>
{
try
{
double end = wpaudio.currentMedia.duration;
double pos = wpaudio.Ctlcontrols.currentPosition;
pgplaytime.Maximum = (int)end;
pgplaytime.Value = (int)pos;
}
catch { }
};
tmr.Start();
}
public void OnSkinLoad()
{
wpaudio.uiMode = "none";
wpaudio.Show();
pgplaytime.Width = flcontrols.Width - btnplay.Width - 25;
wpaudio.enableContextMenu = false;
}
public bool OnUnload()
{
if(!string.IsNullOrWhiteSpace(filePath))
if (File.Exists(filePath))
File.Delete(filePath);
tmr.Stop();
return true;
}
public void OnUpgrade()
{
}
Timer tmr = new Timer();
string filePath = null;
private void addSongToolStripMenuItem_Click(object sender, EventArgs e)
{
FileSkimmerBackend.GetFile(new[] { ".mp4", ".wmv" }, FileOpenerStyle.Open, (result) =>
{
var finf = ShiftOS.Objects.ShiftFS.Utils.GetFileInfo(result);
File.WriteAllBytes(finf.Name, ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(result));
filePath = finf.Name;
wpaudio.URL = filePath;
wpaudio.Ctlcontrols.play();
btnplay.Text = "Pause";
});
}
private void btnplay_Click(object sender, EventArgs e)
{
if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
wpaudio.Ctlcontrols.pause();
btnplay.Text = "Play";
}
else if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused)
{
wpaudio.Ctlcontrols.play();
btnplay.Text = "Pause";
}
}
bool scrubbing = false;
private void startScrub(object sender, MouseEventArgs e)
{
scrubbing = true;
}
static public double linear(double x, double x0, double x1, double y0, double y1)
{
if ((x1 - x0) == 0)
{
return (y0 + y1) / 2;
}
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
private void pgplaytime_MouseMove(object sender, MouseEventArgs e)
{
if (wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying || wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused)
try
{
if (scrubbing)
{
double end = wpaudio.currentMedia.duration;
double result = linear(e.X, 0, pgplaytime.Width, 0, end);
wpaudio.Ctlcontrols.currentPosition = result;
}
}
catch { }
}
private void pgplaytime_MouseUp(object sender, MouseEventArgs e)
{
scrubbing = false;
}
}
}
|