# fbsamples/360-video-player-for-android architecture

> Architecture diagram of the GitHub repository fbsamples/360-video-player-for-android, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fbsamples/360-video-player-for-android
- Repository: https://github.com/fbsamples/360-video-player-for-android

## Overview

##### Project type and purpose
- This is a single-module Android application (“app”) whose purpose is to demonstrate playback of a 360° equirectangular video on a device. It uses standard Android framework components (Activity, TextureView, MediaPlayer) together with an OpenGL ES rendering pipeline (shaders and scene renderer) to map video frames onto a sphere.

##### File structure
- Top-level Gradle files (build.gradle, settings.gradle, gradlew, etc.) define the Android build and dependency system.
- The only code module is `app/`, containing:
- `AndroidManifest.xml` (declares the launch Activity)
- `java/com/oculus/sample/` – main code in packages:
– `SphericalPlayerActivity` (entry point, UI controller)
– `player/SphericalVideoPlayer` (wrapper around MediaPlayer to feed frames)
– `gles/` (EGLRenderTarget, GLHelpers, ShaderProgram, Sphere geometry, SphericalSceneRenderer)
- `res/raw/` (sample360.mp4 + GLSL shader source)
- Standard Android resource folders (layouts, mipmaps, values).

##### README for additional insights
- Confirms the app uses MediaPlayer + TextureView + OpenGL ES to render 360 video on a spherical mesh.
- Touch gestures map to yaw/pitch adjustments in the renderer.
- No network or external services—standalone playback.

##### Diagramming conventions
- Playback pipeline in another (e.g., green)
- Rendering pipeline in a third (e.g., orange)
- System/OS layer in gray

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        SPAct["SphericalPlayerActivity"]:::ui
        Touch["Touch Input"]:::ui
        TV["TextureView"]:::ui
    end

    %% Playback Pipeline
    subgraph "Playback Pipeline"
        SVP["SphericalVideoPlayer"]:::playback
        MP["MediaPlayer"]:::playback
    end

    %% Rendering Pipeline
    subgraph "Rendering Pipeline"
        SSR["SphericalSceneRenderer"]:::render
        Sphere["Sphere Mesh Geometry"]:::render
        SPP["ShaderProgram"]:::render
        GLH["GLHelpers"]:::render
        ERT["EGLRenderTarget"]:::render
    end

    %% Resources
    subgraph "Resources"
        Video[(sample360.mp4)]:::resource
        VS[(video_vertex_shader.glsl)]:::resource
        FS[(video_fragment_shader.glsl)]:::resource
    end

    %% OS / Hardware
    subgraph "OS / Hardware"
        Codec["MediaCodec"]:::system
        GPU["GPU"]:::system
    end

    %% Connections
    Touch -->|"touch events"| SPAct
    SPAct -->|"init(TextureView)"| TV
    SPAct -->|"start playback"| SVP
    SVP -->|"prepare(sample360.mp4)"| MP
    MP -->|"decode"| Codec
    MP -->|"output frames to SurfaceTexture"| TV
    SSR -->|"acquire texture from SurfaceTexture"| TV
    SSR -->|"render frame"| ERT
    ERT -->|"render to"| GPU
    GPU -->|"composite on screen"| TV
    Sphere -->|"geometry data"| SSR
    SPP -->|"apply shaders"| SSR
    VS -->|"vertex shader source"| SPP
    FS -->|"fragment shader source"| SPP
    SSR -->|"use helpers"| GLH

    %% Click Events
    click SPAct "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/SphericalPlayerActivity.java"
    click SVP "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/player/SphericalVideoPlayer.java"
    click SSR "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/gles/SphericalSceneRenderer.java"
    click Sphere "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/gles/Sphere.java"
    click SPP "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/gles/ShaderProgram.java"
    click GLH "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/gles/GLHelpers.java"
    click ERT "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/java/com/oculus/sample/gles/EGLRenderTarget.java"
    click Video "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/res/raw/sample360.mp4"
    click VS "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/res/raw/video_vertex_shader.glsl"
    click FS "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/res/raw/video_fragment_shader.glsl"
    click TV "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/res/layout/activity_main.xml"
    click SPAct "https://github.com/fbsamples/360-video-player-for-android/blob/master/app/src/main/AndroidManifest.xml"

    %% Styles
    classDef ui fill:lightblue,stroke:#555,stroke-width:1px
    classDef playback fill:lightgreen,stroke:#555,stroke-width:1px
    classDef render fill:lightcoral,stroke:#555,stroke-width:1px
    classDef resource fill:lightyellow,stroke:#555,stroke-width:1px
    classDef system fill:lightgray,stroke:#555,stroke-width:1px
```
