Skip to content
Open
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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.insertSpaces": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"files.insertFinalNewline": true
}
13 changes: 4 additions & 9 deletions src/components/Page3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ import { PageCtx } from './models/pageContext'
import config from '@/config'
import PageHeader from './PageHeader'
import Image from 'next/image'
import { getEventImages } from '@/constants/image-config'

type PageProps = { view: Optional<TalkView>; isDk: boolean }
type Props = { view: Optional<TalkView> }

const alias: string = 'srekaigi2026'

const images: string[] = [
'info_001.jpg',
'info_002.jpg',
'info_003.jpg',
'info_004.jpg',
'info_005.jpg',
]
const eventImages = getEventImages()
const alias = eventImages.alias
const images = eventImages.images

export default function Page({ view, isDk }: PageProps) {
const { goNextPage } = useContext(PageCtx)
Expand Down
29 changes: 6 additions & 23 deletions src/components/Page4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,20 @@ import { Optional } from '@/utils/types'
import { TalkView } from './models/talkView'
import { useContext } from 'react'
import { PageCtx } from './models/pageContext'
import VideoPlaylist, { Playlist } from './VideoPlaylist'
import VideoPlaylist from './VideoPlaylist'
import { VIDEO_PLAYLIST } from '@/constants/video-config'

type Props = { view: Optional<TalkView> }

// CM スポンサーがいない時には 各 source をコメントアウトする

const playlist: Playlist = [
{
sources: [
{
src: 'https://pub-ac15e822806e471884e2b63b26f353c6.r2.dev/srekaigi2026/makuai.mp4',
type: 'video/mp4',
},
],
},
// {
// sources: [
// {
// src: 'https://web-intermission.s3.isk01.sakurastorage.jp/cndw2024/cm5.mp4',
// type: 'video/mp4',
// },
// ],
// },
]

export default function Page(_: Props) {
const { goNextPage } = useContext(PageCtx)

return (
<div className="w-full h-full">
<VideoPlaylist onEnded={goNextPage} playlist={playlist}></VideoPlaylist>
<VideoPlaylist
onEnded={goNextPage}
playlist={VIDEO_PLAYLIST}
></VideoPlaylist>
</div>
)
}
34 changes: 34 additions & 0 deletions src/constants/image-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// イベントプロジェクト画像の設定

// イベントごとの画像設定
export const EVENT_PROJECT_IMAGES = {
srekaigi2026: {
alias: 'srekaigi2026',
images: [
'info_001.jpg',
'info_002.jpg',
'info_003.jpg',
'info_004.jpg',
'info_005.jpg',
],
},
// 他のイベントを追加する場合はここに記述
// cnds2025: {
// alias: 'cnds2025',
// images: [
// 'info_001.jpg',
// 'info_002.jpg',
// ],
// },
}

// デフォルトのイベント(環境変数やconfigから動的に選択することも可能)
export const DEFAULT_EVENT = 'srekaigi2026'

// 現在のイベントの画像設定を取得
export function getEventImages(eventKey: string = DEFAULT_EVENT) {
return (
EVENT_PROJECT_IMAGES[eventKey as keyof typeof EVENT_PROJECT_IMAGES] ||
EVENT_PROJECT_IMAGES[DEFAULT_EVENT]
)
}
30 changes: 30 additions & 0 deletions src/constants/video-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 動画設定の一元管理

// VideoPlaylistで使用するプレイリスト形式
export const VIDEO_PLAYLIST = [
{
sources: [
{
src: 'https://pub-ac15e822806e471884e2b63b26f353c6.r2.dev/srekaigi2026/makuai.mp4',
type: 'video/mp4',
},
],
},
// CM動画 (必要に応じてコメントアウト/アンコメント)
// {
// sources: [
// {
// src: 'https://web-intermission.s3.isk01.sakurastorage.jp/cndw2024/cm5.mp4',
// type: 'video/mp4',
// },
// ],
// },
]

// Service Workerでキャッシュする動画URLのリスト
export const CACHE_VIDEO_URLS = VIDEO_PLAYLIST.flatMap((item) =>
item.sources.map((source) => source.src)
)

// Service Workerのビデオキャッシュを許可するパス
export const ALLOWED_CACHE_PATHS = ['/break-dk/talks/', '/break/talks/']
22 changes: 19 additions & 3 deletions src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// https://github.com/GoogleChrome/workbox/issues/2519
import { precacheAndRoute } from 'workbox-precaching'
import { CACHE_VIDEO_URLS, ALLOWED_CACHE_PATHS } from './constants/video-config'

precacheAndRoute(self.__WB_MANIFEST)

const CACHE_NAME = 'video-cache'
const VIDEO_URL = [
'https://pub-ac15e822806e471884e2b63b26f353c6.r2.dev/srekaigi2026/makuai.mp4',
]
const VIDEO_URL = CACHE_VIDEO_URLS

async function updateCache() {
const status = VIDEO_URL.reduce((acc, url) => {
Expand Down Expand Up @@ -45,9 +44,26 @@ self.addEventListener('install', (event) => {
// https://developer.mozilla.org/ja/docs/Web/API/Service_Worker_API/Using_Service_Workers
self.addEventListener('fetch', (event) => {
console.debug('fetch event:', event.request)

// ビデオファイルでない場合は処理しない
if (!event.request.url.endsWith('.mp4')) {
return
}

// リファラーをチェックして、特定のパスからのリクエストのみ処理
const referer = event.request.referrer
const url = new URL(event.request.url)

// 許可されたパスからのリクエストのみキャッシュを使用
const shouldUseCache = ALLOWED_CACHE_PATHS.some((path) =>
referer.includes(path)
)

if (!shouldUseCache) {
console.log('video cache skipped (not from allowed path):', url.href)
return
}

console.log('video request: url:', event.request.url)

const response = (async () => {
Expand Down