# waleedtalha/videoplayer architecture

> Architecture diagram of the GitHub repository waleedtalha/videoplayer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/waleedtalha/videoplayer
- Repository: https://github.com/waleedtalha/videoplayer

## Overview

##### Project Type and Purpose
- This is a native Android mobile application (“VideoPlayer”) that leverages Google’s ExoPlayer library to provide advanced full-HD video playback features.
- There is no separate backend service; all playback, data management, and UI run on the device.

##### File Structure
- Top-level “app” module contains:
– src/main/java/com/example/videoplayer/activities – UI screens (Splash, Main, Video Files, Video Player, Permissions)
– src/main/java/com/example/videoplayer/models – Data models (MediaFiles), utility classes (Utility, OnSwipeTouchListener), and dialogs (BrightnessDialog, PlaylistDialog, VolumeDialog)
- Build artifacts: build.gradle, proguard rules, AndroidManifest.xml
- Tests in src/test and src/androidTest

##### README Insights
- Confirms use of ExoPlayer, supported formats, key features (zoom, PiP, equalizer, gestures)
- No external servers—media is loaded from device storage via Android’s MediaStore APIs

##### Main Components
a. UI Layer (blue):
– Activities: SplashScreenActivity, AllowAccessActivity, MainActivity, VideoFilesActivity, VideoPlayerActivity
– RecyclerView Adapters: VideoFoldersAdapter, VideoFilesAdapter, PlaybackIconsAdapter
– Dialog Components: BrightnessDialog, VolumeDialog, PlaylistDialog
– Layout XMLs & Menus (as static assets)
b. Domain / Business Layer (green):
– Models: MediaFiles, IconModel
– Utility & Gesture Handling: Utility class, OnSwipeTouchListener
c. Playback Engine (orange):
– ExoPlayer Core & Custom Renderers
– Custom view binding: exo_layout_view.xml, custom_playback_view.xml
d. Data & Storage (purple):
– Android MediaStore / File System
– Local device storage (SD card/internal)
e. External & OS Services (gray):
– Android OS: Activity Manager, Permission Manager, Picture-in-Picture API, Audio Focus API, Sensor Manager (for brightness/volume gestures)
– System Notifications (optional)

##### Component Relationships & Data Flow
2. SplashScreen checks permissions → AllowAccessActivity (if needed) → MediaStore query (via Utility) → returns list of MediaFiles
3. VideoFilesActivity displays folders/video items (via VideoFoldersAdapter & VideoFilesAdapter)
4. User selects a video → MainActivity or VideoPlayerActivity
5. VideoPlayerActivity initializes ExoPlayer instance → loads MediaFiles.uri → render video in custom_playback_view
6. UI gestures (swipe) trigger OnSwipeTouchListener → Utility adjusts brightness/volume via Sensor Manager & Audio Manager
7. Playback controls (play/pause/seek/next/prev) drive ExoPlayer API
8. Equalizer & speed controls → ExoPlayer TrackSelection & AudioProcessor modules
9. Picture-in-Picture mode invokes Android PiP APIs

##### Architectural Patterns & Design Principles
- Separation of Concerns – distinct UI, domain, and data/engine layers
- Adapter pattern – RecyclerView Adapters for list presentation
- Builder/Factory – ExoPlayer instantiation and track selector configuration
- Observer – ExoPlayer EventListener for playback state updates

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        SplashScreen["SplashScreenActivity"]:::ui
        AllowAccess["AllowAccessActivity"]:::ui
        MainAct["MainActivity"]:::ui
        VideoFilesAct["VideoFilesActivity"]:::ui
        VideoPlayerAct["VideoPlayerActivity"]:::ui
        subgraph "Adapters"
            direction TB
            FoldersAdapter["VideoFoldersAdapter"]:::ui
            FilesAdapter["VideoFilesAdapter"]:::ui
            IconsAdapter["PlaybackIconsAdapter"]:::ui
        end
        subgraph "Dialogs"
            direction TB
            BrightnessDlg["BrightnessDialog"]:::ui
            VolumeDlg["VolumeDialog"]:::ui
            PlaylistDlg["PlaylistDialog"]:::ui
        end
        subgraph "Layouts & Menus"
            direction TB
            Layouts["Layout XMLs & Menus"]:::ui
        end
    end

    %% Domain Layer
    subgraph "Domain / Business Layer"
        direction TB
        MediaFilesModel["MediaFiles"]:::domain
        IconModel["IconModel"]:::domain
        UtilityClass["Utility"]:::domain
        SwipeListener["OnSwipeTouchListener"]:::domain
    end

    %% Playback Engine
    subgraph "Playback Engine"
        direction TB
        ExoCore["ExoPlayer Core"]:::engine
        CustomRender["Custom Renderers"]:::engine
        exoLayout["exo_layout_view.xml"]:::engine
        customView["custom_playback_view.xml"]:::engine
    end

    %% Data & Storage
    subgraph "Data & Storage"
        direction TB
        MediaStore["Android MediaStore"]:::data
        FileSystem["Local File System"]:::data
    end

    %% External & OS Services
    subgraph "External & OS Services"
        direction TB
        ActivityMgr["Activity Manager"]:::os
        PermissionMgr["Permission Manager"]:::os
        PiPAPI["Picture-in-Picture API"]:::os
        AudioFocus["Audio Focus API"]:::os
        SensorMgr["Sensor Manager"]:::os
    end

    %% Data Flow & Relationships
    SplashScreen -->|"launches"| ActivityMgr
    SplashScreen -->|"checkPermissions()"| PermissionMgr
    SplashScreen --> AllowAccess
    AllowAccess -->|"MediaStore.query()"| UtilityClass
    UtilityClass --> MediaStore
    UtilityClass --> FileSystem
    UtilityClass --> MediaFilesModel
    AllowAccess --> VideoFilesAct
    VideoFilesAct --> FoldersAdapter
    VideoFilesAct --> FilesAdapter
    FoldersAdapter --> folder_item["folder_item.xml"]:::ui
    FilesAdapter --> video_item["video_item.xml"]:::ui
    VideoFilesAct --> VideoPlayerAct
    VideoPlayerAct --> ExoCore
    ExoCore --> CustomRender
    ExoCore -->|"player.prepare()"| exoLayout
    ExoCore -->|"player.prepare()"| customView
    VideoPlayerAct --> SwipeListener
    SwipeListener --> SensorMgr
    SwipeListener --> AudioFocus
    VideoPlayerAct --> BrightnessDlg
    VideoPlayerAct --> VolumeDlg
    VideoPlayerAct --> PlaylistDlg
    VideoPlayerAct --> PiPAPI
    ExoCore -->|"setTrackSelection() / setAudioProcessor()"| AudioFocus

    %% Click Events
    click SplashScreen "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/activities/SplashScreenActivity.java"
    click AllowAccess "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/activities/AllowAccessActivity.java"
    click MainAct "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/activities/MainActivity.java"
    click VideoFilesAct "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/activities/VideoFilesActivity.java"
    click VideoPlayerAct "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/activities/VideoPlayerActivity.java"
    click FoldersAdapter "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/adapters/VideoFoldersAdapter.java"
    click FilesAdapter "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/adapters/VideoFilesAdapter.java"
    click IconsAdapter "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/adapters/PlaybackIconsAdapter.java"
    click BrightnessDlg "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/BrightnessDialog.java"
    click VolumeDlg "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/VolumeDialog.java"
    click PlaylistDlg "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/PlaylistDialog.java"
    click MediaFilesModel "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/MediaFiles.java"
    click IconModel "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/IconModel.java"
    click UtilityClass "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/Utility.java"
    click SwipeListener "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/java/com/example/videoplayer/models/OnSwipeTouchListener.java"
    click Layouts "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/res/layout/activity_splash_screen.xml"
    click exoLayout "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/res/layout/exo_layout_view.xml"
    click customView "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/res/layout/custom_playback_view.xml"
    click folder_item "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/res/layout/folder_item.xml"
    click video_item "https://github.com/waleedtalha/videoplayer/blob/master/app/src/main/res/layout/video_item.xml"

    %% Styles
    classDef ui fill:#aecbfa,stroke:#0665d0,stroke-width:1px
    classDef domain fill:#b3e6b3,stroke:#2d862d,stroke-width:1px
    classDef engine fill:#ffd1a9,stroke:#d97300,stroke-width:1px
    classDef data fill:#d1b3ff,stroke:#5e2ca5,stroke-width:1px
    classDef os fill:#e0e0e0,stroke:#707070,stroke-width:1px
```
