跪拜 Guibai
← All articles
JavaScript

A Scriptable Script Turns a Local Music Folder into an Offline iPhone Player

By Vic_wkx ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The script shows how far a few Scriptable APIs can go in replacing a bloated music app with a folder and a preview player. It also hits the hard ceiling of iOS: QuickLook offers no background audio, no lock-screen controls, and no gapless playback, so this is a quick-access tool rather than a full player.

Summary

Music apps have become a maze of subscriptions, licensing splits, and pop-ups. The author's answer is a one-file Scriptable script that treats a local folder as a library: it reads a folder bookmarked as Music, filters audio file extensions (mp3, m4a, flac, wav, aac), sorts them, and displays them in a native UITable. Tapping a row closes the table and invokes QuickLook to play the file through the system player, with a while(true) loop to return to the list after playback finishes.

The script also handles a home-screen widget path. When config.runsInWidget is true, it draws a centered progress ring and sets a URL that opens the script when tapped. The widget gives one-tap access to the playlist, which is the author's core ask: quick startup and immediate access to offline songs.

The author had previously written an Android version but switched to iPhone, where native app signing is a pain, so Scriptable becomes the test bed. The result is deliberately minimal, lacking lyrics, shuffle, search, and playlist categories. The author calls it crude and plans to iterate.

Takeaways
— Use FileManager.local and a File Bookmark named Music to access a music folder without asking for full photo/library permissions.
— Filter audio files with a regex matching mp3, m4a, flac, wav, and aac, then sort them alphabetically.
— config.runsInWidget lets the same script render a home-screen widget that opens the script via URLScheme.forRunningScript().
— Because iOS bars a player from overlapping an open table, record the selected row in a variable, close the list, then call QuickLook.present.
— The while(true) loop sends the user back to the song list after the player closes; tapping the list's close button with no selection exits the script.
Conclusions

The author's pain list (subscription fatigue, split licensing, ads, and convoluted flows) mirrors what drives many users to pirate or to local storage; a 30-line script that lets you browse a folder is a real alternative.

Scriptable's widget and UITable are powerful enough to build a usable 'app' without Xcode, yet the script remains a hack: no background audio, no playback state, and no metadata beyond filenames. The gap between 'works' and 'a real player' is exactly why the author is still on the fence.

Concepts & terms
Scriptable
An iOS app that runs JavaScript scripts and exposes native iOS APIs for widgets, file access, UI tables, and more. It lets developers build lightweight tools without a full Xcode project.
File Bookmark
A permission token in Scriptable that grants a script access to a specific folder. The user picks the folder once, names it, and the script can read its contents later without re-prompting.
QuickLook
A system-level preview/player on iOS that can display files or play media. In Scriptable it can present a file path, but it doesn't provide background playback or lock-screen controls.
UITable
A native table view available in Scriptable for building list-based interfaces. Rows can be selected and can trigger callbacks, but the table must close before presenting another view on iOS.
From the discussion
Featured comments
Mervyn_Lee

Try Salt Player.

Vic_wkx

Thanks. I gave Salt Player a try, and the experience is genuinely nice. The UI is clean, and the home screen shows a list that plays directly. It's the effect I wanted to achieve. The only thing it lacks is the letter index bar. The alphabetical index bar on the right side of QQ Music is genuinely handy; once you've used it, you can't go back. When I want to find a song, tapping the search box at the top and typing is a bit of a hassle, and scrolling down through the list takes too long. With a letter index bar, one-hand swiping gets you to the song quickly. So satisfying. There are also two minor flaws: first, "Locate Current Song" is buried in the collapsible menu; I think this feature could be pinned as a floating button. Second, I don't think the "Stats" tab needs to be fixed in the tab bar; it could just be hidden.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