@brandbrigade/ott-bb-player 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,14 +1,28 @@
1
1
  {
2
2
  "name": "@brandbrigade/ott-bb-player",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "ott bb player",
5
- "main": "OTTPlayer.prod.js",
6
- "directories": {
7
- "lib": "lib"
8
- },
5
+ "main": "./dist/OTTPlayer.js",
6
+ "files": ["src", "dist"],
9
7
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "dev": "vite serve --host",
9
+ "format": "prettier --write .",
10
+ "build": "vite build",
11
+ "build-lib": "vite build --config vite.config.prod.js"
11
12
  },
12
13
  "author": "Alexey",
13
- "license": "ISC"
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "@vitejs/plugin-basic-ssl": "^1.1.0",
17
+ "prettier": "3.3.3",
18
+ "vite": "^5.4.8"
19
+ },
20
+ "dependencies": {
21
+ "@datadog/browser-logs": "^5.29.1",
22
+ "lodash": "^4.17.21",
23
+ "mp4box": "^0.5.2",
24
+ "socket.io-client": "^2.3.0",
25
+ "twgl.js": "^5.5.4",
26
+ "uzip": "^0.20201231.0"
27
+ }
14
28
  }
package/src/Ads.js ADDED
@@ -0,0 +1,82 @@
1
+ import Socket from "./Socket";
2
+
3
+ export default class Ads {
4
+ constructor(composer, options) {
5
+ let selectedAdsList = [];
6
+ const socket = new Socket((type, message) => {
7
+ switch (type) {
8
+ case "roommembers":
9
+ console.log("roommembers message: ", message);
10
+ break;
11
+ case "join":
12
+ const name = document.getElementById("name");
13
+ if (name) {
14
+ name.textContent = socket.name;
15
+ }
16
+ break;
17
+ case "messageroom":
18
+ if (message.player === socket.name) {
19
+ if (message.url) {
20
+ const name = "#external";
21
+ if (window.BB.RENDER_IN_WORKER) {
22
+ composer.addAdvertisement({
23
+ name,
24
+ path: message.url,
25
+ isSelected: true,
26
+ });
27
+ } else {
28
+ composer.addAdvertisement(name, message.url, () => {
29
+ composer.selectAd(name);
30
+ });
31
+ }
32
+ } else {
33
+ selectedAdsList = message.ads;
34
+ if (selectedAdsList.length) {
35
+ composer.selectAd(selectedAdsList[0]);
36
+ }
37
+ }
38
+ }
39
+ break;
40
+ case "ads":
41
+ selectedAdsList = message;
42
+ if (selectedAdsList.length) {
43
+ composer.selectAd(selectedAdsList[0]);
44
+ }
45
+ break;
46
+ }
47
+ });
48
+
49
+ socket.connect(options.augmentation.channelName);
50
+
51
+ //load the ads for this projects:
52
+ if (options.augmentation.logoURL) {
53
+ if (window.BB.RENDER_IN_WORKER) {
54
+ composer.addAdvertisement({
55
+ name: `#ad`,
56
+ path: options.augmentation.logoURL,
57
+ isSelected: false,
58
+ });
59
+ } else {
60
+ composer.addAdvertisement(`#ad`, options.augmentation.logoURL);
61
+ }
62
+ } //get logo according to the channel's S3 bucket
63
+ else {
64
+ fetch(
65
+ "https://www.virtualott.com/ads/" + options.augmentation.channelName,
66
+ ).then(async (res) => {
67
+ const list = await res.json();
68
+ list.forEach((photo) => {
69
+ if (window.BB.RENDER_IN_WORKER) {
70
+ composer.addAdvertisement({
71
+ name: `#${photo.name}`,
72
+ path: photo.url,
73
+ isSelected: true,
74
+ });
75
+ } else {
76
+ composer.addAdvertisement(`#${photo.name}`, photo.url);
77
+ }
78
+ });
79
+ });
80
+ }
81
+ }
82
+ }