Created
March 23, 2026 19:23
-
-
Save yetimdasturchi/d4050ae2c3f5688272554695c354e4df to your computer and use it in GitHub Desktop.
Stream any URL to VLC on Android TV over ADB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DEVICE_IP="${ADB_DEVICE:-}" | |
| VLC_ACTIVITY="org.videolan.vlc/org.videolan.vlc.StartActivity" | |
| usage() { | |
| echo "Usage: $(basename "$0") [OPTIONS] <url>" | |
| echo "" | |
| echo "Options:" | |
| echo " -d, --device <ip:port> Target device (or set ADB_DEVICE env)" | |
| echo " -h, --help Show this help" | |
| echo "" | |
| echo "Examples:" | |
| echo " $(basename "$0") https://example.com/video.mp4" | |
| echo " $(basename "$0") -d 192.168.1.100:5555 https://example.com/video.mp4" | |
| echo "" | |
| echo "Env:" | |
| echo " ADB_DEVICE Set default device IP:port" | |
| } | |
| connect_device() { | |
| echo "Connecting to $DEVICE_IP..." | |
| local out | |
| out=$(adb connect "$DEVICE_IP" 2>&1) | |
| if echo "$out" | grep -qE "connected|already connected"; then | |
| echo "$out" | |
| else | |
| echo "Failed to connect: $out" | |
| exit 1 | |
| fi | |
| } | |
| play_url() { | |
| local url="$1" | |
| echo "Opening in VLC: $url" | |
| adb -s "$DEVICE_IP" shell am start \ | |
| -a android.intent.action.VIEW \ | |
| -d "$url" \ | |
| -n "$VLC_ACTIVITY" \ | |
| > /dev/null 2>&1 && echo "Done" || { echo "Failed to launch VLC"; exit 1; } | |
| } | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| -d|--device) DEVICE_IP="$2"; shift 2 ;; | |
| -h|--help) usage; exit 0 ;; | |
| http*|rtsp*|rtmp*|ftp*) URL="$1"; shift ;; | |
| *) echo "Unknown argument: $1"; usage; exit 1 ;; | |
| esac | |
| done | |
| if [[ -z "$DEVICE_IP" ]]; then | |
| echo "Device IP not set. Use -d <ip:port> or export ADB_DEVICE=<ip:port>" | |
| exit 1 | |
| fi | |
| if [[ -z "$URL" ]]; then | |
| usage | |
| exit 1 | |
| fi | |
| connect_device | |
| play_url "$URL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment