How yichengchen/atv-bilibili-demo works
Main Components and Their Groupings
• TVOS Client Application: This is the “BilibiliLive” app that includes the entire client.
• UI / Presentation Layer:
• Base components like AppDelegate, BLTabBarViewController, and numerous View Controllers (FeedViewController, LivePlayerViewController, PersonalViewController, etc.).
• Storyboards (Main.storyboard and LaunchScreen.storyboard) which define UI layouts.
• Feature-Specific Modules:
• Feed Module: Includes components under Feed (FeedCollectionViewController, StandardVideoCollectionViewController, TitleSupplementaryView, etc.).
• Player Module: Contains player-related classes, video resource loader, video player view controller, and an assortment of plugins (e.g., DebugPlugin, SpeedChangerPlugin, etc.).
• Video Module: Covers video detail, mask providers, video clips, and plugins related to video handling.
• Live Module: Houses live streaming functionality with LivePlayerViewController, LiveViewController, and related provider classes.
• Personal and other modules: These include controllers for user data such as HistoryViewController, SettingsViewController, and so on.
• DLNA Module: Handles cloud casting functionalities with UPnP / DLNA protocols (<Module/DLNA> directory).
• Networking/Request Layer:
• Defined in the “Request” folder, including classes for API requests, cookie management, WebRequest signing (wbi), and protobuf-based network definitions (dm.pb.swift, dmView.pb.swift).
• Extensions & Utilities:
• Numerous extension files that extend native types and UI classes (e.g., String.swift, DateFormatter.swift, UIView+Layout.swift).
• Logger, Keys, and configuration files.
• Supporting Files and Assets:
Relationships and Data Flow
• The UI layer communicates with the Request layer (APIRequest, WebRequest, etc.) to fetch data, which is then passed to the respective modules (Feed, Live, Video, Personal).
• Video and Live modules incorporate the Player module components to facilitate smooth video playback and manage interactive plugins. The Video module even showcases an abstraction with plugins to add, for example, masking, playback control, or additional information.
• The DLNA module represents an external service integration for casting, interacting with the native player to allow cloud streaming functionalities.
Architectural Patterns and Design Principles
• Modularity: The project separates concerns by isolating features (Feed, Player, Live, etc.) into dedicated directories and modules.
• Plugin Architecture: The Player and Video components use a plugin system to allow flexible extensions (e.g., Danmu, SpeedChanger, SponsorSkip plugins).
• Layered Architecture: There is a clear separation between the UI (presentation), business logic and request/network layer, and supporting utility extensions.
• Use of MVC/MVVM: Given the presence of View Controllers and ViewModels (e.g., NewVideoPlayerViewModel, LivePlayerViewModel), the design likely follows MVC or a variant with MVVM patterns.
Final Recommendations
• Begin at the highest level (entire tvOS app) and then break it down to show each module’s internal components.
• Modular and extensible nature (especially in the Player and Video sections) to communicate flexibility and separation of responsibilities.