Skip to content

Commit

Permalink
Infrastructure Preparation 56
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Jul 5, 2023
1 parent 18367d7 commit 663a24f
Show file tree
Hide file tree
Showing 31 changed files with 757 additions and 226 deletions.
2 changes: 1 addition & 1 deletion src/Sucrose.Globalization/Manage/Resources.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Globalization;
using System.Resources;
using SGSG = Sucrose.Globalization.Strings.General;
using SGSW = Sucrose.Globalization.Strings.Watchdog;
using SGST = Sucrose.Globalization.Strings.Tray;
using SGSW = Sucrose.Globalization.Strings.Watchdog;

namespace Sucrose.Globalization.Manage
{
Expand Down
2 changes: 2 additions & 0 deletions src/Sucrose.Manager/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static class Internal

public static SMLM UserInterfaceLogManager = new("UserInterface-{0}.log");

public static SMLM WebViewPlayerLogManager = new("WebViewPlayer-{0}.log");

public static SMLM CefSharpPlayerLogManager = new("CefSharpPlayer-{0}.log");

public static SMLM MediaElementPlayerLogManager = new("MediaElementPlayer-{0}.log");
Expand Down
44 changes: 36 additions & 8 deletions src/Sucrose.Manager/SettingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public T GetSetting<T>(string key, T back = default)
{
if (File.Exists(_settingsFilePath))
{
string json = File.ReadAllText(_settingsFilePath);
string json = ReadFile();

Settings settings = JsonConvert.DeserializeObject<Settings>(json, _serializerSettings);

Expand All @@ -70,7 +70,7 @@ public T GetSettingStable<T>(string key, T back = default)
{
if (File.Exists(_settingsFilePath))
{
string json = File.ReadAllText(_settingsFilePath);
string json = ReadFile();

Settings settings = JsonConvert.DeserializeObject<Settings>(json, _serializerSettings);

Expand All @@ -96,7 +96,7 @@ public T GetSettingAddress<T>(string key, T back = default)
{
if (File.Exists(_settingsFilePath))
{
string json = File.ReadAllText(_settingsFilePath);
string json = ReadFile();

Settings settings = JsonConvert.DeserializeObject<Settings>(json, _serializerSettings);

Expand Down Expand Up @@ -124,7 +124,7 @@ public void SetSetting<T>(string key, T value)

if (File.Exists(_settingsFilePath))
{
string json = File.ReadAllText(_settingsFilePath);
string json = ReadFile();
settings = JsonConvert.DeserializeObject<Settings>(json, _serializerSettings);
}
else
Expand All @@ -134,15 +134,43 @@ public void SetSetting<T>(string key, T value)

settings.Properties[key] = ConvertToType<T>(value);

string serializedSettings = JsonConvert.SerializeObject(settings, _serializerSettings);
WriteFile(JsonConvert.SerializeObject(settings, _serializerSettings));
}
finally
{
_lock.ExitWriteLock();
}
}

using FileStream fileStream = new(_settingsFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
private string ReadFile()
{
try
{
//return File.ReadAllText(_settingsFilePath);

using FileStream fileStream = new(_settingsFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using StreamReader reader = new(fileStream);
return reader.ReadToEnd();
}
catch
{
return string.Empty;
}
}

private void WriteFile(string serializedSettings)
{
try
{
//File.WriteAllText(_settingsFilePath, serializedSettings);

using FileStream fileStream = new(_settingsFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
using StreamWriter writer = new(fileStream);
writer.Write(serializedSettings);
}
finally
catch
{
_lock.ExitWriteLock();
//
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Sucrose.Memory/Readonly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static class Readonly

public static readonly string MediaElement = "MediaElement";

public static readonly string VideoContent = "VideoContent.html";

public static readonly string StartCommand = $"{StartCommandChar}";

public static readonly string EngineLive = "Sucrose.Engine.Live.exe";
Expand Down
6 changes: 4 additions & 2 deletions src/Sucrose.Player.CS/Event/Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SMMI = Sucrose.Manager.Manage.Internal;
using SPCSHCSH = Sucrose.Player.CS.Helper.CefSharpHelper;
using SPCSMI = Sucrose.Player.CS.Manage.Internal;
using SSEST = Sucrose.Space.Enum.StretchType;

namespace Sucrose.Player.CS.Event
{
Expand All @@ -16,14 +17,15 @@ public static void CefPlayerFrameLoadEnd(object sender, FrameLoadEndEventArgs e)
SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].controls = false;");
SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].loop = true;");

SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].style = \"position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; object-fit: fill;\";");
SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].style = \"position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;\";");

SPCSHCSH.SetStretch(SMMI.EngineSettingManager.GetSettingStable(SMC.StretchType, SSEST.Fill));
SPCSHCSH.SetVolume(SMMI.EngineSettingManager.GetSettingStable(SMC.Volume, 100));
}

public static void CefPlayerLoaded(object sender, RoutedEventArgs e)
{
SPCSMI.CefPlayer.ShowDevTools();
//SPCSMI.CefPlayer.ShowDevTools();
}
}
}
36 changes: 32 additions & 4 deletions src/Sucrose.Player.CS/Helper/CefSharpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,42 @@ public static void Play()
SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].play();");
}

public static void Stop()
public static async Task<bool> GetEnd()
{
SPCSMI.CefPlayer.ExecuteScriptAsync("document.getElementsByTagName('video')[0].stop();"); //Not Working
JavascriptResponse Response;
string Current = string.Empty;
string Duration = string.Empty;

Response = await SPCSMI.CefPlayer.EvaluateScriptAsync($"document.getElementsByTagName('video')[0].duration");

if (Response.Success)
{
Duration = Response.Result.ToString();
}

Response = await SPCSMI.CefPlayer.EvaluateScriptAsync($"document.getElementsByTagName('video')[0].currentTime");

if (Response.Success)
{
Current = Response.Result.ToString();
}

return Current.Equals(Duration);
}

