{
  "info": {
    "_postman_id": "347467fd-f9e3-478b-8f06-18956f4cf65b",
    "name": "negavid-player",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "29367259"
  },
  "item": [
    {
      "name": "V2",
      "item": [],
      "description": "The **NEGAVID** **Player API** provides a set of methods, events, and properties that allow you to control playback and respond to changes in the player's state. With this API, you can:\n\n- Programmatically play, pause, or seek the media\n    \n- Listen to key events like `play`, `pause`, `ended`, and more\n    \n- Handle playback behavior dynamically based on the current position or custom logic\n    \n\nThis API is ideal for customizing user experience, tracking playback progress, or integrating with other parts of your application.\n\n# Detecting Player Load with\n\nThe `negavidOnPlayerReady` helper function allows you to detect when a specific video player instance is ready for interaction.\n\nEach video element has a unique _**data-video-key**_ assigned via its `video` tag, which is used to identify the player.\n\n##### ✅ Example\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n// Do something amazing\n});\n\n ```\n\n**VideoHashId**: A string that uniquely identifies the video player instance (from the video tag).\n\n- **player**: The player instance passed to the callback once it's fully loaded and ready.\n    \n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) { \nplayer.play();\n});\n\n ```\n\n# Player APIs: `Getters & Setters`\n\nNEGAVID Player exposes a set of properties that act as **getters** (to read player state) and **setters** (to update player behavior or appearance). These are ideal for dynamically controlling playback, customizing the UI, and reacting to user interaction.\n\n### ✅ Overview\n\n- **Getter**: Read a property from the player, like `player.volume` or `player.paused`\n    \n- **Setter**: Modify the player by assigning a value, like `player.volume = 0.2`\n    \n\n| Property | Getter | Setter | Description |\n| --- | --- | --- | --- |\n| `playing` | ✓ | \\- | Returns a boolean indicating if the current player is playing. |\n| `paused` | ✓ | \\- | Returns a boolean indicating if the current player is paused. |\n| `stopped` | ✓ | \\- | Returns a boolean indicating if the current player is stopped. |\n| `ended` | ✓ | \\- | Returns a boolean indicating if the current player has finished playback. |\n| `currentTime` | ✓ | ✓ | Gets or sets the currentTime for the player. The setter accepts a float in seconds. |\n| `seeking` | ✓ | \\- | Returns a boolean indicating if the current player is seeking. |\n| `duration` | ✓ | \\- | Returns the duration for the current media. |\n| `volume` | ✓ | ✓ | Gets or sets the volume for the player. The setter accepts a float between 0 and 1. |\n| `muted` | ✓ | ✓ | Gets or sets the muted state of the player. The setter accepts a boolean. |\n| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |\n| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |\n| `fullscreen.active` | ✓ | \\- | Returns a boolean indicating if the current player is in fullscreen mode. |\n| `fullscreen.enabled` | ✓ | \\- | Returns a boolean indicating if the current player has fullscreen enabled. |\n\n##### ✅ Example\n\n1. _**Set Volume**_\n    \n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  // Set volume to 80%\n  player.volume = 0.8;\n  console.log('Volume is:', player.volume);\n}); \n\n ```\n\n2\\. _**Get current time**_\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  // Jump to 60 seconds\n  player.currentTime = 60;\n  // Log current playback time\n  console.log('Current time:', player.currentTime);\n});\n\n ```\n\n3\\. _**Enable loop**_\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.loop = true;\n  console.log('Looping is', player.loop ? 'enabled' : 'disabled');\n});\n\n ```\n\n# API Methods\n\nThe NEGAVID player exposes various methods that allow you to control playback, toggle fullscreen, and manipulate the media programmatically.\n\n### ✅ Overview\n\n- These methods are **actions**, not properties — you call them like functions.\n    \n\n| Method | Parameters | Description |\n| --- | --- | --- |\n| `play()` | \\- | Start playback. |\n| `pause()` | \\- | Pause playback. |\n| `stop()` | \\- | Stop playback and reset to start. |\n| `restart()` | \\- | Restart playback. |\n| `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |\n| `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |\n| `fullscreen.enter()` | \\- | Enter fullscreen. If fullscreen is not supported, a fallback \"full window/viewport\" is used instead. |\n| `fullscreen.exit()` | \\- | Exit fullscreen. |\n| `fullscreen.toggle()` | \\- | Toggle fullscreen. |\n| `on(event, function)` | String, Function | Add an event listener for the specified event. |\n| `once(event, function)` | String, Function | Add an event listener for the specified event once. |\n| `off(event, function)` | String, Function | Remove an event listener for the specified event. |\n\n##### ✅ Example\n\n1. _**Play video**_\n    \n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.play().then(() => {\n    console.log('Playback started');\n  }).catch(error => {\n    console.error('Play failed:', error);\n  });\n});\n\n ```\n\n2\\. _**Restart from begining**_\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.restart();\n});\n\n ```\n\n3\\. _**Enter full screen mode**_\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.fullscreen.enter();\n});\n\n ```\n\n# Listening to Events\n\nYou can respond to player actions by attaching **event listeners** to the element where negavid player is initialized.\n\nEvents help you track things like playback state changes, loading, or when the player becomes ready.\n\n### ✅ Overview\n\n- Using the **`.on()`** **method** on the negavid player instance\n    \n- Using the native `addEventListener()` on the DOM element\n    \n\n| Event Type | Description |\n| --- | --- |\n| `playing` | Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting). |\n| `play` | Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior `pause` event. |\n| `pause` | Sent when playback is paused. |\n| `timeupdate` | The time indicated by the element's `currentTime` attribute has changed. |\n| `seeked` | Sent when a seek operation completes. |\n| `ended` | Sent when playback completes. _Note:_ This does not fire if `autoplay` is true. |\n| `enterfullscreen` | Sent when the player enters fullscreen mode (either the proper fullscreen or full-window fallback for older browsers). |\n| `exitfullscreen` | Sent when the player exits fullscreen mode. |\n| `ready` | Triggered when the instance is ready for API calls. |\n\n##### ✅ Example\n\n1. When Playback Starts\n    \n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.on('play', function() {\n    console.log('Playback started');\n  });\n});\n\n ```\n\n2\\. When Playback Ends\n\n``` javascript\nwindow.negavidOnPlayerReady('NEGAVID_VIDEO_KEY', function(player) {\n  player.on('ended', function() {\n    console.log('Playback finished');\n  });\n});\n\n ```\n\n**Note :**\n\nIf you're using native `addEventListener`:\n\n``` javascript\nconst videoElement = document.querySelector('[data-hash-id=\"NEGAVID_VIDEO_KEY\"]');\nvideoElement.addEventListener('play', function(event) {\n  console.log('Play event from native listener:');\n});\n\n ```\n\n# Player Shortcuts\n\nNegavid player includes built-in **keyboard shortcuts** to improve accessibility and user experience during playback. These shortcuts work when the player is focused or hovered, allowing users to control media without a mouse.\n\n| Key | Action |\n| --- | --- |\n| `0` to `9` | Seek from 0 to 90% respectively |\n| `space` | Toggle playback |\n| `K` | Toggle playback |\n| ← | Seek backward by the `seekTime` option |\n| → | Seek forward by the `seekTime` option |\n| ↑ | Increase volume |\n| ↓ | Decrease volume |\n| `M` | Toggle mute |\n| `F` | Toggle fullscreen |\n| `C` | Toggle captions |\n| `L` | Toggle loop |"
    }
  ]
}