{videos.map((video, index) => (
@@ -412,203 +1665,47 @@ function Playlist() {
}
```
----
-
-## ⌨️ Klavye Kısayolları
-
-Video player, kullanıcı deneyimini geliştirmek için kapsamlı klavye desteği sunar:
-
-| Tuş | Aksiyon |
-|-----|---------|
-| `Space` veya `K` | Oynat/Duraklat |
-| `←` (Sol Ok) | 5 saniye geri sar |
-| `→` (Sağ Ok) | 5 saniye ileri sar |
-| `J` | 10 saniye geri sar |
-| `L` | 10 saniye ileri sar |
-| `↑` (Yukarı Ok) | Ses seviyesini artır (%5) |
-| `↓` (Aşağı Ok) | Ses seviyesini azalt (%5) |
-| `M` | Sessiz/Sesli |
-| `F` | Tam ekran aç/kapat |
-| `P` | Picture-in-Picture |
-| `0` | Başa dön (%0) |
-| `1-9` | İlgili yüzdeye atla (%10-%90) |
-| `Home` | Başa dön |
-| `End` | Sona git |
-| `<` | Oynatma hızını azalt (0.25x) |
-| `>` | Oynatma hızını artır (0.25x) |
-
-**Not:** Klavye kısayolları sadece video player'a focus edildiğinde çalışır.
-
----
-
-## 📱 Touch Gesture'lar
-
-Mobil cihazlarda kullanıcı deneyimini geliştiren touch gesture'lar:
-
-### Temel Gesture'lar
-
-- **Tek Dokunuş**: Oynat/Duraklat
-- **Çift Dokunuş (Sol)**: 10 saniye geri sar
-- **Çift Dokunuş (Sağ)**: 10 saniye ileri sar
-
-### Swipe Gesture'ları
-
-- **Sağa Kaydır**: İleri sar (kaydırma mesafesine göre)
-- **Sola Kaydır**: Geri sar (kaydırma mesafesine göre)
-- **Yukarı Kaydır**: Ses seviyesini artır
-- **Aşağı Kaydır**: Ses seviyesini azalt
-
-### Pinch & Zoom
-
-- **Pinch**: Video zoom (bazı tarayıcılarda)
-
----
-
-## 🎨 Stil ve Özelleştirme
-
-### CSS Değişkenleri
-
-Video player, CSS değişkenleri kullanarak kolayca özelleştirilebilir. İşte tüm değişkenler:
-
-```css
-:root {
- /* Ana Renkler */
- --player-primary: #ef4444; /* Ana renk */
- --player-primary-hover: #dc2626; /* Hover rengi */
- --player-primary-active: #b91c1c; /* Active rengi */
- --player-primary-light: rgba(239, 68, 68, 0.2); /* Açık renk */
-
- /* Arkaplan Renkleri */
- --player-bg: #000000; /* Ana arkaplan */
- --player-bg-controls: rgba(0, 0, 0, 0.85); /* Kontrol paneli */
- --player-bg-overlay: rgba(0, 0, 0, 0.6); /* Overlay */
- --player-bg-menu: rgba(20, 20, 20, 0.95); /* Menu arkaplan */
-
- /* Yazı Renkleri */
- --player-text: #ffffff; /* Ana yazı */
- --player-text-secondary: #d1d5db; /* İkincil yazı */
- --player-text-muted: #9ca3af; /* Soluk yazı */
-
- /* Kenarlık & Ayırıcı */
- --player-border: #374151;
- --player-divider: rgba(255, 255, 255, 0.1);
-
- /* Progress & Buffered */
- --player-buffered: rgba(239, 68, 68, 0.3);
- --player-progress-bg: rgba(255, 255, 255, 0.3);
-
- /* Gölgeler */
- --player-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
- --player-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
- --player-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
-
- /* Geçişler */
- --player-transition-fast: 150ms;
- --player-transition-normal: 250ms;
- --player-transition-slow: 400ms;
-
- /* Z-index */
- --player-z-video: 1;
- --player-z-subtitle: 10;
- --player-z-controls: 20;
- --player-z-menu: 30;
- --player-z-loading: 40;
-
- /* Boşluklar */
- --player-spacing-xs: 6px;
- --player-spacing-sm: 10px;
- --player-spacing-md: 14px;
- --player-spacing-lg: 20px;
- --player-spacing-xl: 28px;
-
- /* Border Radius */
- --player-radius-sm: 4px;
- --player-radius-md: 6px;
- --player-radius-lg: 8px;
- --player-radius-full: 9999px;
-
- /* İkon Boyutları */
- --player-icon-sm: 20px;
- --player-icon-md: 28px;
- --player-icon-lg: 36px;
- --player-icon-xl: 56px;
-}
-```
-
-### Tema Özelleştirme Örnekleri
-
-#### Koyu Mavi Tema
-
-```css
-:root {
- --player-primary: #3b82f6;
- --player-primary-hover: #2563eb;
- --player-primary-active: #1d4ed8;
- --player-bg: #0f172a;
-}
-```
+### CORS Hata Yönetimi
```tsx
-// veya JavaScript ile
-
-```
+import { VideoPlayer, isCORSError, getCORSErrorMessage } from '@alper/video-player'
+import { useState } from 'react'
-#### Yeşil Tema
+function VideoWithCORSHandling() {
+ const [error, setError] = useState
(null)
+ const videoUrl = 'https://example.com/video.mp4'
-```css
-:root {
- --player-primary: #10b981;
- --player-primary-hover: #059669;
- --player-primary-active: #047857;
-}
-```
+ const handleError = (err: Error) => {
+ if (isCORSError(err)) {
+ const message = getCORSErrorMessage(err, videoUrl)
+ setError(message)
+ console.error('CORS Hatası:', message)
+ } else {
+ setError(err.message)
+ }
+ }
-#### Mor Tema
+ return (
+
+
-```css
-:root {
- --player-primary: #8b5cf6;
- --player-primary-hover: #7c3aed;
- --player-primary-active: #6d28d9;
-}
-```
-
-### Özel CSS ile Özelleştirme
-
-Daha fazla kontrol için özel CSS yazabilirsiniz:
-
-```css
-/* Video player container boyutu */
-.video-player {
- max-width: 1200px;
- margin: 0 auto;
- border-radius: 12px;
- overflow: hidden;
- box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
-}
-
-/* Kontrol paneli opacity */
-.video-controls {
- background: rgba(0, 0, 0, 0.95) !important;
-}
-
-/* Progress bar yüksekliği */
-.progress-bar {
- height: 6px !important;
-}
-
-/* Button boyutları */
-.control-button {
- width: 48px !important;
- height: 48px !important;
+ {error && (
+
+
Video Yükleme Hatası
+
{error}
+
Çözüm: Video sunucunuzda CORS headers ekleyin:
+
+ Access-Control-Allow-Origin: *{'\n'}
+ Access-Control-Allow-Methods: GET, HEAD{'\n'}
+ Access-Control-Allow-Headers: Range
+
+
+ )}
+
+ )
}
```
@@ -616,732 +1713,897 @@ Daha fazla kontrol için özel CSS yazabilirsiniz:
## 🔧 Gelişmiş Kullanım
-### Context API ile Video Kontrolü
+### Feature Detection
-Video player'ın context'ini kullanarak programatik kontrol:
+```typescript
+import {
+ hasNativeHLS,
+ hasMSE,
+ hasPIP,
+ hasFullscreen,
+ hasTouch,
+ isIOSSafari,
+ hasVolumeControl
+} from '@alper/video-player'
+
+// Safari'de native HLS var mı kontrol et
+if (hasNativeHLS()) {
+ console.log('Native HLS destekleniyor')
+}
+
+// MSE desteği kontrol et (HLS.js için gerekli)
+if (hasMSE()) {
+ console.log('HLS.js kullanılabilir')
+}
+
+// PIP desteği kontrol et
+if (hasPIP()) {
+ console.log('Picture-in-Picture kullanılabilir')
+}
+
+// iOS Safari kontrolü
+if (isIOSSafari()) {
+ console.log('iOS Safari - volume control yok')
+}
+
+// Ses kontrolü desteği
+if (hasVolumeControl()) {
+ // Volume slider göster
+} else {
+ // Volume slider gizle (iOS)
+}
+```
+
+### Manual HLS.js Setup
+
+```typescript
+import { loadHls, setupHls } from '@alper/video-player'
+
+async function customHlsSetup() {
+ const videoElement = document.querySelector('video')
+ const Hls = await loadHls()
+
+ if (Hls) {
+ const { instance, cleanup } = setupHls(
+ Hls,
+ videoElement,
+ 'https://example.com/stream.m3u8',
+ {
+ onManifestParsed: (qualities, audioTracks, subtitles) => {
+ console.log('Qualities:', qualities)
+ console.log('Audio tracks:', audioTracks)
+ console.log('Subtitles:', subtitles)
+ },
+ onError: (error) => {
+ console.error('HLS error:', error)
+ }
+ }
+ )
+
+ // instance → hls.js instance
+ // cleanup → cleanup function (unmount'ta çağır)
+
+ return { instance, cleanup }
+ }
+}
+```
+
+### Custom Subtitle Processing
+
+```typescript
+import { parseSRT, createSubtitleBlobURL, fetchSubtitle } from '@alper/video-player'
+
+async function loadCustomSubtitle(url: string) {
+ // SRT dosyasını fetch et
+ const srtContent = await fetchSubtitle(url)
+
+ // VTT'ye dönüştür
+ const vttContent = parseSRT(srtContent)
+
+ // Blob URL oluştur
+ const blobUrl = createSubtitleBlobURL(vttContent)
+
+ // Video elementine ekle
+ const track = document.createElement('track')
+ track.kind = 'subtitles'
+ track.label = 'Custom'
+ track.srclang = 'en'
+ track.src = blobUrl
+
+ videoElement.appendChild(track)
+
+ // Cleanup
+ return () => URL.revokeObjectURL(blobUrl)
+}
+```
+
+### Progressive Download Monitoring
```tsx
-import { VideoPlayer, usePlayerContext, PlayerProvider } from '@alper/video-player'
+function VideoWithProgress() {
+ const [buffered, setBuffered] = useState(0)
+ const { videoRef } = usePlayerContext()
-function VideoControls() {
- const {
- play,
- pause,
- seek,
- setVolume,
- toggleFullscreen,
- videoState
- } = usePlayerContext()
+ useEffect(() => {
+ const video = videoRef.current
+ if (!video) return
+
+ const updateBuffer = () => {
+ if (video.buffered.length > 0) {
+ const bufferedEnd = video.buffered.end(video.buffered.length - 1)
+ setBuffered((bufferedEnd / video.duration) * 100)
+ }
+ }
+
+ video.addEventListener('progress', updateBuffer)
+ return () => video.removeEventListener('progress', updateBuffer)
+ }, [videoRef])
return (
-
-
-
-
-
-
-
Oynatılıyor: {videoState.playing ? 'Evet' : 'Hayır'}
-
Süre: {videoState.duration}s
-
Mevcut: {videoState.currentTime}s
+
+
+ Buffer: {buffered.toFixed(0)}%
+
)
}
-
-function App() {
- return (
-
-
-
-
- )
-}
-```
-
-### Custom Hook'lar Kullanımı
-
-Kendi player'ınızı oluşturmak için hook'ları kullanabilirsiniz:
-
-```tsx
-import { useKeyboardShortcuts, useTouchGestures } from '@alper/video-player'
-
-function CustomPlayer() {
- const videoRef = useRef(null)
-
- // Klavye kısayollarını ekle
- useKeyboardShortcuts(videoRef, {
- onPlayPause: () => {
- if (videoRef.current?.paused) {
- videoRef.current?.play()
- } else {
- videoRef.current?.pause()
- }
- },
- onSeek: (seconds) => {
- if (videoRef.current) {
- videoRef.current.currentTime += seconds
- }
- }
- })
-
- // Touch gesture'ları ekle
- useTouchGestures(videoRef, {
- onDoubleTapLeft: () => console.log('Geri sar'),
- onDoubleTapRight: () => console.log('İleri sar'),
- })
-
- return
-}
-```
-
-### Altyazı İşlemleri
-
-Altyazıları programatik olarak işleme:
-
-```tsx
-import { parseSRT, createSubtitleBlobURL, fetchSubtitle } from '@alper/video-player'
-
-// SRT dosyasını VTT'ye dönüştür
-async function convertSRTtoVTT(srtUrl: string) {
- const srtContent = await fetch(srtUrl).then(r => r.text())
- const vttContent = parseSRT(srtContent)
- const blobUrl = createSubtitleBlobURL(vttContent)
- return blobUrl
-}
-
-// Altyazıyı fetch et ve kullan
-async function loadSubtitle(url: string) {
- const subtitle = await fetchSubtitle(url)
- console.log(subtitle)
-}
-```
-
-### CORS Kontrolü
-
-Video URL'lerini yüklemeden önce CORS kontrolü:
-
-```tsx
-import { validateVideoURL, checkVideoCORS } from '@alper/video-player'
-
-async function loadVideo(url: string) {
- // URL validasyonu
- const validation = validateVideoURL(url)
- if (!validation.valid) {
- alert(`Geçersiz URL: ${validation.error}`)
- return
- }
-
- // CORS kontrolü
- const corsCheck = await checkVideoCORS(url)
- if (!corsCheck.supported) {
- console.error('CORS hatası:', corsCheck.error)
-
- if (corsCheck.needsProxy) {
- console.log('Proxy gerekiyor')
- // Proxy kullanarak yükle
- }
- return
- }
-
- // Güvenli şekilde yükle
- return
-}
-```
-
-### Zaman Formatı Yardımcıları
-
-```tsx
-import { formatTime, parseTime } from '@alper/video-player'
-
-// Saniyeyi formatla
-formatTime(125) // "02:05"
-formatTime(3661) // "01:01:01"
-
-// Formatlanmış zamanı saniyeye çevir
-parseTime("02:05") // 125
-parseTime("01:01:01") // 3661
```
---
-## 🌍 Çoklu Dil Desteği (i18n)
+## 🎨 Tema ve Özelleştirme
-Video player İngilizce ve Türkçe dil desteği ile gelir.
+### CSS Variables
-### Dil Değiştirme
+Tüm tema CSS değişkenleri ile özelleştirilebilir:
-```tsx
-// Türkçe arayüz
-
+```css
+:root {
+ /* Ana renkler */
+ --player-primary: #ef4444;
+ --player-primary-hover: #dc2626;
+ --player-bg: #000000;
+ --player-text: #ffffff;
-// İngilizce arayüz
-
-```
+ /* Spacing */
+ --player-spacing-xs: 4px;
+ --player-spacing-sm: 8px;
+ --player-spacing-md: 12px;
+ --player-spacing-lg: 16px;
-### Özel Çeviriler
+ /* Border radius */
+ --player-radius: 14px;
+ --player-radius-sm: 8px;
-Kendi çevirilerinizi eklemek için:
+ /* Transitions */
+ --player-transition-fast: 120ms;
+ --player-transition-normal: 200ms;
+ --player-transition-slow: 300ms;
-```tsx
-import { translations, getTranslations } from '@alper/video-player'
-
-// Mevcut çevirileri genişlet
-translations.tr.customKey = 'Özel metin'
-translations.en.customKey = 'Custom text'
-
-// Çevirileri kullan
-const t = getTranslations('tr')
-console.log(t.play) // "Oynat"
-console.log(t.pause) // "Duraklat"
-```
-
-### Desteklenen Diller
-
-| Dil | Kod | Durum |
-|-----|-----|-------|
-| Türkçe | `tr` | ✅ Tam destek |
-| İngilizce | `en` | ✅ Tam destek |
-
----
-
-## 🎯 HLS Streaming Detayları
-
-### Otomatik HLS Algılama
-
-Video player, `.m3u8` uzantılı dosyaları otomatik algılar ve hls.js'i yükler:
-
-```tsx
-
-```
-
-### Manuel HLS Kontrolü
-
-```tsx
-import Hls from 'hls.js'
-
-// HLS desteğini kontrol et
-if (Hls.isSupported()) {
- console.log('HLS destekleniyor (hls.js ile)')
-} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
- console.log('Native HLS destekleniyor (Safari)')
+ /* Z-index layers */
+ --player-z-video: 1;
+ --player-z-overlay: 10;
+ --player-z-controls: 20;
+ --player-z-menu: 30;
+ --player-z-loading: 40;
}
```
-### HLS Kalite Seçimi
-
-HLS stream'inde kalite seçimi otomatik olarak aktif olur:
+### Custom Theme Örneği
+**Mavi Tema:**
```tsx
-```
-
-### HLS Hata Yönetimi
-
-```tsx
- {
- console.error('HLS hatası:', error)
- // Fallback video göster
+ src="video.mp4"
+ theme={{
+ primaryColor: '#3b82f6',
+ accentColor: '#2563eb',
+ backgroundColor: '#1e293b',
+ textColor: '#f1f5f9'
}}
/>
```
----
-
-## 📱 Responsive Tasarım
-
-### Mobil Uyumluluk
-
-Video player mobil cihazlarda mükemmel çalışır:
-
+**Yeşil Tema:**
```tsx
-
-
-
-```
-
-```css
-.mobile-container {
- width: 100%;
- padding: 0;
-}
-
-/* Mobil için özel ayarlar */
-@media (max-width: 768px) {
- .video-player {
- border-radius: 0;
- }
-
- .video-controls {
- padding: 8px !important;
- }
-}
-```
-
-### Aspect Ratio Koruması
-
-```tsx
-
-
-
-```
-
-### Grid Layout ile Çoklu Video
-
-```css
-.video-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
- gap: 20px;
- padding: 20px;
-}
-```
-
-```tsx
-
-
-
-
-
-
-```
-
----
-
-## ⚠️ Dikkat Edilmesi Gerekenler
-
-### 1. CORS (Cross-Origin Resource Sharing)
-
-Video dosyaları farklı bir domain'de ise CORS header'ları gereklidir:
-
-```
-Access-Control-Allow-Origin: *
-Access-Control-Allow-Methods: GET, HEAD, OPTIONS
-Access-Control-Allow-Headers: Range
-```
-
-**Çözüm:**
-- Sunucunuzda CORS'u etkinleştirin
-- CDN kullanıyorsanız CORS ayarlarını yapın
-- Veya proxy sunucu kullanın
-
-### 2. Otomatik Oynatma Kısıtlamaları
-
-Modern tarayıcılar, kullanıcı etkileşimi olmadan otomatik oynatmayı engelleyebilir:
-
-```tsx
-// Otomatik oynatma için sessiz gereklidir
```
-### 3. iOS Safari Davranışları
-
-iOS Safari'de bazı özel durumlar vardır:
-
-- Fullscreen native player'ı açar
-- Volume kontrolü çalışmaz (sistem ses seviyesi kullanılır)
-- Otomatik oynatma kısıtlamaları daha katıdır
-
+**Dark Theme:**
```tsx
-import { features } from '@alper/video-player'
+
+```
-if (features.isIOSSafari()) {
- console.log('iOS Safari tespit edildi')
- // iOS spesifik ayarlamalar
+### CSS Override ile Özelleştirme
+
+```css
+/* Progress bar yüksekliğini artır */
+.video-player .progress-bar {
+ height: 8px !important;
}
-if (!features.hasVolumeControl()) {
- // Volume kontrolünü gizle
+/* Kontrol butonlarını büyüt */
+.video-player .control-button {
+ width: 48px !important;
+ height: 48px !important;
+}
+
+/* Loading spinner rengini değiştir */
+.video-player .loading-spinner {
+ border-color: #10b981 transparent transparent transparent !important;
+}
+
+/* Settings menü arka planı */
+.video-player .settings-menu {
+ background: rgba(30, 41, 59, 0.95) !important;
+ backdrop-filter: blur(10px) !important;
}
```
-### 4. Büyük Video Dosyaları
+### Responsive Design
-Büyük video dosyaları için HTTP Range Request desteği önemlidir:
+```css
+/* Mobil cihazlar için özelleştirme */
+@media (max-width: 768px) {
+ .video-player {
+ --player-spacing-md: 8px;
+ --player-radius: 8px;
+ }
-```
-Accept-Ranges: bytes
-Content-Range: bytes 0-1024/5242880
-```
+ .video-player .control-button {
+ width: 40px;
+ height: 40px;
+ }
-### 5. HLS.js Yükleme
+ .video-player .time-display {
+ font-size: 12px;
+ }
+}
-HLS.js optional dependency olarak eklenmiştir. NPM'den yüklenemezse CDN'den otomatik yüklenir.
+/* Tablet için */
+@media (min-width: 769px) and (max-width: 1024px) {
+ .video-player {
+ --player-spacing-md: 10px;
+ }
+}
-**Manuel kurulum:**
-```bash
-npm install hls.js
-```
-
-### 6. Performance İpuçları
-
-```tsx
-// ❌ Kötü: Her render'da yeni object
-
-
-// ✅ İyi: Dışarıda tanımla
-const theme = { primaryColor: '#ff0000' }
-
-
-// ✅ Daha iyi: useMemo kullan
-const theme = useMemo(() => ({
- primaryColor: '#ff0000'
-}), [])
-
-```
-
-### 7. Memory Leak Önleme
-
-Component unmount olduğunda player otomatik temizlenir. Manuel cleanup gerekmez.
-
-### 8. TypeScript Strict Mode
-
-TypeScript strict mode ile tam uyumludur:
-
-```typescript
-import type { VideoPlayerProps } from '@alper/video-player'
-
-const props: VideoPlayerProps = {
- src: 'video.mp4',
- // TypeScript tüm prop'ları kontrol eder
+/* Desktop için */
+@media (min-width: 1025px) {
+ .video-player {
+ --player-spacing-md: 12px;
+ }
}
```
---
-## 🧪 Test ve Hata Ayıklama
+## 🌍 Uluslararasılaştırma (i18n)
-### Hata Yakalama
+### Desteklenen Diller
+
+- **English (en)** - Varsayılan
+- **Turkish (tr)** - Türkçe
+
+### Otomatik Dil Tespiti
```tsx
-function SafePlayer() {
- const [error, setError] = useState(null)
+// Tarayıcı dilini otomatik tespit eder
+
+```
- if (error) {
- return (
-
-
Video yüklenemedi
-
{error.message}
-
-
- )
+### Manuel Dil Seçimi
+
+```tsx
+// Türkçe zorla
+
+
+// İngilizce zorla
+
+```
+
+### Translation Keys
+
+```typescript
+interface Translations {
+ noSubtitlesAvailable: string // "No subtitles available" / "Altyazı mevcut değil"
+ subtitles: string // "Subtitles" / "Altyazı"
+ off: string // "Off" / "Kapalı"
+ auto: string // "Auto" / "Otomatik"
+ quality: string // "Quality" / "Kalite"
+ speed: string // "Speed" / "Hız"
+ normal: string // "Normal" / "Normal"
+ default: string // "Default" / "Varsayılan"
+ audioTrack: string // "Audio Track" / "Ses"
+ settings: string // "Settings" / "Ayarlar"
+ level: string // "Level" / "Seviye"
+}
+```
+
+### Programmatic Access
+
+```typescript
+import { getTranslations, detectBrowserLanguage } from '@alper/video-player'
+
+// Tarayıcı dilini tespit et
+const browserLang = detectBrowserLanguage() // "tr", "en-US", vb.
+
+// Translation'ları al
+const t = getTranslations('tr')
+console.log(t.subtitles) // "Altyazı"
+console.log(t.quality) // "Kalite"
+
+// Fallback ile
+const t2 = getTranslations('fr') // Fransızca yok
+console.log(t2.subtitles) // "Subtitles" (İngilizce fallback)
+```
+
+### Yeni Dil Ekleme
+
+`src/i18n/index.ts` dosyasını düzenleyin:
+
+```typescript
+export const translations: Record = {
+ en: { /* ... */ },
+ tr: { /* ... */ },
+ // Yeni dil ekle
+ es: {
+ noSubtitlesAvailable: 'No hay subtítulos disponibles',
+ subtitles: 'Subtítulos',
+ off: 'Desactivado',
+ auto: 'Automático',
+ quality: 'Calidad',
+ speed: 'Velocidad',
+ normal: 'Normal',
+ default: 'Predeterminado',
+ audioTrack: 'Pista de audio',
+ settings: 'Configuración',
+ level: 'Nivel',
}
+}
+```
+
+---
+
+## ⚡ Performans
+
+### Bundle Size
+
+| Component | Size (gzipped) |
+|-----------|----------------|
+| Core library | ~8KB |
+| CSS | ~7KB |
+| **Total** | **~15KB** |
+| HLS.js (lazy) | ~200KB |
+| FLV.js (lazy) | ~150KB |
+
+### Optimizasyon Teknikleri
+
+1. **Lazy Loading**
+ - HLS.js ve FLV.js sadece ihtiyaç duyulduğunda yüklenir
+ - Settings menü lazy-loaded
+ - CDN fallback ile yükleme garantisi
+
+2. **Tree Shaking**
+ - ES Module format
+ - Kullanılmayan kod elimine edilir
+ - Named exports ile selective import
+
+3. **Code Splitting**
+ - Async component loading
+ - Dynamic imports
+ - Route-based splitting için hazır
+
+4. **CSS Optimization**
+ - CSS minification
+ - Tek dosyada bundle
+ - CSS-only animasyonlar (JS yok)
+ - Critical CSS inline (opsiyonel)
+
+5. **React Optimization**
+ - React.memo kullanımı
+ - useCallback/useMemo
+ - Gereksiz re-render önleme
+ - Event delegation
+
+6. **Memory Management**
+ - Proper cleanup (useEffect return)
+ - Blob URL revocation
+ - HLS/FLV instance destroy
+ - Event listener removal
+
+### Performance Monitoring
+
+```tsx
+import { useEffect } from 'react'
+import { VideoPlayer } from '@alper/video-player'
+
+function MonitoredVideo() {
+ useEffect(() => {
+ // Bundle size monitoring
+ console.log('Initial bundle loaded')
+
+ // Measure loading time
+ const start = performance.now()
+
+ return () => {
+ const end = performance.now()
+ console.log(`Player active for ${end - start}ms`)
+ }
+ }, [])
return (
{
- console.error('Video hatası:', err)
- setError(err)
+ src="video.mp4"
+ onLoadedMetadata={() => {
+ console.log('Video metadata loaded')
}}
/>
)
}
```
-### Loading State
-
-```tsx
-function PlayerWithLoading() {
- const [loading, setLoading] = useState(true)
-
- return (
-
- {loading && (
-
- Yükleniyor...
-
- )}
-
setLoading(false)}
- />
-
- )
-}
-```
-
-### Console Debug
-
-```tsx
- console.log('[DEBUG] Play')}
- onPause={() => console.log('[DEBUG] Pause')}
- onTimeUpdate={(t) => console.log('[DEBUG] Time:', t)}
- onError={(e) => console.error('[DEBUG] Error:', e)}
- onLoadedMetadata={() => console.log('[DEBUG] Metadata loaded')}
-/>
-```
-
----
-
-## 📊 Browser Desteği
-
-| Browser | Versiyon | Destek |
-|---------|----------|--------|
-| Chrome | 90+ | ✅ Tam |
-| Firefox | 88+ | ✅ Tam |
-| Safari | 14+ | ✅ Tam |
-| Edge | 90+ | ✅ Tam |
-| Opera | 76+ | ✅ Tam |
-| iOS Safari | 14+ | ✅ Tam |
-| Chrome Mobile | 90+ | ✅ Tam |
-| Samsung Internet | 15+ | ✅ Tam |
-
-### Feature Desteği
-
-| Özellik | Chrome | Firefox | Safari | Edge |
-|---------|--------|---------|--------|------|
-| HLS | ✅* | ✅* | ✅ | ✅* |
-| PIP | ✅ | ✅ | ✅ | ✅ |
-| Fullscreen | ✅ | ✅ | ✅ | ✅ |
-| Subtitles | ✅ | ✅ | ✅ | ✅ |
-| Touch | ✅ | ✅ | ✅ | ✅ |
-
-*hls.js ile desteklenir (Safari'de native)
-
----
-
-## 🚀 Production Deployment
-
-### Build Optimizasyonu
-
-```bash
-# Production build
-npm run build:lib
-
-# Bundle boyutunu kontrol et
-npm run build:lib -- --mode production
-
-# Gzip sıkıştırma ile
-gzip -k dist/video-player.js
-```
-
-### CDN Kullanımı
-
-```html
-
-
-
-
-
-```
-
-### Lazy Loading
+### Loading Strategy
```tsx
+// Lazy load player component
import { lazy, Suspense } from 'react'
const VideoPlayer = lazy(() =>
- import('@alper/video-player').then(m => ({ default: m.VideoPlayer }))
+ import('@alper/video-player').then(module => ({
+ default: module.VideoPlayer
+ }))
)
function App() {
return (
- Video player yükleniyor...