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

Added mute function to card AfterRender #386

Merged
merged 2 commits into from
Feb 27, 2024
Merged
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
12 changes: 9 additions & 3 deletions src/TagzApp.Blazor.Client/Components/ModerationMessage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
if (Content.Content.PreviewCard.ImageUri.ToString().EndsWith(".mp4"))
{
<div class="contentcard">
<video muted="muted" controls="controls" autoplay src="@Content.Content.PreviewCard.ImageUri" class="card-img-top" alt="@Content.Content.PreviewCard.AltText"></video>
<video id="video_@Content.ProviderId" muted controls="controls" autoplay src="@Content.Content.PreviewCard.ImageUri" class="card-img-top" alt="@Content.Content.PreviewCard.AltText"></video>
</div>
}
else
Expand Down Expand Up @@ -105,9 +105,15 @@

private bool ShowModerationActions = false;

protected override Task OnAfterRenderAsync(bool firstRender)
protected override async Task OnAfterRenderAsync(bool firstRender)
{


if (Content.Content.HasVideoPreview)
{
await JSRuntime.InvokeVoidAsync("window.WaterfallUi.MuteVideo", $"video_{Content.ProviderId}");
}

if (firstRender)
{
JSRuntime.InvokeVoidAsync("window.Masonry.resizeGridItem", thisArticle);
Expand All @@ -118,7 +124,7 @@

}

return base.OnAfterRenderAsync(firstRender);
await base.OnAfterRenderAsync(firstRender);
}

private const string CSS_APPROVED = "status-approved";
Expand Down
9 changes: 6 additions & 3 deletions src/TagzApp.Blazor.Client/Components/WaterfallMessage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if (Content.PreviewCard.ImageUri.ToString().EndsWith(".mp4"))
{
<div class="contentcard">
<video muted="muted" controls="controls" autoplay src="@Content.PreviewCard.ImageUri" class="card-img-top" alt="@Content.PreviewCard.AltText"></video>
<video id="video_@Content.ProviderId" controls="controls" autoplay src="@Content.PreviewCard.ImageUri" class="card-img-top" alt="@Content.PreviewCard.AltText"></video>
</div>
}
else
Expand Down Expand Up @@ -61,12 +61,15 @@
private List<string> _CssClasses = new();
private string CssClass => string.Join(" ", _CssClasses);

protected override Task OnAfterRenderAsync(bool firstRender)
protected override async Task OnAfterRenderAsync(bool firstRender)
{

if (Content.HasVideoPreview) {
await JSRuntime.InvokeVoidAsync("window.WaterfallUi.MuteVideo", $"video_{Content.ProviderId}");
}
JSRuntime.InvokeVoidAsync("window.Masonry.resizeGridItem", thisArticle);

return base.OnAfterRenderAsync(firstRender);
await base.OnAfterRenderAsync(firstRender);
}

}
5 changes: 5 additions & 0 deletions src/TagzApp.Blazor/wwwroot/js/waterfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@
},

Messages: messages,

MuteVideo: function (video) {
var video = document.getElementById(video);
video.muted = true;
},
};

window.WaterfallUi = waterfallUi;
Expand Down
2 changes: 2 additions & 0 deletions src/TagzApp.ViewModels/Data/ContentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Emote[] Emotes
)
{

public bool HasVideoPreview => PreviewCard?.ImageUri.ToString().EndsWith(".mp4") ?? false;

// TODO: Refactor to not take a dependency on the Common library
public static explicit operator ContentModel(Content content)
{
Expand Down