# Installation

> Install one Sky DJ resource, add original MP3s, and choose Normal or optional On-demand delivery without an external music host.

## Requirements

<table>
<thead>
  <tr>
    <th>
      Requirement
    </th>
    
    <th>
      Purpose
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      FiveM server with OneSync enabled
    </td>
    
    <td>
      Shared club state, routing buckets and server-side position checks
    </td>
  </tr>
  
  <tr>
    <td>
      ESX, QBCore or Qbox selected in Sky Base
    </td>
    
    <td>
      Player access and framework integration
    </td>
  </tr>
  
  <tr>
    <td>
      FiveM’s built-in <code>
        yarn
      </code>
      
       resource
    </td>
    
    <td>
      Installs the supplied server dependencies before Sky DJ starts
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ox_lib
      </code>
    </td>
    
    <td>
      Callbacks and shared utilities
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sky_base
      </code>
      
       with a working database connection
    </td>
    
    <td>
      Framework bridge, interactions and automatic SQL persistence
    </td>
  </tr>
  
  <tr>
    <td>
      Optional <code>
        ox_target
      </code>
    </td>
    
    <td>
      Target interaction when selected in Sky Base
    </td>
  </tr>
</tbody>
</table>

Use the database provider already configured for Sky Base, such as `oxmysql` or `mysql-async`. Sky DJ includes its audio engine; a separate sound resource and `sky_jobs_base` are not required.

The customer package already contains the built frontend and server dependency metadata. FiveM supplies Node.js and the built-in Yarn resource installs the pinned dependencies automatically. Normal playback needs no encoder. Optional On-demand delivery needs the explicit process permission below and automatically prepares its server encoder. No separate host Node.js/Yarn installation, terminal command, Python, webserver, domain, certificate or music port is required.

<callout color="warning" icon="i-lucide-triangle-alert">

Test the complete resource on your development server before production use. The separate **On-demand MP3** option is disabled by default; Select and save the mode in the administration interface.

</callout>

## Install the resource

<steps level="3">

### Copy the complete resource

Extract the release package and copy the complete `sky_dj` resource into your server's resources directory. The standalone drag-and-drop package contains `resources/[sky]/sky_dj/`; a central resource ZIP may contain `sky_dj/` directly.

Keep the resource name **sky_dj** and retain its complete `config`, `source` and `stream` folders. Your installation must contain `fxmanifest.lua` directly inside `sky_dj`, without an extra nested `sky_dj` directory:

```text
resources/
└── [sky]/
    └── sky_dj/
        ├── fxmanifest.lua
        ├── config/
        │   └── music/
        ├── source/
        │   └── html/
        └── stream/
```

Keep package-root instructions beside your extracted package; they are not resources to start. There is one resource for both music modes and no separate Normal or On-demand package to install.

### Configure the database and start order

Start your database provider and the ESX, QBCore or Qbox framework selected in Sky Base before the Sky resources. The example below uses ESX; on Core servers retain your existing framework start line instead of adding `es_extended`. This example uses an existing `oxmysql` installation; retain your own database connection settings and provider:

```cfg [server.cfg]
set onesync on

ensure oxmysql
ensure es_extended
ensure ox_lib
ensure sky_base
ensure sky_dj
```

