-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from ITU-BDSA2024-GROUP10/short-form-content
Short form content
- Loading branch information
Showing
13 changed files
with
313 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Chirp/src/Chirp.Web/Pages/Shared/Components/SideVideo/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
@{ | ||
var videoList = ViewBag.VideoList as List<string>; | ||
var isLeft = ViewBag.IsLeft; | ||
} | ||
|
||
@if (isLeft) | ||
{ | ||
<div id="videoLeftContainer" class="video-container"> | ||
<video id="leftVideo" autoplay muted disablePictureInPicture> | ||
<source src="@videoList?[0]" type="video/mp4"> | ||
Your browser does not support the video tag. | ||
</video> | ||
</div> | ||
} | ||
else | ||
{ | ||
<div id="videoRightContainer" class="video-container"> | ||
<video id="rightVideo" autoplay muted disablePictureInPicture> | ||
<source src="@videoList?[0]" type="video/mp4"> | ||
Your browser does not support the video tag. | ||
</video> | ||
</div> | ||
} | ||
|
||
<script type="module"> | ||
import VideoController from '/js/videoController.js'; | ||
const videoList = @Html.Raw(Json.Serialize(videoList)); | ||
const isLeft = @Html.Raw(Json.Serialize(isLeft)); | ||
if(isLeft) | ||
{ | ||
const leftVideoElement = document.getElementById('leftVideo'); | ||
new VideoController(leftVideoElement, videoList); | ||
} | ||
else | ||
{ | ||
const rightVideoElement = document.getElementById('rightVideo'); | ||
new VideoController(rightVideoElement, videoList); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Chirp/src/Chirp.Web/ViewComponents/SideVideoViewComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Chirp.Web.ViewComponents; | ||
|
||
public class SideVideoViewComponent : ViewComponent | ||
{ | ||
private readonly List<string> _videoNames = | ||
[ | ||
"~/videos/Kittens.mp4", | ||
"~/videos/SubwaySurfers_1.mp4", | ||
"~/videos/SubwaySurfers_2.mp4", | ||
"~/videos/TempleRun.mp4" | ||
]; | ||
|
||
public IViewComponentResult Invoke(bool isLeft) | ||
{ | ||
ViewBag.IsLeft = isLeft; | ||
ViewBag.VideoList = GetVideos(); | ||
|
||
return View("Default"); | ||
} | ||
|
||
public List<string> GetVideos() | ||
{ | ||
var random = new Random(); | ||
var videos = _videoNames.OrderBy(x => random.Next()).ToList(); | ||
return videos.Select(v =>Url.Content(v)).ToList(); | ||
} | ||
} |
Oops, something went wrong.