Skip to content

Commit 200ae44

Browse files
author
Nadeem Haidar
committed
Final touches before first release
1 parent d37b5c3 commit 200ae44

6 files changed

Lines changed: 28 additions & 11 deletions

File tree

YouTube15/Autostart.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace YouTube15
99
class Autostart
1010
{
1111
private const string RunLocation = @"Software\Microsoft\Windows\CurrentVersion\Run";
12-
private const string KeyName = "Spoti15Autostart";
12+
private const string KeyName = "YouTube15Autostart";
1313

1414
static private string RunValue()
1515
{

YouTube15/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void Main(string[] args)
141141
cm.MenuItems.Add(menu);
142142

143143
notico = new NotifyIcon();
144-
notico.Text = "Spoti15";
144+
notico.Text = "YouTube15";
145145
notico.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
146146
notico.ContextMenu = cm;
147147
notico.Visible = !Properties.Settings.Default.HideIcon;

YouTube15/YouTube15.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,20 @@ public void UpdateLcd()
209209

210210
try
211211
{
212-
//StatusResponse status = api.GetStatus();
213-
//int len = status.Track.Length;
212+
// no youtube video detected.
213+
if (api.noVideoDetected())
214+
{
215+
g.Clear(bgColor);
216+
DrawTextScroll(g, 1, "No YouTube videos detected.", true);
217+
DoRender();
218+
return;
219+
}
220+
214221
int len = (int)double.Parse(api.getDuration());
215-
//int pos = (int)status.PlayingPosition;
216222
int pos = (int)double.Parse(api.getCurrentTime());
217223
double perc = double.Parse(api.getCurrentTime()) / double.Parse(api.getDuration());
218224

219-
// DrawTextScroll(g, 0, status.Track.ArtistResource.Name + " - " + status.Track.AlbumResource.Name);
220225
DrawTextScroll(g, 0, api.getVideoTitle());
221-
// DrawTextScroll(g, 1, status.Track.TrackResource.Name);
222226
DrawTextScroll(g, 1, api.getUploader());
223227
DrawTextScroll(g, 3, String.Format("{0}:{1:D2}/{2}:{3:D2}", pos / 60, pos % 60, len / 60, len % 60));
224228

@@ -238,7 +242,7 @@ public void UpdateLcd()
238242
catch (NullReferenceException)
239243
{
240244
g.Clear(bgColor);
241-
DrawTextScroll(g, 1, "No track information available", false);
245+
DrawTextScroll(g, 1, "An error has occured.", true);
242246
}
243247
}
244248

YouTube15/YouTube15.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
34+
<PropertyGroup>
35+
<ApplicationIcon>icon.ico</ApplicationIcon>
36+
</PropertyGroup>
3437
<ItemGroup>
3538
<Reference Include="Newtonsoft.Json">
3639
<HintPath>.\Newtonsoft.Json.dll</HintPath>
@@ -83,6 +86,9 @@
8386
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8487
</None>
8588
</ItemGroup>
89+
<ItemGroup>
90+
<Content Include="icon.ico" />
91+
</ItemGroup>
8692
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8793
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
8894
Other similar extension points exist, see Microsoft.Common.targets.

YouTube15/YouTubeAPI.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public YouTubeAPI()
2323
_listener.Prefixes.Add("http://127.0.0.1:60024/");
2424
_listener.Start();
2525
_listener.BeginGetContext(new AsyncCallback(ProcessRequest), null);
26-
videos.Add("12345", new YoutubeVideo("12345", "No video", "Nima158"));
26+
27+
// add dummy video
28+
videos.Add("12345", new YoutubeVideo("12345", "Dummy video title", "Dummy video uploader"));
2729
priorityList.Add("12345");
2830
}
2931

@@ -67,7 +69,7 @@ private void ProcessRequest(IAsyncResult result)
6769
}
6870
else { video.paused = paused; }
6971

70-
72+
// terminate flag is on, so tab or window was closed.
7173
if (terminate)
7274
{
7375
videos.Remove(id);
@@ -110,6 +112,11 @@ public Boolean playing()
110112
return videos[priorityList.Last()].playing();
111113
}
112114

115+
public Boolean noVideoDetected()
116+
{
117+
return videos[priorityList.Last()].getID() == "12345";
118+
}
119+
113120
private class YoutubeVideo
114121
{
115122
private String id, videoTitle, uploader, currentTime, duration;
@@ -120,7 +127,7 @@ public YoutubeVideo(string id, string videoTitle, string uploader)
120127
this.videoTitle = videoTitle;
121128
this.uploader = uploader;
122129
this.currentTime = "0";
123-
this.duration = "1";
130+
this.duration = "0";
124131
this.paused = true;
125132
}
126133

YouTube15/icon.ico

121 KB
Binary file not shown.

0 commit comments

Comments
 (0)