OneSync must be enabled before resource startup. See the official [FiveM resource commands](https://docs.fivem.net/docs/server-manual/server-commands/#resource-commands) and [OneSync setting](https://docs.fivem.net/docs/server-manual/server-commands/#onesync-onofflegacy).

Sky Base creates the `sky_dj_state` table and missing initial records automatically. The database account must be able to create or alter the resource's tables and read and write their data. No manual SQL import is required. Preserve existing records when updating; do not reset the table to change music delivery.

### Choose who owns the settings

The default `Config.IngameSettings = true` uses saved SQL settings. On first startup, shipped defaults seed missing settings; existing saved values take precedence. Open **/djadmin → Settings** as an authorized administrator and save global changes there. Other global entries in the customer's `config/config.lua` do not override SQL settings in this mode.

For file-owned global configuration, change the existing `IngameSettings` entry to `false`, edit `config/config.lua`, and restart `sky_dj`. Global settings writes are then disabled in-game while the saved SQL row is retained. Club layouts, placed devices and playlists remain in SQL in either mode.

Administrator access uses `CommandPermissions.djadmin` through Sky Base’s existing permission system (`god`, `superadmin`, `admin` on fresh installations), ACE `sky_dj.djadmin`, or the existing additional ACE `sky.dj.admin`. Existing saved groups are retained during updates. See [Configuration](/docs/scripts/sky-dj/setup/configuration) for permissions, language and configuration ownership.

### Add original MP3s

Put your own original MP3 files in **sky_dj/config/music/**, then restart `sky_dj`. Both delivery modes use this same folder. The customer package does not include a music library.

- Use at most **500 MP3 files** in the selected directory. Subfolders are not scanned.
- Files may be up to **50 MiB** each. Names may contain ASCII letters, numbers, spaces, underscores, hyphens and periods, must start with a letter, number, underscore or hyphen, and must end in lowercase `.mp3`. Maximum length is 160 characters; `..` is rejected.
- Keep paths and filename capitalization consistent, especially on Linux. Folder paths use forward slashes; symlinked folders are not supported.
- Upload audio through your server's file manager or SFTP. The in-game library manages playlists and settings; it does not upload files.
- Preserve original filenames when updating or moving music: playlist track IDs use those filenames.
- Restart the owning resource after adding, removing or replacing files so FiveM rebuilds the optional music pack and Sky DJ refreshes its catalogue.

Normal playback uses the original MP3 bytes without conversion. On-demand prepares smaller cached Opus files on the server while preserving those originals. Leave **Music folder** at `config/music` for the built-in setup.

### MP3 filename check

<callout color="warning" icon="i-lucide-file-audio">

MP3s with unsupported names are skipped even when `file_set 'sky_dj_music'` is present and the server has restarted. Parentheses such as `(Extended Mix)`, umlauts such as `ä`, and characters such as `&`, `#` or typographic quotes are not accepted. The extension must be lowercase `.mp3`, not `.MP3`.

</callout>

Use a simple name such as **Adrenalize - Epic Sax Song Original Mix.mp3**. Only ASCII letters, digits, spaces, `_`, `-` and `.` are allowed; start with a letter, digit, `_` or `-`, keep the complete filename within 160 characters and avoid `..`.

To check an empty library, rename one original MP3 to a supported name and restart its owning resource. Confirm that it appears before renaming the rest. Filenames are saved playlist references: if you rename a track already used by a playlist, update that playlist entry too. Do not delete the SQL table or add duplicate manifest lines to repair a filename mismatch.

### Create a playlist and test playback

Open **/djadmin → Settings → Music & Playlists**, create a playlist and add tracks. Assign that playlist to a club and save the club. At its DJ booth, load an assigned track into deck A or B and test playback.

For a new custom club, place its DJ booth and at least one speaker before saving. The festival is configured separately from your own clubs. Music synchronization is optional and starts disabled; ordinary playback does not require it.

For a radio station or live broadcast, follow [Livestreams and radio](/docs/scripts/sky-dj/features/livestreams-and-radio) instead of copying a web page URL into the MP3 library. The feature uses assigned direct HTTPS audio/HLS sources and starts disabled.

</steps>

## Choose music delivery

The **On-demand MP3** checkbox under **Settings → Music & Playlists → Library & Queues** selects delivery for the same original files:

<table>
<thead>
  <tr>
    <th>
      Checkbox
    </th>
    
    <th>
      Delivery
    </th>
    
    <th>
      When audio is received
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Off — Normal MP3 (default)
      </strong>
    </td>
    
    <td>
      FiveM mounts the complete optional <code>
        sky_dj_music
      </code>
      
       music pack into its native cache.
    </td>
    
    <td>
      The first local MP3 use, including playback or PFL, can request the complete library. The pack is not automatically requested during connection.
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        On — On-demand MP3
      </strong>
    </td>
    
    <td>
      Only currently needed songs transfer through FiveM's internal events. The optional music pack is not requested.
    </td>
    
    <td>
      An eligible listener near a playing club or a DJ loading a deck/PFL receives needed songs. Each prepared song finishes loading before playback.
    </td>
  </tr>
</tbody>
</table>

With SQL-owned settings, enable On-demand only after acknowledging its warning, then **save**. Sources on loaded decks and queues update live; switching modes does not require moving music, replacing the package or restarting the resource. Existing SQL settings, playlist filename IDs and club assignments are retained.

For file-owned settings, keep the following entries for the default Normal mode and restart `sky_dj`. To switch delivery in-game, use SQL-owned settings:

```lua [config/config.lua — existing Config entries]
IngameSettings = false,
MusicDirectory = 'config/music',
```

Normal MP3 is the shipped default. Existing saved choices are preserved. File-library changes still require a resource restart, even though an in-game mode change applies live.

### On-demand server preparation

Leave the on-demand option disabled unless you want this delivery mode. Before enabling it, add the following exact line to `server.cfg`, retain the resource name `sky_dj` and fully restart FXServer:

```cfg
add_unsafe_child_process_permission "sky_dj"
```

Keep the supplied `package.json` and `yarn.lock` beside `fxmanifest.lua`, and keep the built-in `yarn` resource available. On the first uncached on-demand song, Sky DJ installs the pinned FFmpeg binary automatically on the server, then prepares the original MP3 as cached stereo 96 kbps Opus. The server needs outbound HTTPS to the dependency registry and encoder release host. Normal playback never starts the encoder setup.

The first prepared song can take longer. Check the displayed preparation status and first server error if permission, download or conversion fails. No host terminal or separate Node/Yarn installation is required. Original MP3s are not modified; when conversion cannot make a song smaller, delivery retains the original. Installed dependencies, encoder files and prepared caches are server-local and must not be copied into a public release ZIP.

The server keeps prepared songs under `data/music-cache/`, with a 256 MiB / 64-entry cache and active outputs protected from eviction. Encoder installation and its notices stay under `data/ffmpeg/`. These paths are runtime data, not another music folder to select or client files to publish. The server cache can be reused after a restart; the separate per-player browser cache is temporary.

If the built-in Yarn installation was interrupted, stop `sky_dj` before checking its `node_modules` and `.yarn.installed` marker. When the marker remains but the dependencies are missing, remove only that marker inside this resource and start it again to rerun the builder. Do not copy installed modules or encoder binaries from another operating system. Hosts that deliberately provision dependencies themselves may use the optional commands in the supplied package; this is not required for the default automatic path.

The process permission follows the official [Cfx sandbox configuration](https://docs.fivem.net/docs/developers/sandbox/#unsafe-child-process-permission). It permits this resource's server encoder and installer; it is not needed for Normal playback. Do not grant broad filesystem permissions or expose an additional music port to solve an encoder error.

### Connection downloads and loading

The supplied manifest keeps library MP3s in the optional set:

```lua [fxmanifest.lua — supplied music declaration]
file_set 'sky_dj_music' {
    'config/music/*.mp3',
}
```

Keep this declaration. Do not also add library MP3s to ordinary client `files`, `client_script`, `shared_script` or streamed-asset folders; those locations can download independently of the music checkbox.

**No automatic full-library download during connection** does not mean that players never receive music. After joining, a player near an active club may immediately need its playing songs. In Normal mode, that first local music use can start the complete optional-pack download. In On-demand mode, only currently needed songs load, and the complete prepared song is received before decoding and playback. Spawning inside a playing club can therefore cause audio transfer soon after joining.

<callout color="warning" icon="i-lucide-triangle-alert">

Switching to On-demand cannot cancel a Normal optional-pack download that has already started or erase files already in FiveM's native cache. The new mode controls subsequent Sky DJ music requests.

</callout>

On-demand transfers retain listener authorization, routing-bucket checks, bandwidth budgets and a bounded transfer window. Cold tracks can take time to load; slow links, large files and many simultaneous listeners need testing on your server. This mode does not promise a fixed loading time.

### Existing custom music sources

The built-in optional-pack setup applies to **sky_dj/config/music/**. For restart-free switching between these two modes, keep that folder and the supplied manifest.

An advanced existing Normal source such as `@sky_dj_music/music` requires its owning resource to publish the MP3s through ordinary client `files` and to start before Sky DJ. Such music still downloads when players connect, independently of the Sky DJ checkbox. Sky DJ cannot mount another resource's optional file set on its behalf. Custom Normal folders inside `sky_dj` likewise need ordinary client publication. On-demand rejects a selected source whose MP3s are already client-published.

Absolute operating-system paths and symlinked folders are unsupported. See [Configuration](/docs/scripts/sky-dj/setup/configuration) before changing **Music folder**.

## Updating an existing installation

Back up `config/`, original music files and the `sky_dj_state` database table before updating. Replace the complete published runtime together so Lua, the built NUI and streamed assets match. Preserve your original MP3 names and SQL records.

The former external HTTPS/Opus delivery and its settings are retired. Generated Opus exports are not used; keep the original MP3s in `config/music/`. No converter, domain or external music host is needed. If updating the earlier private-folder experiment, move its original MP3s from `config/music-private/` back to `config/music/` and restart `sky_dj`. Do not replace saved settings or playlists with empty records.

An existing custom **Music folder** is retained during migration. If it points at an old export folder, open **Settings → Music & Playlists → Library & Queues**, set **Music folder** to `config/music`, and save. In file mode, update the existing `MusicDirectory` value instead and restart. Moving MP3s without updating that saved folder leaves the catalogue pointed at the old location.

## Final check

Test playback, seeking, A/B transitions and optional music synchronization with two FiveM clients. Verify that saved settings and club assignments survive a restart.

Use a fresh-cache client outside any playing club to check that joining does not automatically request the music library. Then test Normal's first-use complete-pack download separately from On-demand's needed-song transfer. Also join or walk into an active club and check that its current music loads and joins the correct playback position.

After a map update, fully exit and relaunch FiveM before checking streaming and collision.

Continue with [Overview](/docs/scripts/sky-dj/overview) and [Configuration](/docs/scripts/sky-dj/setup/configuration). For missing tracks, downloads, playback or access errors, use [Troubleshooting](/docs/scripts/sky-dj/reference/troubleshooting).
