---
title: Integration
hide_meta: true
---

## Easy Method

The easiest way to ensure the functionality of a self-developed jukebox with VinURL is to extend the standard jukebox.
```java
public class CustomJukeBox extends JukeboxBlock{
     public CustomJukeBox(Settings settings) {
        super(settings);
    }
    // Your own Logic...
}
```

## Advanced Method

This method should only be used if a separate entity class has been created for your use case, and therefore you implemented separate functions for starting and stopping jukebox sounds.

### Setup

Add the following repository to your `../../build.gradle`.

```groovy title="build.gradle"
repositories {
    maven { url 'https://api.modrinth.com/maven' }
}
```

Then the following dependency must be added in the `../../build.gradle` to reference VinURL specific code. The version of VinURL needs to be declared in the `../../gradle.properties`.

<Callout variant="warning">
    Only VinURL 2.2.0+ supports this method. Previous versions may work when used correctly,
    but only the newest api endpoints are shown here.
</Callout>


```groovy title="build.gradle"
dependencies {
    modCompileOnly "maven.modrinth:vinurl:${project.vinurl_version}"
}
```

```.properties title="gradle.properties"
vinurl_version=...
```

### Implementation

First declare a static variable to determine if VinURL is loaded

```java
public static boolean isVinURLLoaded = FabricLoader.getInstance().isModLoaded("vinurl");
```

Import the VinURL API, which contains methods for playing and stopping custom sounds.

```java
import com.vinurl.api.VinURLSound;
```

<Callout variant="warning">
    The API is designed to be used from the server-side only
</Callout>

#### Positional Sounds

This method starts a positional custom sound for all players in a 64 block range from the specified *blockPos*.

```java
public void startPlaying(){
    // Your own Logic...
    if (isVinURLLoaded) {
        VinURLSound.playAt(serverLevel, itemStack, blockPos);
    }
}
```

This method stops a positional custom sound at the specified *blockPos* for all players.
If a custom sound is still downloading when this function is called,
then the parameter *cancelable* is responsible for whether the active download is aborted or not.

```java
public void stopPlaying(){
    if (isVinURLLoaded) {
		VinURLSound.stopAt(serverLevel, itemStack, blockPos, cancelable);
	}
    // Your own Logic...
}
```

#### Entity-Bound Sounds / Moving Sounds

This method starts a movable custom sound for all players in a 64 block range from the specified *entity*.

```java
public void startPlaying(){
    // Your own Logic...
    if (isVinURLLoaded) {
        VinURLSound.playFor(serverLevel, itemStack, entity);
    }
}
```

This method stops a movable custom sound of the specified *entity* for all players.
If a custom sound is still downloading when this function is called,
then the parameter *cancelable* is responsible for whether the active download is aborted or not.

```java
public void stopPlaying(){
    if (isVinURLLoaded) {
		VinURLSound.stopFor(serverLevel, itemStack, entity, cancelable);
	}
    // Your own Logic...
}
```