Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更改音频播放方案 #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added PowerfulWindSlickedBackHair/Assets/BlueError.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PowerfulWindSlickedBackHair/Assets/blue.bmp
Binary file not shown.
Binary file modified PowerfulWindSlickedBackHair/Assets/font.ttf
Binary file not shown.
Binary file added PowerfulWindSlickedBackHair/Assets/yellow.bmp
Binary file not shown.
17 changes: 0 additions & 17 deletions PowerfulWindSlickedBackHair/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 40 additions & 33 deletions PowerfulWindSlickedBackHair/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using AxWMPLib;
using NAudio.Wave;
using PowerfulWindSlickedBackHair.Tools;
using PowerfulWindSlickedBackHair.Windows;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

using SoundTouch;
using System.Collections.Generic;

namespace PowerfulWindSlickedBackHair
{
Expand All @@ -28,9 +30,10 @@ public partial class MainForm : Form

private JumpingYukiForm yukiForm;

private int offset = 3;
private double bgRate = 1;
private int offset = 40;
private float bgRate = 1;
private int bgOffset = 0;
private float jumpYukiForm_jumpSpace = 1f;

private bool isSummonBackgroundForm;

Expand All @@ -46,6 +49,8 @@ public MainForm()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;


Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
base.Location = new Point(workingArea.Width - base.Size.Width, workingArea.Height - base.Size.Height);
if (File.Exists("Offset.txt"))
Expand All @@ -54,8 +59,9 @@ public MainForm()
{
var array = File.ReadAllLines("Offset.txt");
offset = int.Parse(array[0].Split(':')[1]);
bgRate = double.Parse(array[1].Split(':')[1]);
bgRate = float.Parse(array[1].Split(':')[1]);
bgOffset = int.Parse(array[2].Split(':')[1]);
jumpYukiForm_jumpSpace = float.Parse(array[3].Split(':')[1]);
}
catch (Exception)
{
Expand Down Expand Up @@ -104,11 +110,11 @@ public static void ChangeWallpaper(int type)
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, currentWallpaper, 3);
break;
case 1:
string whiteWallpaper = Application.StartupPath + "\\Assets\\yellow.png";
string whiteWallpaper = Application.StartupPath + "\\Assets\\yellow.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, whiteWallpaper, 3);
break;
case 2:
whiteWallpaper = Application.StartupPath + "\\Assets\\blue.png";
whiteWallpaper = Application.StartupPath + "\\Assets\\blue.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, whiteWallpaper, 3);
break;
}
Expand All @@ -125,8 +131,6 @@ public static void ChangeWallpaper(int type)

private void MainForm_Load(object sender, EventArgs e)
{
//CmdHelper.ExeCommand("taskkill /im cmd.exe /f");

//最小化所有窗口
IntPtr lHwnd = FindWindow("Shell_TrayWnd", "");
SendMessage(lHwnd, WM_COMMAND, MIN_ALL, IntPtr.Zero);
Expand All @@ -150,7 +154,7 @@ private void MainForm_Load(object sender, EventArgs e)
if (lastFrame != Tracker.frame)
{
lastFrame = Tracker.frame;
frameLabel.Text = Tracker.frame.ToString();
frameLabel.Text = string.Format("{0} | {1}", Tracker.frame, soundPlayer.CurrentTime);
Update(Tracker.frame, Screen.PrimaryScreen.WorkingArea);
Thread.Sleep(num / 2);
}
Expand Down Expand Up @@ -187,51 +191,41 @@ private void MainForm_Load(object sender, EventArgs e)
}
});

void BeginWinDance()
{
thread.Start();
thread2.Start();
}

new Thread(() =>
{
if (bgOffset >= 0)
{
PlaySound();
Thread.Sleep(Math.Abs(bgOffset));
BeginWinDance();
thread.Start();
thread2.Start();
}
else
{
BeginWinDance();
thread.Start();
thread2.Start();
Thread.Sleep(Math.Abs(bgOffset));
PlaySound();
}
}).Start();

}

SoundPlayer soundPlayer;

void PlaySound()
{
axWindowsMediaPlayer1.URL = "Assets\\Audio.mp3";
axWindowsMediaPlayer1.settings.volume = 100;
axWindowsMediaPlayer1.settings.rate = bgRate;
axWindowsMediaPlayer1.Ctlcontrols.play();
bool soundReady = false;
axWindowsMediaPlayer1.PlayStateChange += (_, eState) =>
{
if ((int)WMPLib.WMPPlayState.wmppsPlaying == eState.newState)
soundReady = true;
};
while (!soundReady)
Thread.Sleep(1);
soundPlayer = new SoundPlayer();
soundPlayer.Load(@"Assets\Audio.mp3");
soundPlayer.Play();
soundPlayer.Rate = bgRate;
}

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
ChangeWallpaper(0);
Tracker.StopAll();
axWindowsMediaPlayer1.close();
soundPlayer.Dispose();
notifyIcon1.Visible = false;
notifyIcon1.Dispose();
ChangeWallpaper(0);
Expand All @@ -243,10 +237,10 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
}).Start();
}

bool blueScreenIsShow;
private void Update(long f, Rectangle screen)
{
long num = f;

//壁纸更新
if (num == 60)
this.WindowState = FormWindowState.Minimized;
Expand All @@ -260,6 +254,18 @@ private void Update(long f, Rectangle screen)
ChangeWallpaper(1);
else if (num >= 2870 && num < 2880)
ChangeWallpaper(0);
else if (num >= 2880 && num < 2890)
{
//蓝屏
if (blueScreenIsShow)
return;
blueScreenIsShow = true;
new Thread(() =>
{
BlueScreen blueScreen = new BlueScreen();
blueScreen.ShowDialog();
}).Start();
}
else if (num > 3000)
this.Close();

Expand All @@ -285,7 +291,7 @@ private void Update(long f, Rectangle screen)
}

long num3 = num2;
if (num3 < 9 || num3 >= 14)
if (num3 < 9 || num3 >= 24)
{
switch (num2)
{
Expand Down Expand Up @@ -640,6 +646,7 @@ private void Update(long f, Rectangle screen)
{
isSummonJumpingForm = true;
yukiForm = new JumpingYukiForm();
yukiForm.JumpSpace = jumpYukiForm_jumpSpace;
yukiForm.ShowDialog(new Point(screen.Width / 2 - yukiForm.Width / 2, screen.Height / 2 - yukiForm.Height / 2), 2864);
});
thread23.Start();
Expand Down
11 changes: 0 additions & 11 deletions PowerfulWindSlickedBackHair/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,4 @@
<metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>161, 17</value>
</metadata>
<data name="axWindowsMediaPlayer1.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB
AAAAAQAAAAAAAAAAAAAAAKIAAAABAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA
AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAZgB1AGwAbAAAAAsA
AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAANAYAAOcB
AAAL
</value>
</data>
</root>
Binary file added PowerfulWindSlickedBackHair/NAudio.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions PowerfulWindSlickedBackHair/Offset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
窗口播放速率(30~60):40
音频播放速率(0.95~1.05):1.000
音频提前播放毫秒数(-500~500):0
JumpingYukiForm窗口跳跃空间【部分旧系统可能导致小雪跳跃鬼畜,可修改此处数值。默认1.0, 部分系统可能需要1.2】(1.00-1.29):1.00
Loading