ytify-native is an ultra-lightweight, high-performance native Android application for ytify with an embedded, on-device YouTube InnerTube extraction engine and low-latency chunk-streaming proxy.
It achieves instant, background audio/video playback and lockscreen media session control with a minimal ~131 KB APK footprint β containing zero third-party scrapers, zero remote bucket/worker dependencies, and zero telemetry.
- πͺΆ Tiny Footprint (~131 KB APK): Built strictly with native Android components, R8 bytecode optimization, and an embedded micro-HTTP server. No bulky frameworks or heavy scraping libraries.
- π‘οΈ 100% Local InnerTube Extraction: Extracts direct, unciphered YouTube audio (
itag 140,itag 251,itag 249) and video streams (itag 18,itag 313,itag 137, etc.) directly on device via InnerTube clients (ANDROID_VR,VISIONOS,TVHTML5). - π Smart Chunk-Streaming Proxy (
MultiChunkInputStream): Bridges YouTube Google Video CDN range limitations (handling 256 KB bounded chunks) seamlessly to provide continuous playback withoutHTTP 403 Forbiddeninterruptions. - π Chromium Private Network Access (PNA) Support: Fully compliant with modern Chromium Private Network Access policies (
Access-Control-Allow-Private-Network: true), allowing seamless communication between public origins (ytify.pp.ua) and loopback (127.0.0.1:9999). - π€ Dynamic
visitorDataBootstrapping: Automates YouTube visitor session context acquisition to prevent bot challenges and ensure stream playability. - π§ Native Android Background & Lockscreen Playback: Bridges web audio events directly into Android's native
MediaSessionCompatand foreground notification service with dynamic artwork, scrubber sync, and hardware/Bluetooth controls. - π€ Minimalist Monochrome Onboarding: First-run tutorial explaining app architecture and operation in a clean, high-contrast, theme-adaptive interface.
- πΌοΈ Picture-in-Picture (PiP): Native picture-in-picture window support for videos.
- π Privacy First: All extraction and stream proxying happen strictly within the local device loopback. No middleman servers or user data logging.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Android Application Process β
β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ β
β β VeltrixWebview β β Local HTTP Server β β
β β (https://ytify.pp.ua) β β (127.0.0.1:9999) β β
β βββββββββββββββ¬ββββββββββββββ βββββββββββββββ¬ββββββββββββββ β
β β β β
β Fetch Interceptor NanoHTTPD & β
β (Traps /api/v1/videos/{id}) MultiChunkProxy β
β β β β
β βΌ βΌ β
β Routes to 127.0.0.1:9999 βββββββββββββββββββββββββββββ β
β β β PlaybackResolver β β
β β β (Multi-Client InnerTube)β β
β β βββββββββββββββ¬ββββββββββββββ β
β β β β
β β βΌ β
β β Pure YouTube InnerTube β
β β Endpoint Query β
β β β β
β βΌ βΌ β
β Stream URLs: 127.0.0.1:9999/proxy βββββββββ Unciphered Stream Formats β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Native Android MediaSession & ForegroundService β β
β β (Lockscreen Controls, Notification Player, Track Seeking) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- WebView Injection: On page start,
MainActivityinjectsJS_STREAM_INTERCEPTORinto the WebView context. - Media Interception: When ytify attempts to resolve tracks via
/api/v1/videos/{id}or/s/{id}, the fetch interceptor redirects the query tohttp://127.0.0.1:9999/api/v1/videos/{id}. - InnerTube Resolution:
PlaybackResolverqueries YouTube'syoutubei/v1/playerendpoint using unciphered client payloads (ANDROID_VR1.65.10,VISIONOS,TVHTML5) combined with dynamicvisitorDataacquired fromyoutubei/v1/visitor_id. - Stream Proxying: Format URLs are returned as
http://127.0.0.1:9999/proxy?itag={itag}&url={encoded_googlevideo_url}. - Bounded Chunk Delivery: When the HTML5 audio/video element requests media,
HttpServerusesMultiChunkInputStreamto request bounded chunks (<= 256 KB) from Google Video CDN, preventingHTTP 403 Forbiddenrange errors and assembling a smooth, continuous byte stream. - Native Media Session Bridge:
JS_MEDIA_SCRIPTlistens tonavigator.mediaSessionupdates and<audio>lifecycle events, bridging track title, artist, duration, position, and artwork into Android's nativeForegroundServiceandMediaSessionCompat.
.
βββ app/
β βββ build.gradle # Android build configuration & dependencies
β βββ proguard-rules.pro # Proguard optimization rules
β βββ src/main/
β βββ AndroidManifest.xml # Permissions, Service & Activity declarations
β βββ java/com/shashwat/ytify/
β β βββ MainActivity.java # Core Activity, WebView setup & JS interfaces
β β βββ HttpServer.java # NanoHTTPD proxy & MultiChunk streaming engine
β β βββ PlaybackResolver.java # Pure InnerTube client resolution pipeline
β β βββ InnerTube.java # Direct InnerTube connection primitives
β β βββ ForegroundService.java # Android media notification & background service
β β βββ VeltrixWebview.java # Custom WebView preserving background state
β β βββ WebAppInterface.java # Javascript-to-Java interface bridge
β β βββ CustomWebClient.java # Fullscreen and video chrome handler
β β βββ ...
β βββ res/ # Layouts, icons, and theme definitions
βββ gradle/wrapper/ # Gradle wrapper binaries & configuration
βββ README.md # Project documentation
βββ build.gradle # Top-level Gradle configuration
βββ settings.gradle # Project settings & module inclusions
- Android SDK (API Level 33+)
- JDK 11 or JDK 17
- Git
git clone https://github.com/Anattana-Labs/Ytify-native.git
cd Ytify-native# Build release APK
./gradlew assembleReleaseThe compiled APK will be generated at:
app/build/outputs/apk/release/app-release.apk
# Build debug APK
./gradlew assembleDebugOutput:
app/build/outputs/apk/debug/app-debug.apk
Connect your Android device with USB Debugging enabled, then run:
# Verify device connection
adb devices
# Install the APK
adb install -r app/build/outputs/apk/release/app-release.apk
# Launch the app
adb shell am start -n com.shashwat.ytifynative/com.shashwat.ytify.MainActivityTo inspect or interact directly with the embedded HTTP server running on your phone from your development computer:
# Forward port 9999 from device to local machine
adb forward tcp:9999 tcp:9999
# Test server health
curl -i http://127.0.0.1:9999/
# Test stream extraction for any YouTube video ID
curl -s http://127.0.0.1:9999/api/v1/videos/xvT1jH8B9AM | jq .# Filter app-specific tags
adb logcat -s YtifyHttpServer PlaybackResolver MainActivity| Permission | Purpose |
|---|---|
INTERNET |
Loading the ytify web interface and fetching YouTube stream chunks |
FOREGROUND_SERVICE |
Keeping audio playback active when the screen is turned off or app is minimized |
FOREGROUND_SERVICE_MEDIA_PLAYBACK |
Android 14+ media playback foreground service compliance |
POST_NOTIFICATIONS |
Android 13+ permission for lockscreen & notification media playback controls |
MODIFY_AUDIO_SETTINGS |
Audio focus management and volume adjustments |
WAKE_LOCK |
Preventing CPU sleep during active audio playback |
Contributions, bug reports, and pull requests are welcome!
- Fork the repository: https://github.com/Anattana-Labs/Ytify-native
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.