Anasayfa, Sidebar, Large Playlists - Tüm Senaryolar
⚠️ SORUN: Anasayfa section'ları, sidebar linkleri, 500+ şarkılı playlist'ler için context YOK!
Anasayfada birçok section var: Yeni Albümler, Popüler Şarkılar, Önerilen Playlistler, Son Eklenenler vb. Her section'dan şarkı çalınırsa farklı context uygulanmalı!
Anasayfadaki "Yeni Albümler" section'ından kullanıcı bir albüme tıklar → Şarkı çalar
{type: "album", id: 45, genreId: 9}
{type: "discovery", section: "new-releases"}
✅ Önerilen: Seçenek A (Album context) - Kullanıcı bir albüm seçti, albümü dinlesin
Anasayfadaki "Popüler Şarkılar" section'ından tek bir şarkı seçilir
{type: "popular", period: "weekly"}
{type: "album", id: şarkının albumId}
✅ Önerilen: Seçenek A (Popular context) - Kullanıcı popüler müzik istiyorsa popüler devam etsin
Anasayfadaki "Önerilen Playlistler" section'ından bir playlist seçilir
{type: "playlist", id: 23, name: "Chill Vibes"}
✅ Playlist seçildi, playlist'ten devam et
{type: "recent", order: "created_at DESC"}
{type: "favorites", userId: 123}
Sol taraftaki navigation menu'deki linkler. Her link farklı bir context type'a işaret eder.
Anasayfa'ya tıklanırsa context temizlenmez, son context devam eder
Genres sayfasına git → Context belirlenmez (kullanıcı genre seçene kadar)
Albums sayfasına git → Context belirlenmez
Playlists sayfasına git → Context belirlenmez
Sectors sayfasına git → Context belirlenmez
Radios sayfasına git → Context belirlenmez
💡 Sidebar Kuralı:
Sidebar'daki linkler sadece sayfalar arası geçiş yapar. Context, kullanıcı şarkı/albüm/playlist ÇALANA KADAR belirlenmez.
Bazı playlist'ler 500 hatta 1000 şarkı içerebilir. Tüm şarkıları queue'ya yüklemek:
case 'playlist':
$playlist = Playlist::find($context['id']);
$totalSongs = $playlist->songs()->count();
$currentOffset = $context['currentOffset'] ?? 0;
// Sıradaki 10 şarkıyı çek
$songs = $playlist->songs()
->skip($currentOffset)
->take(10)
->get();
// Eğer playlist bitti ve loop aktifse başa dön
if ($songs->isEmpty() && $context['loop']) {
$songs = $playlist->songs()->take(10)->get();
$newOffset = 10;
} else {
$newOffset = $currentOffset + $songs->count();
}
return [
'songs' => $songs,
'newOffset' => $newOffset,
'totalSongs' => $totalSongs,
'hasMore' => $newOffset < $totalSongs
];
✅ Sonuç: 500 şarkılı playlist olsa bile, her seferinde sadece 10-15 şarkı yüklenir. Memory ve performance problem yok!
Kullanıcı "Shuffle" modunu aktif ederse:
case 'playlist':
$playlist = Playlist::find($context['id']);
// Rastgele 10 şarkı çek (offset yok!)
$songs = $playlist->songs()
->inRandomOrder()
->take(10)
->get();
return ['songs' => $songs];
💡 Shuffle mode'da offset yok, her seferinde rastgele 10 şarkı
Sistem genelinde kullanılacak TÜM context tipleri:
{type: "genre", id: 9}
{type: "album", id: 45, genreId: 9}
{type: "playlist", id: 23, currentOffset: 0}
{type: "sector", id: 3}
{type: "radio", id: 5, playlists: [12,15]}
{type: "popular", period: "weekly"}
{type: "recent", order: "created_at DESC"}
{type: "favorites", userId: 123}
{type: "artist", id: 67}
{type: "search", query: "jazz"}
✅ setPlayContext() - 10 context type desteği
✅ getPlayContext()
✅ updatePlayContext() - offset güncelleme için
✅ home.blade.php - 5 section için context
✅ genres, albums, playlists, sectors, radios
✅ favorites, search results
✅ 10 context type için switch-case
✅ Playlist offset mekanizması
✅ Shuffle mode desteği
✅ refillQueue() - offset update logic
✅ Large playlist handling
✅ 10 context type testi
✅ 500 şarkılı playlist testi
✅ Anasayfa section testleri
⏱️ Toplam Süre: ~10 saat (v1: 6 saat → v2: 10 saat)
Anasayfa section'ları + 500+ şarkılı playlist desteği eklendi
1. Anasayfa 5 section için context mapping (Yeni Albümler, Popüler, Önerilen, vb.)
2. Sidebar navigation context kuralları (sayfa değiştir, context korun)
3. 500+ şarkılı playlist için chunk strategy (offset mekanizması)
4. 10 context type taksonomisi (genre, album, playlist, sector, radio, popular, recent, favorites, artist, search)
5. Hala sıfır migration! Sadece frontend + 1 API endpoint
✅ Tüm senaryolar kapsandı!