Skip to content

Commit 8eefc7b

Browse files
version 1.0.5
Added pick random episode button. Update screenshot.
1 parent 3980bea commit 8eefc7b

7 files changed

Lines changed: 30 additions & 30 deletions

File tree

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ <h3 id="currently-playing-title" style="padding-bottom: 8px;">
775775
<img id="button-play" class="player-controls-disabled" src="play.svg" alt="Play">
776776
<img id="button-stop" class="hidden" src="stop.svg" alt="Stop">
777777
<img id="button-seek-forward" class="player-controls-disabled" src="seek_forward.svg" alt="Seek back 30s">
778+
<img id="button-random" src="random.svg" alt="Random">
778779
</div>
779780
</div>
780781
</footer>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "mfp-app",
33
"private": true,
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"type": "module",
66
"scripts": {
77
"dev": "vite --host",
88
"build": "tsc && vite build",
99
"preview": "vite preview",
10-
"mfp-fetch-and-build": "source .venv/bin/activate && python mfp-fetch-and-build.py",
10+
"mfp-fetch-and-build": "source .venv/bin/activate && python mfp-fetch-and-build.p5",
1111
"icons": "pwa-asset-generator public/mfp.svg ./public/assets --icon-only --favicon --type png --opaque --background '#000000'",
1212
"splash": "pwa-asset-generator public/mfp.svg ./public/splash --splash-only --background '#000000' --type png"
1313
},

public/random.svg

Lines changed: 1 addition & 0 deletions
Loading

public/screenshot.png

875 Bytes
Loading

src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ const header = document.querySelector<HTMLElement>('header')!
1717
const aboutButton = document.querySelector<HTMLImageElement>('#about-button')!
1818
const closeButton = document.querySelector<HTMLImageElement>('#close-button')!
1919
const playlist = document.querySelector<HTMLDivElement>('#playlist')!
20+
const episodes = document.querySelectorAll('A')
2021
const about = document.querySelector<HTMLDivElement>('#about')!
2122
const main = document.querySelector<HTMLElement>('main')!
2223
const mfpAudioPlayer = document.querySelector<HTMLAudioElement>('#mfp-audio-player')!
2324
const buttonPlay = document.querySelector<HTMLButtonElement>('#button-play')!
2425
const buttonStop = document.querySelector<HTMLButtonElement>('#button-stop')!
2526
const buttonSeekBack = document.querySelector<HTMLButtonElement>('#button-seek-back')!
2627
const buttonSeekForward = document.querySelector<HTMLButtonElement>('#button-seek-forward')!
28+
const buttonRandom = document.querySelector<HTMLButtonElement>('#button-random')!
2729

2830
const miniPlayerTitle = document.querySelector<HTMLParagraphElement>('#mini-player-title')!
2931
const miniPlayerDuration = document.querySelector<HTMLParagraphElement>('#mini-player-duration')!
@@ -140,6 +142,10 @@ buttonSeekForward.addEventListener('click', () => {
140142
_seekForward(SEEK_30_SECONDS)
141143
})
142144

145+
buttonRandom.addEventListener('click', () => {
146+
_playRandomEpisode()
147+
})
148+
143149
function _enableSeekButtons() {
144150
console.log('Enabling seek buttons')
145151
buttonSeekBack.classList.remove(PLAYER_CONTROLS_DISABLED_CLASS)
@@ -236,13 +242,23 @@ function _seekBackward(offset: number) {
236242
console.log('Seeking backward:', currentTime, ' offset:', offset)
237243
mfpAudioPlayer.currentTime = Math.max(0, currentTime)
238244
}
245+
239246
function _seekForward(offset: number) {
240247
const duration = Math.floor(mfpAudioPlayer.duration - 1)
241248
const currentTime = Math.floor(mfpAudioPlayer.currentTime + offset)
242249
console.log('Seeking forward:', currentTime, ' offset:', offset, ' duration:', duration)
243250
mfpAudioPlayer.currentTime = Math.min(duration, currentTime)
244251
}
245252

253+
const _playRandomEpisode = () => {
254+
console.log("play random episode...")
255+
if (episodes.length > 0) {
256+
const index = Math.floor(Math.random() * episodes.length)
257+
const episode = episodes[index] as HTMLAnchorElement
258+
episode.click()
259+
}
260+
}
261+
246262
if (hasMediaSession()) {
247263
function _updatePositionState() {
248264
navigator.mediaSession.setPositionState({

src/style.css

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -206,37 +206,18 @@
206206
padding-right: 16px;
207207
}
208208

209-
@media (max-height: 500px) {
210-
#mini-player p {
211-
margin: 0;
212-
}
213-
214-
#button-seek-back,
215-
#button-seek-forward {
216-
width: 16px;
217-
height: 16px;
218-
}
219209

220-
#button-play,
221-
#button-stop {
222-
width: 24px;
223-
height: 24px;
224-
}
210+
#button-seek-back,
211+
#button-seek-forward {
212+
width: 36px;
213+
height: 36px;
225214
}
226215

227-
@media (min-height: 501px) {
228-
229-
#button-seek-back,
230-
#button-seek-forward {
231-
width: 36px;
232-
height: 36px;
233-
}
234-
235-
#button-play,
236-
#button-stop {
237-
width: 56px;
238-
height: 56px;
239-
}
216+
#button-play,
217+
#button-stop,
218+
#button-random {
219+
width: 56px;
220+
height: 56px;
240221
}
241222

242223
/*

templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ <h3 id="currently-playing-title" style="padding-bottom: 8px;">
175175
<img id="button-play" class="player-controls-disabled" src="play.svg" alt="Play">
176176
<img id="button-stop" class="hidden" src="stop.svg" alt="Stop">
177177
<img id="button-seek-forward" class="player-controls-disabled" src="seek_forward.svg" alt="Seek back 30s">
178+
<img id="button-random" src="random.svg" alt="Random">
178179
</div>
179180
</div>
180181
</footer>

0 commit comments

Comments
 (0)