Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Nov 25, 2020
2 parents 515d422 + 1705d19 commit 9856bf2
Show file tree
Hide file tree
Showing 40 changed files with 1,166 additions and 308 deletions.
4 changes: 2 additions & 2 deletions CastIt.GoogleCast/CastIt.GoogleCast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MvvmCross" Version="7.0.1" />
<PackageReference Include="MvvmCross" Version="7.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="protobuf-net" Version="3.0.29" />
<PackageReference Include="protobuf-net" Version="3.0.52" />
<PackageReference Include="Zeroconf" Version="3.4.2" />
</ItemGroup>

Expand Down
11 changes: 9 additions & 2 deletions CastIt.GoogleCast/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class Player : IDisposable
#region Properties
public static bool CanLog { get; private set; }
public bool IsPlaying { get; private set; }
public bool IsPaused { get; private set; }
public string CurrentContentId { get; private set; }
public double CurrentMediaDuration { get; private set; }
public double ElapsedSeconds { get; private set; }
Expand Down Expand Up @@ -262,6 +263,7 @@ public async Task<MediaStatus> LoadAsync(

TriggerTimeEvents();
IsPlaying = true;
IsPaused = false;
ListenForMediaChanges(_listenerToken.Token);
ListenForReceiverChanges(_listenerToken.Token);

Expand All @@ -278,6 +280,7 @@ public Task<MediaStatus> GetMediaStatusAsync()
public Task<MediaStatus> PlayAsync()
{
IsPlaying = true;
IsPaused = false;
return _mediaChannel.PlayAsync(_sender);
}

Expand Down Expand Up @@ -400,23 +403,27 @@ await Task.Run(async () =>
IsPlaying = false;
checkMediaStatus = false;
_logger.LogInfo(
$"{nameof(ListenForMediaChanges)}: Media is null, end is reached = {contentIsBeingPlayed}. " +
$"{nameof(ListenForMediaChanges)}: Media is null, end is reached = {contentIsBeingPlayed} and player was paused = {IsPaused}. " +
$"CurrentContentId = {CurrentContentId}");
CancelAndSetListenerToken(false);

if (contentIsBeingPlayed)
//Only call the end reached if we were playing something and the player was not paused
if (contentIsBeingPlayed && !IsPaused)
EndReached?.Invoke(this, EventArgs.Empty);
IsPaused = false;
break;
}

ElapsedSeconds = mediaStatus.CurrentTime + _seekedSeconds;
if (mediaStatus.PlayerState == PlayerState.Paused)
{
IsPaused = true;
IsPlaying = false;
Paused?.Invoke(this, EventArgs.Empty);
continue;
}
IsPlaying = true;
IsPaused = false;
TriggerTimeEvents();
//If CurrentMediaDuration <= 0, that means that a live streaming is being played
if (CurrentMediaDuration > 0 && Math.Round(ElapsedSeconds, 4) >= Math.Round(CurrentMediaDuration, 4))
Expand Down
3 changes: 2 additions & 1 deletion CastIt/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override void Initialize()
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IAppWebServer, AppWebServer>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IFFMpegService, FFMpegService>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<ICastService, CastService>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IFileWatcherService, FileWatcherService>();

var messenger = Mvx.IoCProvider.Resolve<IMvxMessenger>();
var appSettings = Mvx.IoCProvider.Resolve<IAppSettingsService>();
Expand All @@ -51,7 +52,7 @@ public override void Initialize()
Mvx.IoCProvider.RegisterType<DeviceItemViewModel>();
Mvx.IoCProvider.ConstructAndRegisterSingleton(typeof(SettingsViewModel));

RegisterAppStart<MainViewModel>();
RegisterAppStart<SplashViewModel>();
}

private IMapper CreateMapper()
Expand Down
27 changes: 17 additions & 10 deletions CastIt/CastIt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
<Win32Resource />
<Platforms>x64;x86</Platforms>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<NoWarn>$(NoWarn);NU1605</NoWarn>
<FileVersion>1.0.1.0</FileVersion>
<Version>1.0.1</Version>
<FileVersion>1.0.2.0</FileVersion>
<Version>1.0.2</Version>
<PackageProjectUrl>https://github.com/Wolfteam/CastIt</PackageProjectUrl>
<Description>A casting app and remote controller made for my personal use.</Description>
<RepositoryUrl>https://github.com/Wolfteam/CastIt</RepositoryUrl>
<Authors>Efrain Bastidas</Authors>
<Company>MiraiSoft</Company>
</PropertyGroup>

<ItemGroup>
Expand All @@ -24,23 +29,25 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="Dragablz.NetCore" Version="0.3.3" />
<PackageReference Include="EmbedIO" Version="3.4.3" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="FluentMigrator" Version="3.2.9" />
<PackageReference Include="FluentMigrator.Runner" Version="3.2.9" />
<PackageReference Include="FreeSql.Provider.Sqlite" Version="1.10.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.26" />
<PackageReference Include="MaterialDesignThemes" Version="3.2.0-ci1901" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.4.3" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.4.3" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
<PackageReference Include="MvvmCross" Version="7.0.1" />
<PackageReference Include="MvvmCross.Platforms.Wpf" Version="7.0.1" />
<PackageReference Include="MvvmCross.Plugin.Messenger" Version="7.0.1" />
<PackageReference Include="MvvmCross.Plugin.ResxLocalization" Version="7.0.1" />
<PackageReference Include="MvvmCross" Version="7.1.2" />
<PackageReference Include="MvvmCross.Platforms.Wpf" Version="7.1.2" />
<PackageReference Include="MvvmCross.Plugin.Messenger" Version="7.1.2" />
<PackageReference Include="MvvmCross.Plugin.ResxLocalization" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="System.Management" Version="4.7.0" />
<PackageReference Include="Xabe.FFmpeg.Downloader" Version="4.3.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion CastIt/Common/AppConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static IReadOnlyList<string> AllowedFormats
};

public static string AllowedFormatsString
=> string.Join(";", AllowedFormats.Select(ext => $"*{ext}"));
=> string.Join(";", AllowedFormats.Select(ext => $"*{ext}"));

public static string AllowedSubtitleFormatsString
=> string.Join(";", AllowedSubtitleFormats.Select(ext => $"*{ext}"));
Expand Down
24 changes: 13 additions & 11 deletions CastIt/Common/Utils/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public static string GetFFprobePath()

public static string GetDbConnectionString()
{
return Path.Combine(GetBaseAppFolder(), "CastIt.db");
var path = Path.Combine(GetBaseAppFolder(), "CastIt.db");
return $"Data Source={path}";
}

public static string GetDbPath(string connectionString)
Expand Down Expand Up @@ -269,20 +270,21 @@ private static Encoding GetEncodingByParsing(string filePath, Encoding encoding)

try
{
using (var textReader = new StreamReader(filePath, encodingVerifier, detectEncodingFromByteOrderMarks: true))
using var textReader = new StreamReader(filePath, encodingVerifier, detectEncodingFromByteOrderMarks: true);
while (!textReader.EndOfStream)
{
while (!textReader.EndOfStream)
{
textReader.ReadLine(); // in order to increment the stream position
}

// all text parsed ok
return textReader.CurrentEncoding;
textReader.ReadLine(); // in order to increment the stream position
}

// all text parsed ok
return textReader.CurrentEncoding;
}
catch
{
// ignored
}
catch (Exception ex) { }

return null; //
return null;
}

private static bool IsVideoOrMusicFile(string mrl, bool checkForVideo)
Expand Down
Loading

0 comments on commit 9856bf2

Please sign in to comment.