public static void SetLoop(bool State)
public static async void SetLoop(bool State)
{
SPCSMI.CefPlayer.ExecuteScriptAsync($"document.getElementsByTagName('video')[0].loop = {State.ToString().ToLower()};"); //Not Working
SPCSMI.CefPlayer.ExecuteScriptAsync($"document.getElementsByTagName('video')[0].loop = {State.ToString().ToLower()};");

if (State)
{
bool Ended = await GetEnd();

if (Ended)
{
Play();
}
}
}

public static void SetVolume(int Volume)
Expand Down
54 changes: 48 additions & 6 deletions src/Sucrose.Player.Shared/Helper/Source.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,63 @@
using System.IO;
using System.Text.RegularExpressions;
using SMR = Sucrose.Memory.Readonly;
#if NET48_OR_GREATER
using System.Net.Http;
using SMR = Sucrose.Memory.Readonly;
using SSECCE = Skylark.Standard.Extension.Cryptology.CryptologyExtension;
#endif

namespace Sucrose.Player.Shared.Helper
{
internal static class Source
{
public static bool GetExtension(Uri Source)
{
return GetExtension(Source.ToString());
}

public static bool GetExtension(string Source)
{
if (Path.GetExtension(Source) != ".mov")
{
return true;
}
else
{
return false;
}
}

public static string GetContent(Uri Source)
{
return GetContent(Source.ToString());
}

public static string GetContent(string Source)
{
return $"<html><head><meta name=\"viewport\" content=\"width=device-width\"></head><body><video autoplay name=\"media\" src=\"{Source}\"></video></body></html>";
}

public static void WriteContent(string ContentPath, Uri Content)
{
WriteContent(ContentPath, Content.ToString());
}

public static void WriteContent(string ContentPath, string Content)
{
File.WriteAllText(ContentPath, GetContent(Content));
}

public static string GetContentPath()
{
return Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.CacheFolder, SMR.WebView2, SMR.VideoContent);
}

public static Uri GetSource(Uri Source)
{
return GetSource(Source.ToString());
}

public static Uri GetSource(string Source)
public static Uri GetSource(string Source, UriKind Kind = UriKind.RelativeOrAbsolute)
{
if (IsUrl(Source))
{
Expand All @@ -32,7 +74,7 @@ public static Uri GetSource(string Source)

if (File.Exists(LocalSource))
{
return new Uri(@LocalSource, UriKind.RelativeOrAbsolute);
return new Uri(@LocalSource, Kind);
}
else
{
Expand All @@ -43,15 +85,15 @@ public static Uri GetSource(string Source)

Content.CopyTo(Stream);

return new Uri(@Path.GetFullPath(LocalSource), UriKind.RelativeOrAbsolute);
return new Uri(@Path.GetFullPath(LocalSource), Kind);
}
#else
return new Uri(@Source, UriKind.RelativeOrAbsolute);
return new Uri(@Source, Kind);
#endif
}
else
{
return new Uri(@Source, UriKind.RelativeOrAbsolute);
return new Uri(@Source, Kind);
}
}

Expand Down
79 changes: 79 additions & 0 deletions src/Sucrose.Player.WV.Live/App.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Bildirim Seçenekleri
Windows Kullanıcı Hesabı Denetimi düzeyini değiştirmek istiyorsanız
requestedExecutionLevel düğümünü aşağıdakilerden biriyle değiştirin.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
requestedExecutionLevel öğesini belirtmek, dosya ve kayıt defteri sanallaştırmasını devre dışı bırakır.
Uygulamanız geriye doğru uyumluluk için bu sanallaştırmayı gerektiriyorsa, bu öğeyi
kaldırın.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Bu uygulamanın test edildiği ve birlikte çalışmak için tasarlandığı
Windows sürümlerinin bir listesi. Uygun öğelerin açıklamasını kaldırdığınızda Windows
en uyumlu ortamı otomatik olarak seçer. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Uygulamanın DPI kullanan uygulama olduğunu ve yüksek DPI'larda Windows tarafından otomatik olarak ölçeklendirilmeyeceğini
belirtir. Windows Presentation Foundation (WPF) uygulamaları otomatik olarak DPI kullanan uygulamalardır ve bunun kabul edilmesi
gerekmez. Bu ayarın kabul edildiği ve .NET Framework 4.6'yı hedefleyen Windows Forms uygulamalarında da
app.config'de 'EnableWindowsFormsHighDpiAutoResizing' ayarının 'true' olarak belirlenmesi gerekir.
Uygulamayı uzun yol kullanan uygulama haline getirir. Bkz. https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">false</longPathAware>
</windowsSettings>
</application>


<!-- Windows genel denetimler ve iletişim kutuları için temaları etkinleştir (Windows XP ve sonrası) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
6 changes: 6 additions & 0 deletions src/Sucrose.Player.WV.Live/App.net48.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
6 changes: 6 additions & 0 deletions src/Sucrose.Player.WV.Live/App.net481.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
</configuration>
3 changes: 3 additions & 0 deletions src/Sucrose.Player.WV.Live/App.net6.0-windows.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
3 changes: 3 additions & 0 deletions src/Sucrose.Player.WV.Live/App.net7.0-windows.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
3 changes: 3 additions & 0 deletions src/Sucrose.Player.WV.Live/App.net8.0-windows.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
Loading

0 comments on commit 663a24f

Please sign in to comment.