### Syntax
```js
// Get information about the currently-loaded video Representation
const videoRepresentation = player.getVideoRepresentation();
// Get information about the loaded video Representation for a specific Period
const videoRepresentation = player.getVideoRepresentation(periodId);
```
### Parameters
#### Arguments
- `periodId` (`string|undefined`): The `id` of the Period for which you want to get
information about its currently loaded video Representation. If not defined, the
information associated to the currently-playing Period will be returned.
### Return Value
`Object|null|undefined`
```
--------------------------------
### Initialize and Use TextTrackRenderer with SRT
Source: https://github.com/canalplus/rx-player/blob/dev/doc/api/Tools/TextTrackRenderer.md
This example demonstrates a complete usage scenario, including importing necessary parsers, initializing the TextTrackRenderer with video and text track elements, and setting a subtitle track. Ensure the video and text track elements exist in your HTML.
```javascript
// import TextTrackRenderer and the parsers we want
import TextTrackRenderer, {
TTML_PARSER,
VTT_PARSER,
SRT_PARSER,
SAMI_PARSER,
} from "rx-player/tools/TextTrackRenderer";
// Add the needed parsers to the TextTrackRenderer
TextTrackRenderer.addParsers([TTML_PARSER, VTT_PARSER, SRT_PARSER, SAMI_PARSER]);
// get video element the subtitles has to be synchronized to
const videoElement = document.querySelector("video");
// get HTML element in which the text track will be displayed
// Should generally be on top of the video, with the same size than it (but can
// also be in any shape, corresponding to your UI needs).
const textTrackElement = document.querySelector(".text-track-container");
const textTrackRenderer = new TextTrackRenderer({
videoElement,
textTrackElement,
});
// example: a ".srt" track
const exampleSRT = `1
00:00:01,600 --> 00:00:04,200
English (US)
2
00:00:05,900 --> 00:00:07,999
This is a subtitle in American English
3
00:00:10,000 --> 00:00:14,000
Adding subtitles is very easy to do
`;
try {
textTrackRenderer.setTextTrack({
data: exampleSRT,
type: "srt", // or "ttml" / "vtt" / "sami"
// timeOffset: 2.3, // optional offset in seconds to add to the subtitles
});
} catch (e) {
console.error(`Could not parse the subtitles: ${e}`);
}
```
--------------------------------
### Get Currently Loaded Audio Representation
Source: https://github.com/canalplus/rx-player/blob/dev/doc/api/Representation_Selection/getAudioRepresentation.md
Call this method without arguments to get information about the audio Representation currently loaded for the active Period. Ensure the player instance is available.
```javascript
const audioRepresentation = player.getAudioRepresentation();
```
--------------------------------
### Example loadSegment Callback
Source: https://github.com/canalplus/rx-player/blob/dev/doc/api/Miscellaneous/Local_Manifest_v0.1.md
Demonstrates the implementation of the `loadSegment` callback for fetching media segments. It handles segment retrieval, resolution, and error rejection, with a note on abort functionality.
```javascript
async function loadSegment(segment, callbacks) {
try {
const segmentData = await getStoredSegment(segment);
callbacks.resolve(segmentData);
} catch (e) {
callbacks.reject(e);
}
// Note: in this example, there is no mean to abort the operation, as a result
// we do not return a function here
// // Here is how it would look like if we could:
// return function abort() {
// abortStoredSegmentRequest();
// }
}
```