1
0
mirror of synced 2025-01-18 17:14:07 +01:00

曲をダウンロード可能に (#197)

* 曲をダウンロード可能に

* Commit漏れ

* Cacheフォルダがない場合クラッシュする問題を修正
This commit is contained in:
Takkkom 2022-05-24 07:39:41 +09:00 committed by GitHub
parent e8cb4aed41
commit 7f3bd0a5b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 215 additions and 121 deletions

View File

@ -95,6 +95,27 @@ namespace TJAPlayer3
#region [ Fetch song list ]
//-----------------
public void UpdateDownloadBox()
{
C曲リストード downloadBox = null;
for (int i = 0; i < TJAPlayer3.Songs管理.list曲ルート.Count; i++)
{
if (TJAPlayer3.Songs管理.list曲ルート[i].strジャンル == "Download")
downloadBox = TJAPlayer3.Songs管理.list曲ルート[i];
}
for (int i = 0; i < downloadBox.list子リスト.Count; i++)
{
if (downloadBox.list子リスト[i].eード種別 != C曲リストード.Eード種別.BACKBOX)
{
downloadBox.list子リスト.Remove(downloadBox.list子リスト[i]);
i--;
}
}
t曲を検索してリストを作成する(@"Songs\S3 Download", true, downloadBox.list子リスト, downloadBox);
tSongsDBになかった曲をファイルから読み込んで反映する(downloadBox.list子リスト);
}
public void t曲を検索してリストを作成する( string str基点フォルダ, bool b子BOXへ再帰する )
{
this.t曲を検索してリストを作成する( str基点フォルダ, b子BOXへ再帰する, this.list曲ルート, null );

View File

@ -59,6 +59,8 @@ namespace TJAPlayer3
dbCDN = TJAPlayer3.Databases.DBCDN;
dbCDNData = null;
IsDownloading = false;
#region [Main menu]
this.ttkMainMenuOpt = new TitleTextureKey[3];
@ -112,6 +114,8 @@ namespace TJAPlayer3
{
// On de-activation
TJAPlayer3.Songs管理.UpdateDownloadBox();
base.On非活性化();
}
@ -272,7 +276,14 @@ namespace TJAPlayer3
#endregion
if (IsDownloading)
{
TJAPlayer3.Tx.OnlineLounge_Box.t2D描画(TJAPlayer3.app.Device, 0, 0);
var text = TJAPlayer3.stage選曲.act曲リスト.ResolveTitleTexture(
new TitleTextureKey("DownloadNow", this.pfOLFontLarge, Color.White, Color.Black, 1000));
text.t2D中心基準描画(TJAPlayer3.app.Device, 640, 605);
}
#endregion
@ -280,6 +291,8 @@ namespace TJAPlayer3
#region [Input]
if (!IsDownloading)
{
if (TJAPlayer3.Input管理.Keyboard.bキーが押された((int)SlimDXKeys.Key.RightArrow) ||
TJAPlayer3.Pad.b押された(E楽器パート.DRUMS, Eパッド.RBlue))
{
@ -413,12 +426,40 @@ namespace TJAPlayer3
}
}
else if (currentMenu == ECurrentMenu.CDN_SONGS)
{
if (this.cdnSongListIndex == 0)
{
TJAPlayer3.Skin.sound取消音.t再生する();
currentMenu = ECurrentMenu.CDN_OPTION;
}
else
{
if (this.cdnSongListIndex < apiMethods.FetchedSongsList.Length)
{
var song = apiMethods.FetchedSongsList[this.cdnSongListIndex - 1];
var zipPath = $@"Cache\{song.Md5}.zip";
if (System.IO.Directory.Exists($@"Songs\S3 Download\{song.Md5}"))
{
TJAPlayer3.Skin.soundError.t再生する();
}
else
{
TJAPlayer3.Skin.sound決定音.t再生する();
System.Threading.Thread download =
new System.Threading.Thread(new System.Threading.ThreadStart(DownloadSong));
download.Start();
}
}
}
}
#endregion
}
}
#endregion
// Menu exit fade out transition
@ -471,6 +512,25 @@ namespace TJAPlayer3
return true;
}
private void DownloadSong()
{
IsDownloading = true;
System.IO.Directory.CreateDirectory($@"Cache\");
var song = apiMethods.FetchedSongsList[this.cdnSongListIndex - 1];
var zipPath = $@"Cache\{song.Md5}.zip";
System.Net.WebClient wc = new System.Net.WebClient();
wc.DownloadFile($"{dbCDNData.BaseUrl}{dbCDNData.Download["default"]}{song.Id}", zipPath);
wc.Dispose();
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, $@"Songs\S3 Download\{song.Md5}");
IsDownloading = false;
}
public enum E戻り値 : int
{
@ -527,6 +587,8 @@ namespace TJAPlayer3
private TitleTextureKey[] ttkCDNSongSubtitles;
private int cdnSongListIndex;
private bool IsDownloading;
private class CMenuInfo
{
public CMenuInfo(string ttl)

View File

@ -107,6 +107,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />

View File

@ -0,0 +1,10 @@
#TITLE:Download
#GENRE:Download
#BOXEXPLANATION1:
#BOXEXPLANATION2:
#BOXEXPLANATION3:
#BGCOLOR:#ff00a2
#BOXCOLOR:#ff00a2
#BOXTYPE:0
#BGTYPE:1
#BOXCHARA:0