Skip to content

Commit

Permalink
Merge branch 'release/v1.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
tor4kichi committed Dec 26, 2024
2 parents 73fc05f + d81e49b commit aef1a99
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Hohoema.Core/Models/Player/IStreamingSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ namespace Hohoema.Models.Player;
public interface IStreamingSession : IDisposable
{
NicoVideoQuality Quality { get; }
Task StartPlayback(MediaPlayer player, TimeSpan initialPosition = default);
Task SetMediaSourceToPlayer(MediaPlayer player, TimeSpan initialPosition = default, bool play = true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void _videoSessionOwnership_ReturnOwnershipRequested(object sender, Even
StopStreamingFromOwnerShipReturned?.Invoke(this, e);
}

public async Task StartPlayback(MediaPlayer player, TimeSpan initialPosition = default)
public async Task SetMediaSourceToPlayer(MediaPlayer player, TimeSpan initialPosition = default, bool play = true)
{
// Note: HTML5プレイヤー移行中のFLV動画に対するフォールバック処理
// サムネではContentType=FLV,SWFとなっていても、
Expand Down Expand Up @@ -147,8 +147,10 @@ public async Task StartPlayback(MediaPlayer player, TimeSpan initialPosition = d
_PlayingMediaPlayer.PlaybackSession.Position = initialPosition;

OnStartStreaming();

_PlayingMediaPlayer.Play();
if (play)
{
_PlayingMediaPlayer.Play();
}
}
else
{
Expand Down
23 changes: 15 additions & 8 deletions Hohoema.Core/Models/Playlist/HohoemaPlaylistPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ public async Task ChangeQualityAsync(NicoVideoQualityEntity qualityEntity)
IStreamingSession videoSession;
if (_videoSessionDisposable is DomandStreamingSession dommandSession)
{
_videoSessionDisposable?.Dispose();
videoSession = await CurrentPlayingSession.VideoSessionProvider.CreateVideoSessionAsync(qualityEntity);
}
else
Expand All @@ -560,7 +561,7 @@ public async Task ChangeQualityAsync(NicoVideoQualityEntity qualityEntity)


_videoSessionDisposable = videoSession;
await videoSession.StartPlayback(_mediaPlayer, currentPosition ?? TimeSpan.Zero);
await videoSession.SetMediaSourceToPlayer(_mediaPlayer, currentPosition ?? TimeSpan.Zero);
_mediaPlayer.PlaybackSession.PlaybackRate = lastPlaybackRate;

_playerSettings.DefaultVideoQualityId = qualityEntity.QualityId;
Expand All @@ -575,11 +576,10 @@ private void StopPlaybackMedia()
TimeSpan endPosition = _mediaPlayer.PlaybackSession.Position;
VideoId? videoId = CurrentPlaylistItem?.VideoId;

_mediaPlayer.Source = null;
_videoSessionDisposable?.Dispose();
_videoSessionDisposable = null;
CurrentPlayingSession = null;
_mediaPlayer.Pause();
_mediaPlayer.Source = null;
ClearCurrentContent();

if (prevSource != null && videoId.HasValue)
Expand Down Expand Up @@ -731,6 +731,7 @@ private async Task<bool> UpdatePlayingMediaAsync(IVideoContent item, TimeSpan? s
{
Guard.IsNotNull(item, nameof(item));

IStreamingSession? videoSession = null;
try
{
PlayingOrchestrateResult result = await _videoStreamingOriginOrchestrator.CreatePlayingOrchestrateResultAsync(item.VideoId);
Expand All @@ -747,10 +748,9 @@ private async Task<bool> UpdatePlayingMediaAsync(IVideoContent item, TimeSpan? s
qualityEntity = AvailableQualities.SkipWhile(x => !x.IsAvailable).First();
}

IStreamingSession videoSession = await result.VideoSessionProvider.CreateVideoSessionAsync(qualityEntity);
videoSession = await result.VideoSessionProvider.CreateVideoSessionAsync(qualityEntity);

_videoSessionDisposable = videoSession;
await videoSession.StartPlayback(_mediaPlayer, startPosition ?? TimeSpan.Zero);

_mediaPlayer.PlaybackSession.PlaybackRate = _playerSettings.PlaybackRate;
CurrentQuality = AvailableQualities.First(x => x.Quality == videoSession.Quality);
Expand All @@ -761,9 +761,6 @@ private async Task<bool> UpdatePlayingMediaAsync(IVideoContent item, TimeSpan? s

NowPlayingWithCache = videoSession is CachedVideoStreamingSession;

// メディア再生成功時のメッセージを飛ばす
_ = _messenger.Send(new PlaybackStartedMessage(new(this, CurrentPlaylistId, item.VideoId, videoSession.Quality, _mediaPlayer.PlaybackSession)));

_mediaPlayer.PlaybackSession.PlaybackStateChanged -= PlaybackSession_PlaybackStateChanged;
_mediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged;

Expand Down Expand Up @@ -791,10 +788,20 @@ await _dispatcherQueue.EnqueueAsync(async () =>
_smtc.ButtonPressed -= _smtc_ButtonPressed;
_smtc.ButtonPressed += _smtc_ButtonPressed;

// 自動で再生開始せず、アプリ側で制御してもらう
await videoSession.SetMediaSourceToPlayer(_mediaPlayer, startPosition ?? TimeSpan.Zero, false);

// メディア再生成功時のメッセージを飛ばす
_ = _messenger.Send(new PlaybackStartedMessage(new(this, CurrentPlaylistId, item.VideoId, videoSession.Quality, _mediaPlayer.PlaybackSession)));

return true;
}
catch (Exception)
{
videoSession?.Dispose();
_mediaPlayer.PlaybackSession.PlaybackStateChanged -= PlaybackSession_PlaybackStateChanged;
_smtc.ButtonPressed -= _smtc_ButtonPressed;

StopPlaybackMedia();
_ = _messenger.Send(new PlaybackFailedMessage(new(this, CurrentPlaylistId, item.VideoId, PlayingOrchestrateFailedReason.Unknown)));
throw;
Expand Down
44 changes: 0 additions & 44 deletions Hohoema.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "R3.UWP", "R3.UWP\R3.UWP.csp
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|Any CPU.ActiveCfg = Debug|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|Any CPU.Build.0 = Debug|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|Any CPU.Deploy.0 = Debug|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM.ActiveCfg = Debug|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM.Build.0 = Debug|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM.Deploy.0 = Debug|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM64.Build.0 = Debug|ARM64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|ARM64.Deploy.0 = Debug|ARM64
Expand All @@ -40,12 +30,6 @@ Global
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|x86.ActiveCfg = Debug|x86
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|x86.Build.0 = Debug|x86
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Debug|x86.Deploy.0 = Debug|x86
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|Any CPU.ActiveCfg = Release|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|Any CPU.Build.0 = Release|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|Any CPU.Deploy.0 = Release|x64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM.ActiveCfg = Release|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM.Build.0 = Release|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM.Deploy.0 = Release|ARM
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM64.ActiveCfg = Release|ARM64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM64.Build.0 = Release|ARM64
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|ARM64.Deploy.0 = Release|ARM64
Expand All @@ -55,60 +39,32 @@ Global
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|x86.ActiveCfg = Release|x86
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|x86.Build.0 = Release|x86
{17BCCDA1-CE22-4306-8845-FDD7B346944D}.Release|x86.Deploy.0 = Release|x86
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|Any CPU.ActiveCfg = Debug|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|Any CPU.Build.0 = Debug|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|Any CPU.Deploy.0 = Debug|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|ARM.ActiveCfg = Debug|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|ARM.Build.0 = Debug|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|ARM.Deploy.0 = Debug|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|ARM64.ActiveCfg = Debug|ARM64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|x64.ActiveCfg = Debug|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Debug|x86.ActiveCfg = Debug|x86
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|Any CPU.ActiveCfg = Release|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|Any CPU.Build.0 = Release|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|Any CPU.Deploy.0 = Release|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM.ActiveCfg = Release|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM.Build.0 = Release|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM.Deploy.0 = Release|ARM
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM64.ActiveCfg = Release|ARM64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM64.Build.0 = Release|ARM64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|ARM64.Deploy.0 = Release|ARM64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|x64.ActiveCfg = Release|x64
{D46333EA-134E-46A0-AA86-FECA2C1E74E3}.Release|x86.ActiveCfg = Release|x86
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|ARM.ActiveCfg = Debug|ARM
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|ARM.Build.0 = Debug|ARM
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|ARM64.ActiveCfg = Debug|ARM64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|ARM64.Build.0 = Debug|ARM64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|x64.ActiveCfg = Debug|x64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|x64.Build.0 = Debug|x64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|x86.ActiveCfg = Debug|x86
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Debug|x86.Build.0 = Debug|x86
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|Any CPU.Build.0 = Release|Any CPU
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|ARM.ActiveCfg = Release|ARM
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|ARM.Build.0 = Release|ARM
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|ARM64.ActiveCfg = Release|ARM64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|ARM64.Build.0 = Release|ARM64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|x64.ActiveCfg = Release|x64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|x64.Build.0 = Release|x64
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|x86.ActiveCfg = Release|x86
{5877A9CA-2D3A-4B8B-86CA-D77E6D68CF98}.Release|x86.Build.0 = Release|x86
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|ARM.ActiveCfg = Debug|ARM
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|ARM.Build.0 = Debug|ARM
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|ARM64.ActiveCfg = Debug|ARM64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|ARM64.Build.0 = Debug|ARM64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|x64.ActiveCfg = Debug|x64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|x64.Build.0 = Debug|x64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|x86.ActiveCfg = Debug|x86
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Debug|x86.Build.0 = Debug|x86
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|Any CPU.Build.0 = Release|Any CPU
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|ARM.ActiveCfg = Release|ARM
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|ARM.Build.0 = Release|ARM
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|ARM64.ActiveCfg = Release|ARM64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|ARM64.Build.0 = Release|ARM64
{A90FCB00-1552-4570-94A9-A1DD9F2CEBEB}.Release|x64.ActiveCfg = Release|x64
Expand Down
2 changes: 1 addition & 1 deletion Hohoema/Hohoema.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxPackageDir>D:\tor4k\Documents\Hohoema\Packages\</AppxPackageDir>
<Use64BitCompiler>True</Use64BitCompiler>
<PackageCertificateThumbprint>015B2FDB045FEC07E2DE40236A00B5DC31563AE6</PackageCertificateThumbprint>
<PackageCertificateThumbprint>0466F2F6C316015FB1FAE8ED719BCEAC860FC78A</PackageCertificateThumbprint>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion Hohoema/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
<Identity Name="18803tor4kichi.Hohoema" Publisher="CN=DFF1CEA0-5963-4197-8676-6105C5E8CE4B" Version="1.7.3.0" />
<Identity Name="18803tor4kichi.Hohoema" Publisher="CN=DFF1CEA0-5963-4197-8676-6105C5E8CE4B" Version="1.7.4.0" />
<mp:PhoneIdentity PhoneProductId="01cfd879-0a19-44a7-b5db-11bdbd13f0df" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Hohoema</DisplayName>
Expand Down
15 changes: 6 additions & 9 deletions Hohoema/Views.Player/VideoPlayerPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,12 @@ async void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
// コメントを更新
await _dispatcherQueue.EnqueueAsync(async () =>
{
sender.Pause();
try
{
await CommentPlayer.UpdatePlayingCommentAsync(result.CommentSessionProvider);
}
finally
{
sender.Play();
}
await CommentPlayer.UpdatePlayingCommentAsync(result.CommentSessionProvider);

// コメント読み込み完了後に再生を開始したい
// このためにHohoemaPlaylistPlayerなどで再生開始しないように調整している
// 動画準備段階でコメント準備処理が走ると稀に映像が表示されないまま再生するケースがあった
MediaPlayer.Play();
});
}
void MediaPlayer_MediaFailed(MediaPlayer sender, MediaPlayerFailedEventArgs args)
Expand Down
2 changes: 2 additions & 0 deletions Hohoema/Views/Extensions/MediaPlayer/MediaPlayerSetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override void OnAttached()
{
base.OnAttached();

this.AssociatedObject.Loaded -= AssociatedObject_Loaded;
this.AssociatedObject.Loaded += AssociatedObject_Loaded;
}

Expand All @@ -54,6 +55,7 @@ protected override void OnDetaching()

private void AssociatedObject_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
this.AssociatedObject.Loaded -= AssociatedObject_Loaded;
if (MediaPlayer != null)
{
AssociatedObject.SetMediaPlayer(MediaPlayer);
Expand Down

0 comments on commit aef1a99

Please sign in to comment.