# Media Player

{% hint style="info" %}
You'll need to import the javascript file in your website before starting from this [link](/javascript-apis/getting-started.md).
{% endhint %}

Functions required to have a media player like notification and control it in Android and iOS devices.

### Start Media

To start the media with controls call the function.

{% tabs %}
{% tab title="Plain JS" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>window.WTN.MediaPlayer.playMedia({
</strong>    url:"Your Media URL",
    imageUrl:"Custom Image that should be shown in the notifcation"
})
</code></pre>

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { playMedia } from "webtonative/MediaPlayer";

playMedia({
    url:"Your Media URL",
    imageUrl:"Custom Image that should be shown in the notifcation"
})
```

{% endtab %}
{% endtabs %}

image (optional) : It's an optional parameter to show the image in notification else default image will be shown.

### Pause Media

{% tabs %}
{% tab title="Plain JS" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>window.WTN.MediaPlayer.pauseMedia();
</strong></code></pre>

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { pauseMedia } from "webtonative/MediaPlayer";

pauseMedia();
```

{% endtab %}
{% endtabs %}

### Stop Media

{% tabs %}
{% tab title="Plain JS" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>window.WTN.MediaPlayer.stopMedia();
</strong></code></pre>

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { stopMedia } from "webtonative/MediaPlayer";

stopMedia();
```

{% endtab %}
{% endtabs %}

\*Feature for Android was taken live on 26/09/2023\
\*Feature for iOS was taken live on 18/06/2025


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.webtonative.com/javascript-apis/media-player-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
