An iOS Netflix clone application built with Swift and UIKit, featuring movie browsing, video playback, danmaku (bullet comments), subtitles, and more.
- Movie Browsing: Browse trending, upcoming, and top-rated movies and TV shows
- Search: Real-time search for movies and TV shows
- Video Preview: Watch movie trailers
- Download Management: Manage downloaded movie content
-
Playback Controls
- Play/Pause
- Seekable progress bar
- Playback speed control (0.5x, 0.75x, 1.0x, 1.25x, 1.5x, 2.0x)
- Time display (current/duration)
-
Display Features
- Subtitle support
- Danmaku system (similar to Bilibili)
- Danmaku input and sending
-
Playback Modes
- Fullscreen/Portrait switching
- Auto-rotation support
- Picture-in-Picture (PiP) mode
- Background playback support
-
Gesture Controls
- Swipe left side up/down to adjust brightness
- Swipe right side up/down to adjust volume
- Single tap to show/hide controls
-
Video Caching
- Automatic video cache management
- Offline playback support
- Language: Swift
- UI Framework: UIKit
- Architecture: MVC
- Networking: URLSession + async/await
- Video Playback: AVFoundation, AVKit
- Data Persistence: Core Data (for download management)
This project integrates the following APIs:
-
The Movie Database (TMDB) API
- Fetch movie and TV show information
- Get trending, upcoming, and top-rated content
-
YouTube Data API
- Fetch movie trailer videos
-
Pexels API
- Get high-quality sample video content
Netflix Clone/
├── iOS/
│ └── Netflix Clone/
│ ├── Controllers/
│ │ ├── Core/ # Main view controllers
│ │ │ ├── HomeViewController.swift
│ │ │ ├── SearchViewController.swift
│ │ │ ├── UpcomingViewController.swift
│ │ │ └── DownloadViewController.swift
│ │ └── General/ # General controllers
│ │ ├── SearchResultsViewController.swift
│ │ ├── TitlePreviewViewController.swift
│ │ └── CustomVideoPlayerViewController.swift
│ ├── Views/ # Custom views
│ │ ├── TitleCollectionViewCell.swift
│ │ ├── TitleTableViewCell.swift
│ │ ├── HeroHeaderUIView.swift
│ │ ├── SubtitleView.swift
│ │ ├── DanmakuView.swift
│ │ └── CollectionViewTableViewCell.swift
│ ├── ViewModels/ # View models
│ │ ├── TitleViewModel.swift
│ │ └── TitlePreviewViewModel.swift
│ ├── Models/ # Data models
│ │ ├── Movie.swift
│ │ ├── YoutubeSearchResponse.swift
│ │ └── PexelsModels.swift
│ ├── Managers/ # Managers
│ │ ├── APICaller.swift
│ │ ├── PexelsAPIManager.swift
│ │ ├── VideoCacheManager.swift
│ │ └── APIKeys.swift
│ └── Resources/
│ └── Extensions.swift
- iOS 15.0+
- Xcode 14.0+
- Swift 5.0+
- Clone the repository
git clone https://github.com/AlureLove/Netflix-Clone.git
cd Netflix-Clone- Configure API Keys
Create the APIKeys.swift file in the project and add your API keys:
struct APIKeys {
static let tmdbBearerToken = "YOUR_TMDB_BEARER_TOKEN"
static let YouTubeAPIKey = "YOUR_YOUTUBE_API_KEY"
static let pexelsAPIKey = "YOUR_PEXELS_API_KEY"
}Get your API keys:
- TMDB API: Visit https://www.themoviedb.org/settings/api to sign up and get your Bearer Token
- YouTube Data API: Visit https://console.developers.google.com/ to create a project and enable YouTube Data API v3
- Pexels API: Visit https://www.pexels.com/api/ to sign up and get your API Key
- Open the project
cd iOS/Netflix\ Clone
open Netflix\ Clone.xcodeproj- Run the project
- Select a target device or simulator
- Press the Run button (⌘ + R)
- Featured movie Hero Banner
- Category sections: Trending Movies, Trending TV Shows, Upcoming, Top Rated, etc.
- Horizontal scrolling for each category
- Real-time movie and TV show search
- Grid display of search results
- Tap to view details
- List view of upcoming movies
- Display movie poster, title, and description
- Tap to play trailer
- Manage saved movies
- Delete downloaded content
- Offline playback support
The player provides rich functionality:
- Play/Pause button
- Draggable progress bar
- Time display
- Playback speed toggle
- Subtitles: Tap subtitle button to toggle subtitle display
- Danmaku:
- Tap danmaku button to open input field
- Enter text and send danmaku
- Danmaku scrolls from right to left across the screen
- Picture-in-Picture: Support iOS PiP mode, continue watching while using other apps
- Fullscreen: Support landscape/portrait switching, auto-fullscreen in landscape
- Single Tap: Show/hide playback controls
- Left Side Swipe Up/Down: Adjust screen brightness
- Right Side Swipe Up/Down: Adjust system volume
Uses Swift's async/await pattern for network requests:
func getTrendingMovies() async throws -> [Title]Implements intelligent video caching system to enhance user experience:
- Automatic caching of played videos
- Cache size management
- Offline playback support
Bilibili-style danmaku functionality:
- Multi-lane danmaku display
- Collision avoidance algorithm
- Customizable danmaku color, size, and speed
Complete PiP functionality:
- Automatic PiP (when app enters background)
- Manual PiP toggle
- PiP state monitoring and handling
The app supports dark mode and automatically adapts to system settings.
Issues and Pull Requests are welcome!
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is for learning and demonstration purposes only.
- The Movie Database (TMDB) - Movie data provider
- YouTube Data API - Video preview provider
- Pexels - Sample video content provider
Jethro Liu
-
v1.0.0 - Initial release
- Basic movie browsing functionality
- Search and download features
- Basic video player
-
v1.1.0 - Player enhancement
- Added custom video player
- Subtitle and danmaku support
- Picture-in-Picture mode
- Gesture control features
- Video caching system