> For the complete documentation index, see [llms.txt](https://docs.gmetri.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gmetri.com/metaverse/sdk/gmetri-player.md).

# GMetri Player

The GMetri Player is a **full-fledged Metaverse application** that can run experiences created using the GMetri editor.

The latest javascript file is hosted [here](https://s.vrgmetri.com/gm-gb-test/gmetri-player/local/web/player.bundle.js). **We recommend you to not self-host this file to receive latest updates from us.**

There are 2 simple steps to get GMetri Player running on your website.

* Drop the below script in the `<head>` section of your web-page

```html
<script type="application/javascript" 
src="https://s.vrgmetri.com/gm-gb-test/gmetri-player/local/web/player.bundle.js">
</script>
```

* Initialize the Player API by passing the JSON and options

```typescript
// usage 
const player = gmetri.player.load({
  json: {}, 
  options: { 
    htmlAnchor: document.body, 
    onSceneChange: () => {}, 
    onRuleTriggered: () => {}, 
    onViewerStateChange: () => {}, 
  } 
}).play();
```

### Player Options

```typescript
type PlayerOptions = { 
  htmlAnchor?: HTMLElement,
  onSceneChange?: () => Promise<void>,
  onRuleTriggered?: () => Promise<void>,
  onViewerStateChange?: () => Promise<void>,
};
```

1. **htmlAnchor** - Reference to the HTML element you want the player to attach to
2. **onSceneChange** - Optional callback, fired whenever a scene is changed inside the experience
3. **onRuleTriggered** - Optional callback, fired whenever a rule is triggered
4. **onViewerStateChange** - Optional callback, fired whenever the [variables](/metaverse/build/variables.md)' state changes.&#x20;

### Project JSON

The Player API accepts a [recursive tree structure](https://github.com/gmetrixr/rjson) - codenamed ***rJson***.

This JSON structure can be easily created using our [open source library](https://github.com/gmetrixr/rjson) on GitHub. Feel free to fork it!

To get started on understanding JSON structure, look at the sample jsons added in the github repo [here](https://github.com/gmetrixr/rjson/blob/main/test/r/jsons). rJson library also exports all the helper functions that you can use to create rJson structures. Have a look at the usage [here](https://github.com/gmetrixr/rjson/blob/main/test/r/1.factory.spec.ts)

There's also a codesandbox that showcases the absolute power of creating **Metaverse Apps** using the GMetri Plugin API

{% embed url="<https://r27u8.csb.app/>" %}
Codesandbox for GMetri SDK
{% endembed %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gmetri.com/metaverse/sdk/gmetri-player.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
