Skip to content

Commit

Permalink
Removes missing ad file.
Browse files Browse the repository at this point in the history
  • Loading branch information
JudahGabriel committed Dec 5, 2024
1 parent c157f79 commit 6d3e05f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Chavah.NetCore/Controllers/CdnController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public RedirectResult GetAdAnnouncement()
"ad2x.mp3",
"ad3x.mp3",
"ad4x.mp3",
"ad5x.mp3",
"ad6x.mp3",
"ad5x.mp3"
};

// Sukkot 2024 ad: play it every even hour.
Expand Down
17 changes: 2 additions & 15 deletions Chavah.NetCore/wwwroot/js/Services/AdAnnouncerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
constructor(
private readonly audioPlayer: AudioPlayerService,
private readonly homeViewModel: Server.HomeViewModel) {
this.lastAnnouncementTime.setDate(this.lastAnnouncementTime.getDate() - 1); // set last announcement time to yesterday.
}

hasPendingAnnouncement(): boolean {
Expand All @@ -33,21 +34,7 @@

playAdAnnouncement() {
const adUrl = "/api/cdn/getAdAnnouncement";

// Check if this is a redirect. If so, find the target of the redirect and play that.
// If not, play the URL.
// Reason is, on iOS we use native audio to play the URL. It can have issues playing a redirect result.
window.fetch(adUrl)
.then(res => {
const isRedirect = res.status >= 300 && res.status < 400;
if (isRedirect) {
const redirectUrl = res.headers.get("Location");
this.audioPlayer.playNewUri(redirectUrl || adUrl);
}
}, err => {
console.warn("Unable to fetch ad announcement URL due to error", err);
this.audioPlayer.playNewUri(adUrl);
});
this.audioPlayer.playNewUri(adUrl);
}
}

Expand Down

0 comments on commit 6d3e05f

Please sign in to comment.