Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(playback_speed): playbackSpeed guide #587

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions demo/playbackRate_selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<title>PlaybackRate Selector</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div id="player-placeholder" style="width:560px; height:395px"></div>
<script type="text/javascript" src="https://qa-apache-php7.dev.kaltura.com/p/1091/embedPlaykitJs/uiconf_id/15225670"></script>
<script type="text/javascript">
try {
var kalturaPlayer = KalturaPlayer.setup({
"sources": {
"options": {}
},
"targetId": "player-placeholder",
"ui": {
"components": {}
},
"provider": {
"partnerId": 1091,
"uiConfId": 15225670
},
"playback": {
"playbackRates": [
0.25,
0.5,
0.75,
1,
1.25,
1.5,
1.75,
2,
4
],
"autoplay": true,
"allowMutedAutoPlay": true,
"playsinline": true,
"textLanguage": "default",
"options": {
"html5": {
"hls": {},
"dash": {}
}
},
"streamPriority": [{
"engine": "html5",
"format": "hls"
}, {
"engine": "html5",
"format": "dash"
}, {
"engine": "html5",
"format": "progressive"
}]
},
"plugins": {

},
"log": {
"level": "DEBUG"
}
});
kalturaPlayer.loadMedia({
"entryId": "0_wifqaipd"
});
} catch (e) {
console.error(e.message)
}

//Adding event listeners
kalturaPlayer.addEventListener(kalturaPlayer.Event.Core.VOLUME_CHANGE, event =>
console.info(kalturaPlayer.volume)
);

const events = [

kalturaPlayer.Event.Core.RATE_CHANGE,
kalturaPlayer.Event.Core.PLAY,
kalturaPlayer.Event.Core.TRACKS_CHANGED,
kalturaPlayer.Event.Core.PAUSE
];
events.forEach(eventName => {
kalturaPlayer.addEventListener(eventName, event => console.info('Event: ', event.type, " ", event.payload));
});
</script>
</body>

</html>
Binary file added docs/images/playbackSpeedConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/playbackSpeedConfigNewRange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tracksLabelsAudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tracksLabelsVideo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions docs/playback-speed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Playback Speed Configuration

The Kaltura Player exposes configuration and APIs that are used for controling the playback speed.

The default playback speed is 1.

Values less than 1 will result in reducing playback speed relatively to the nornal speed

Values greater 1 will result in increasing playback speed relatively to the nornal speed


### Playback Speed UI control

The playback seepd can be changed using the UI setting => speed controller icon.


![example](./images/playbackSpeedConfig.png)

#### PlaybackRates

PlaybackRates sets the available rates at which the media can be played.

###### The player default playbackRates :

```
[
0.5,
1,
1.5,
2
]
```

Application may change the default config by providing new values in the playback config object

```
"playback": {
...
"playbackRates": [
0.25,
0.5,
0.75,
1,
1.25,
1.5,
1.75,
2,
4
],
....
```

![example](./images/playbackSpeedConfigNewRange.png)

Note:

* Player may have issues to serve playack in high playback speed, especially on TV's
* Negative values are not valid
* Playback speed 0 will stop the playback


####Playback Speed API

Application may use the player API to get or set the player speed programatically.
make sure you set values which match the playbackRates Array values, as values which are out of that range will not impact the playback speed.

* Get API


```
kalturaPlayer.playbackRate = 1

1

```

* Set API

```
kalturaPlayer.playbackRate = 0.5

0.5

```

#### Event: RATE_CHANGE

The application can listen to the `RATE_CHANGE` event and be informed that such action was triggered by the user

```
const events = [
kalturaPlayer.Event.Core.RATE_CHANGE
];

events.forEach(eventName => {
kalturaPlayer.addEventListener(eventName, event => console.info('Event:', event.type, " ", event.payload));
});
```



#### Example:

**[Playback Speed Example](https://kaltura.github.io/kaltura-player-js/demo/playbackRate_selector.html)**

121 changes: 121 additions & 0 deletions docs/tracks-labels-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Tracks Labels Configuration

The Kaltura Player exposes configuration and APIs can modify the tracks and tracks labels.


Every track label can be changed using the configuration option `customLabels` on the player's root level configuration object.

[Klatura Player config](https://github.com/kaltura/kaltura-player-js/blob/master/docs/configuration.md#configcustomlabels)
[Playkit config](https://github.com/kaltura/playkit-js/blob/master/docs/configuration.md#configcustomlabels)

```
customLabels: {
//qualities: translateVideoQuality, // --> this can also be defined in a finclion check translateVideoQuality example below
qualities: function (videoTrack) {
if (videoTrack.height > 500) {
return 'High';
}
return 'Low';
},
captions: translateLangCode,
audio: translateLangCode
}
```


### Video Tracks Lables: translation function

Video Track has the following parameters which can be used for implementing the label logic


VideoTrack structure:

```
{
"active": false,
"label": "360p",
"language": "",
"index": 1,
"available": true,
"bandwidth": 719794,
"width": 640,
"height": 360
}
```

```
const translateVideoQuality = (track) => {
if (track.height > 500) {
return 'High';
}
return 'Low';
};
```


### AudioText Tracks Labels: translation function

Audio/Text Tracks have the following parameters which can be used for implementing the labels logic


AudioTrack structure:

```
{
"id": 0,
"active": false,
"label": "English",
"language": "en",
"index": 0,
"available": true
}

```

TextTrack structure:

```
{
"id": 1,
"active": true,
"label": "Esp",
"language": "es",
"index": 1,
"available": true,
"kind": "subtitles",
"default": false
}
```

```
const translateLangCode = (track) => {
giladna marked this conversation as resolved.
Show resolved Hide resolved
if (track.language === "es" || track.language === "spa") {
return 'Spanish';
}
else if (track.language === "en" || track.language === "eng") {
return 'English';
}
return track.label;
};
```

### Tracks UI control

The tracks can be changed using the settings icon for video tracks and the globe icon for audio and text tracks



![example](./images/tracksLabelsVideo.png)

![example](./images/tracksLabelsAudio.png)



#### Example:

**[Tracks Lables configuration](https://codepen.io/giladna/pen/WNyexqO)**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check how to replace with github pages


### Tracks Documentation

**[Tracks Documentation](https://github.com/kaltura/kaltura-player-js/blob/master/docs/managing-tracks.md)**