@flashphoner/websdk 2.0.201 → 2.0.206

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.
Files changed (58) hide show
  1. package/docTemplate/README.md +1 -1
  2. package/examples/demo/sip/phone/phone.js +7 -10
  3. package/examples/demo/streaming/hls-player/hls-player.html +1 -4
  4. package/examples/demo/streaming/hls-player/hls-player.js +19 -1
  5. package/examples/demo/streaming/hls-player/player-page.html +1 -1
  6. package/examples/demo/streaming/hls-player/video-js.css +142 -51
  7. package/examples/demo/streaming/hls-player/video.js +27294 -20390
  8. package/examples/demo/streaming/hls-player/video.min.js +27 -0
  9. package/examples/demo/streaming/media_devices_manager/manager.js +27 -1
  10. package/examples/demo/streaming/media_devices_manager/media_device_manager.html +7 -0
  11. package/examples/typescript/two-way-streaming-ts/.gitignore +23 -0
  12. package/examples/typescript/two-way-streaming-ts/README.md +36 -0
  13. package/examples/typescript/two-way-streaming-ts/package.json +45 -0
  14. package/examples/typescript/two-way-streaming-ts/public/favicon.ico +0 -0
  15. package/examples/typescript/two-way-streaming-ts/public/index.html +33 -0
  16. package/examples/typescript/two-way-streaming-ts/public/logo192.png +0 -0
  17. package/examples/typescript/two-way-streaming-ts/public/logo512.png +0 -0
  18. package/examples/typescript/two-way-streaming-ts/public/manifest.json +25 -0
  19. package/examples/typescript/two-way-streaming-ts/public/media/preloader.mp4 +0 -0
  20. package/examples/typescript/two-way-streaming-ts/public/robots.txt +3 -0
  21. package/examples/typescript/two-way-streaming-ts/src/TwoWayStreamingApp.css +23 -0
  22. package/examples/typescript/two-way-streaming-ts/src/TwoWayStreamingApp.tsx +371 -0
  23. package/examples/typescript/two-way-streaming-ts/src/fp-utils.ts +117 -0
  24. package/examples/typescript/two-way-streaming-ts/src/index.css +13 -0
  25. package/examples/typescript/two-way-streaming-ts/src/index.tsx +9 -0
  26. package/examples/typescript/two-way-streaming-ts/tsconfig.json +26 -0
  27. package/examples/vue/two-way-streaming-vue/.gitignore +23 -0
  28. package/examples/vue/two-way-streaming-vue/README.md +36 -0
  29. package/examples/vue/two-way-streaming-vue/babel.config.js +5 -0
  30. package/examples/vue/two-way-streaming-vue/package.json +47 -0
  31. package/examples/vue/two-way-streaming-vue/public/favicon.ico +0 -0
  32. package/examples/vue/two-way-streaming-vue/public/index.html +17 -0
  33. package/examples/vue/two-way-streaming-vue/src/TwoWayStreamingApp.vue +346 -0
  34. package/examples/vue/two-way-streaming-vue/src/assets/media/preloader.mp4 +0 -0
  35. package/examples/vue/two-way-streaming-vue/src/fp-utils.js +117 -0
  36. package/examples/vue/two-way-streaming-vue/src/main.js +9 -0
  37. package/examples/vue/two-way-streaming-vue/vue.config.js +8 -0
  38. package/flashphoner-no-flash.js +4 -4
  39. package/flashphoner-no-flash.min.js +1 -1
  40. package/flashphoner-no-webrtc.js +4 -4
  41. package/flashphoner-no-webrtc.min.js +1 -1
  42. package/flashphoner-no-wsplayer.js +4 -4
  43. package/flashphoner-no-wsplayer.min.js +1 -1
  44. package/flashphoner-room-api.js +4 -4
  45. package/flashphoner-room-api.min.js +1 -1
  46. package/flashphoner-temasys-flash-websocket-without-adapterjs.js +4 -4
  47. package/flashphoner-temasys-flash-websocket.js +4 -4
  48. package/flashphoner-temasys-flash-websocket.min.js +1 -1
  49. package/flashphoner-webrtc-only.js +4 -4
  50. package/flashphoner-webrtc-only.min.js +1 -1
  51. package/flashphoner.js +4 -4
  52. package/flashphoner.min.js +1 -1
  53. package/package.json +2 -1
  54. package/src/constants.d.ts +1 -0
  55. package/src/flashphoner-core.d.ts +192 -0
  56. package/src/flashphoner-core.js +4 -4
  57. package/src/room-module.d.ts +29 -0
  58. package/examples/demo/streaming/hls-player/videojs-hls.min.js +0 -27
@@ -0,0 +1,117 @@
1
+ // eslint-disable-next-line
2
+ 'use strict';
3
+ import { constants } from '@flashphoner/websdk';
4
+ const STREAM_STATUS = constants.STREAM_STATUS;
5
+
6
+ // Set default websocket URL
7
+ export function setURL(): string {
8
+ let proto: string;
9
+ let url: string;
10
+ let port: string;
11
+ if (window.location.protocol === "http:") {
12
+ proto = "ws://";
13
+ port = "8080";
14
+ } else {
15
+ proto = "wss://";
16
+ port = "8443";
17
+ }
18
+
19
+ url = proto + window.location.hostname + ":" + port;
20
+ return url;
21
+ }
22
+
23
+ // Get URL parameter by name
24
+ export function getUrlParam(name: string): string | null {
25
+ let url = window.location.href;
26
+ // eslint-disable-next-line
27
+ name = name.replace(/[\[\]]/g, "\\$&");
28
+ let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
29
+ results = regex.exec(url);
30
+ if (!results) return null;
31
+ if (!results[2]) return '';
32
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
33
+ }
34
+
35
+ // Generate simple uuid
36
+ export function createUUID(length: number): string {
37
+ var s = [];
38
+ var hexDigits = "0123456789abcdef";
39
+ for (var i = 0; i < 36; i++) {
40
+ s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
41
+ }
42
+ s[14] = "4";
43
+ s[19] = hexDigits.substr((parseInt(s[19], 16) & 0x3) | 0x8, 1);
44
+ s[8] = s[13] = s[18] = s[23] = "-";
45
+
46
+ var uuid = s.join("");
47
+
48
+ return uuid.substring(0, length);
49
+ }
50
+
51
+ // Helper function to downscale picture size
52
+ export function downScaleToFitSize(videoWidth: number, videoHeight: number, dstWidth: number, dstHeight: number): any {
53
+ let newWidth: number, newHeight: number;
54
+ var videoRatio = videoWidth / videoHeight;
55
+ var dstRatio = dstWidth / dstHeight;
56
+ if (dstRatio > videoRatio) {
57
+ newHeight = dstHeight;
58
+ newWidth = Math.floor(videoRatio * dstHeight);
59
+ } else {
60
+ newWidth = dstWidth;
61
+ newHeight = Math.floor(dstWidth / videoRatio);
62
+ }
63
+ return {
64
+ w: newWidth,
65
+ h: newHeight
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Resize video object to fit parent div.
71
+ * Div structure: div WxH -> div wrapper (display) -> video
72
+ * @param video HTML element from resize event target
73
+ */
74
+ export function resizeVideo(video: any, width?: number, height?: number) {
75
+ if (!video.parentNode) {
76
+ return;
77
+ }
78
+ let videoWidth = video.width;
79
+ let videoHeight = video.height;
80
+ if (video instanceof HTMLVideoElement) {
81
+ videoWidth = video.videoWidth;
82
+ videoHeight = video.videoHeight;
83
+ }
84
+ var display = video.parentNode;
85
+ var parentSize = {
86
+ w: display.parentNode.clientWidth,
87
+ h: display.parentNode.clientHeight
88
+ };
89
+ let newSize: any;
90
+ if (width && height) {
91
+ newSize = downScaleToFitSize(width, height, parentSize.w, parentSize.h);
92
+ } else {
93
+ newSize = downScaleToFitSize(videoWidth, videoHeight, parentSize.w, parentSize.h);
94
+ }
95
+ display.style.width = newSize.w + "px";
96
+ display.style.height = newSize.h + "px";
97
+
98
+ //vertical align
99
+ let margin = 0;
100
+ if (parentSize.h - newSize.h > 1) {
101
+ margin = Math.floor((parentSize.h - newSize.h) / 2);
102
+ }
103
+ display.style.margin = margin + "px auto";
104
+ console.log("Resize from " + videoWidth + "x" + videoHeight + " to " + display.offsetWidth + "x" + display.offsetHeight);
105
+ }
106
+
107
+ export function isPlaying(streamStatus: string): boolean {
108
+ switch(streamStatus) {
109
+ case STREAM_STATUS.PLAYING:
110
+ case STREAM_STATUS.RESIZE:
111
+ case STREAM_STATUS.SNAPSHOT_COMPLETE:
112
+ case STREAM_STATUS.NOT_ENOUGH_BANDWIDTH:
113
+ return true;
114
+ default:
115
+ return false;
116
+ }
117
+ }
@@ -0,0 +1,13 @@
1
+ body {
2
+ margin: 0;
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+ sans-serif;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ }
9
+
10
+ code {
11
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
+ monospace;
13
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import './index.css';
4
+ import TwoWayStreamingApp from './TwoWayStreamingApp';
5
+
6
+ ReactDOM.render(
7
+ <TwoWayStreamingApp />,
8
+ document.getElementById('root')
9
+ );
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "jsx": "react-jsx",
5
+ "module": "esnext",
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "lib": [
11
+ "dom",
12
+ "dom.iterable",
13
+ "esnext"
14
+ ],
15
+ "allowJs": true,
16
+ "allowSyntheticDefaultImports": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "moduleResolution": "node",
19
+ "resolveJsonModule": true,
20
+ "isolatedModules": true,
21
+ "noEmit": true
22
+ },
23
+ "include": [
24
+ "src"
25
+ ]
26
+ }
@@ -0,0 +1,23 @@
1
+ .DS_Store
2
+ node_modules
3
+ /dist
4
+
5
+
6
+ # local env files
7
+ .env.local
8
+ .env.*.local
9
+
10
+ # Log files
11
+ npm-debug.log*
12
+ yarn-debug.log*
13
+ yarn-error.log*
14
+ pnpm-debug.log*
15
+
16
+ # Editor directories and files
17
+ .idea
18
+ .vscode
19
+ *.suo
20
+ *.ntvs*
21
+ *.njsproj
22
+ *.sln
23
+ *.sw?
@@ -0,0 +1,36 @@
1
+ # Two Way Streaming Vue.js example application
2
+
3
+ This example shows how to integrate Flashphoner [WebCallServer](https://flashphoner.com) Javascript API ([WebSDK](https://www.npmjs.com/package/@flashphoner/websdk)) to Vue.js application
4
+
5
+ ## How to build
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm install`
10
+
11
+ Installs all the dependencies needed.
12
+
13
+ ### `npm run serve`
14
+
15
+ Runs the app in the development mode.\
16
+ Open [http://localhost:8080](http://localhost:8080) to view it in the browser.
17
+
18
+ ### `npm run build`
19
+
20
+ Builds the app for production to the `dist` folder.\
21
+ It correctly bundles React and WebSDK in production mode and optimizes the build for the best performance.
22
+
23
+ The build is minified and the filenames include the hashes.\
24
+ Your app is ready to be deployed!
25
+
26
+ ## How to deploy
27
+
28
+ Copy build folder content to a web server, for example
29
+ ```
30
+ mkdir -p /var/www/html/two-way-streaming-vue
31
+ cp -r dist/* /var/www/html/two-way-streaming-vue
32
+ ```
33
+
34
+ Then you can open example page in browser `https://yourhost/two-way-streaming-vue/index.html`
35
+
36
+ Please note that you should open page via secure connection in browser for WebRTC to work, except localhost.
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ presets: [
3
+ '@vue/cli-plugin-babel/preset'
4
+ ]
5
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "two-way-streaming-vue",
3
+ "description": "Two Way Streaming Vue.js application example using Flashphoner Web SDK",
4
+ "author": "Flashphoner",
5
+ "license": "MIT",
6
+ "version": "1.0.0",
7
+ "private": true,
8
+ "scripts": {
9
+ "serve": "vue-cli-service serve",
10
+ "build": "vue-cli-service build",
11
+ "lint": "vue-cli-service lint"
12
+ },
13
+ "dependencies": {
14
+ "@flashphoner/websdk": "^2.0.200",
15
+ "bootstrap": "^5.1.1",
16
+ "core-js": "^3.6.5",
17
+ "vue": "^2.6.11"
18
+ },
19
+ "devDependencies": {
20
+ "@vue/cli-plugin-babel": "~4.5.0",
21
+ "@vue/cli-plugin-eslint": "~4.5.0",
22
+ "@vue/cli-service": "~4.5.0",
23
+ "babel-eslint": "^10.1.0",
24
+ "eslint": "^6.7.2",
25
+ "eslint-plugin-vue": "^6.2.2",
26
+ "vue-template-compiler": "^2.6.11"
27
+ },
28
+ "eslintConfig": {
29
+ "root": true,
30
+ "env": {
31
+ "node": true
32
+ },
33
+ "extends": [
34
+ "plugin:vue/essential",
35
+ "eslint:recommended"
36
+ ],
37
+ "parserOptions": {
38
+ "parser": "babel-eslint"
39
+ },
40
+ "rules": {}
41
+ },
42
+ "browserslist": [
43
+ "> 1%",
44
+ "last 2 versions",
45
+ "not dead"
46
+ ]
47
+ }
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
+ <title><%= htmlWebpackPlugin.options.title %></title>
9
+ </head>
10
+ <body>
11
+ <noscript>
12
+ <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13
+ </noscript>
14
+ <div id="app"></div>
15
+ <!-- built files will be auto injected -->
16
+ </body>
17
+ </html>
@@ -0,0 +1,346 @@
1
+ <template>
2
+ <div id="app">
3
+ <div class="container">
4
+ <h2 class="text-danger">{{ apiFailed }}</h2>
5
+ <div class="row col-sm-12">
6
+ <h2 class="text-center">Two-way Streaming in Vue</h2>
7
+ </div>
8
+ <div class="row col-sm-12" style="margin-top: 20px;">
9
+ <div class="col-sm-6">
10
+ <div class="text-center text-muted">Local</div>
11
+ <div class="fp-Video">
12
+ <div id="localVideo" class="display"></div>
13
+ </div>
14
+ <div class="input-group col-sm-5" style="margin: 10px auto 0 auto;">
15
+ <input type="text"
16
+ class="form-control"
17
+ placeholder="Stream Name"
18
+ v-model="publishStreamName"
19
+ :disabled="publishStreamNameDisabled"
20
+ />
21
+ <div class="input-group-btn">
22
+ <button
23
+ class="btn btn-outline-dark"
24
+ :disabled="publishButtonDisabled"
25
+ v-on:click="onPublishClick">
26
+ {{ publishButtonText }}
27
+ </button>
28
+ </div>
29
+ </div>
30
+ <div class="text-center" style="margin-top: 20px;">
31
+ <div v-bind:class="publishStatusClass">{{ publishStatus }}</div>
32
+ </div>
33
+ </div>
34
+ <div class="col-sm-6">
35
+ <div class="text-center text-muted">Remote</div>
36
+ <div class="fp-Video">
37
+ <div id="remoteVideo" class="display"></div>
38
+ </div>
39
+ <div class="input-group col-sm-5" style="margin: 10px auto 0 auto;">
40
+ <input type="text"
41
+ class="form-control"
42
+ placeholder="Stream Name"
43
+ v-model="playStreamName"
44
+ :disabled="playStreamNameDisabled"
45
+ />
46
+ <div class="input-group-btn">
47
+ <button
48
+ class="btn btn-outline-dark"
49
+ :disabled="playButtonDisabled"
50
+ v-on:click="onPlayClick">
51
+ {{ playButtonText }}
52
+ </button>
53
+ </div>
54
+ </div>
55
+ <div class="text-center" style="margin-top: 20px;">
56
+ <div v-bind:class="playStatusClass">{{ playStatus }}</div>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ <div class="row col-sm-12" style="margin-top: 20px;">
61
+ <div class="col-sm-6 offset-sm-3">
62
+ <div class="input-group col-sm-5">
63
+ <input type="text"
64
+ class="form-control"
65
+ placeholder="Server Url"
66
+ v-model="serverUrl"
67
+ :disabled="serverUrlDisabled"
68
+ />
69
+ <div class="input-group-btn">
70
+ <button
71
+ class="btn btn-outline-dark"
72
+ :disabled="connectButtonDisabled"
73
+ v-on:click="onConnectClick">
74
+ {{ connectButtonText }}
75
+ </button>
76
+ </div>
77
+ </div>
78
+ <div class="text-center" style="margin-top: '20px';">
79
+ <div v-bind:class="sessionStatusClass">{{ sessionStatus }}</div>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </template>
86
+
87
+ <script>
88
+ import * as FPUtils from './fp-utils.js';
89
+ import * as Flashphoner from '@flashphoner/websdk';
90
+
91
+ const SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
92
+ const STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
93
+ const Browser = Flashphoner.Browser;
94
+ const PRELOADER_URL = require('@/assets/media/preloader.mp4');
95
+
96
+ export default {
97
+ name: 'TwoWayStreamingApp',
98
+ data: () => ({
99
+ apiFailed: '',
100
+ session: null,
101
+ sessionStatus: '',
102
+ sessionStatusClass: 'text-muted',
103
+ localVideo: null,
104
+ remoteVideo: null,
105
+ publishStreamObj: null,
106
+ publishStatus: '',
107
+ publishStatusClass: 'text-muted',
108
+ playStreamObj: null,
109
+ playStatus: '',
110
+ playStatusClass: 'text-muted',
111
+ publishStreamName: 'streamName',
112
+ publishStreamNameDisabled: true,
113
+ playStreamName: 'streamName',
114
+ playStreamNameDisabled: true,
115
+ connectButtonText: 'Connect',
116
+ connectButtonDisabled: false,
117
+ serverUrl: 'wss://demo.flashphoner.com:8443',
118
+ serverUrlDisabled: false,
119
+ publishButtonText: 'Publish',
120
+ publishButtonDisabled: true,
121
+ playButtonText: 'Play',
122
+ playButtonDisabled: true,
123
+ }),
124
+ mounted() {
125
+ this.onLoad();
126
+ },
127
+ methods: {
128
+ onLoad() {
129
+ try {
130
+ Flashphoner.init({});
131
+ this.localVideo = document.getElementById('localVideo');
132
+ this.remoteVideo = document.getElementById('remoteVideo');
133
+ }
134
+ catch(e) {
135
+ console.log(e);
136
+ this.apiFailed = 'Your browser does not support WebRTC technology needed for this example';
137
+ this.connectButtonDisabled = true;
138
+ this.serverUrlDisabled = true;
139
+ }
140
+ },
141
+ onConnected(session) {
142
+ this.session = session;
143
+ this.connectButtonText = 'Disconnect';
144
+ this.connectButtonDisabled = false;
145
+ this.serverUrlDisabled = true;
146
+ this.onUnpublished();
147
+ this.onStopped();
148
+ },
149
+ onDisconnected() {
150
+ this.session = null;
151
+ this.connectButtonText = 'Connect';
152
+ this.connectButtonDisabled = false;
153
+ this.serverUrlDisabled = false;
154
+ this.onUnpublished();
155
+ this.onStopped();
156
+ },
157
+ onPublishing(stream) {
158
+ this.publishStreamObj = stream;
159
+ this.publishButtonText = 'Unpublish';
160
+ this.publishButtonDisabled = false;
161
+ },
162
+ onUnpublished() {
163
+ let session = this.session;
164
+ let itemState = true;
165
+
166
+ if(session && session.status() === SESSION_STATUS.ESTABLISHED) {
167
+ itemState = false;
168
+ }
169
+ this.publishStreamObj = null;
170
+ this.publishButtonText = 'Publish';
171
+ this.publishButtonDisabled = itemState;
172
+ this.publishStreamNameDisabled = itemState;
173
+ },
174
+ onPlaying(stream) {
175
+ this.playStreamObj = stream;
176
+ this.playButtonText = 'Stop';
177
+ this.playButtonDisabled = false;
178
+ },
179
+ onStopped() {
180
+ let session = this.session;
181
+ let itemState = true;
182
+
183
+ if(session && session.status() === SESSION_STATUS.ESTABLISHED) {
184
+ itemState = false;
185
+ }
186
+ this.playStreamObj = null;
187
+ this.playButtonText = 'Play';
188
+ this.playButtonDisabled = itemState;
189
+ this.playStreamNameDisabled = itemState;
190
+ },
191
+ publishStream() {
192
+ let session = this.session;
193
+ let streamName = this.publishStreamName;
194
+ let localVideo = this.localVideo;
195
+
196
+ if(session && localVideo) {
197
+ session.createStream({
198
+ name: streamName,
199
+ display: localVideo,
200
+ cacheLocalResources: true,
201
+ receiveVideo: false,
202
+ receiveAudio: false
203
+ }).on(STREAM_STATUS.PUBLISHING, (stream) => {
204
+ this.publishStatus = STREAM_STATUS.PUBLISHING;
205
+ this.publishStatusClass = 'text-success';
206
+ this.onPublishing(stream);
207
+ }).on(STREAM_STATUS.UNPUBLISHED, () => {
208
+ this.publishStatus = STREAM_STATUS.UNPUBLISHED;
209
+ this.publishStatusClass = 'text-success';
210
+ this.onUnpublished();
211
+ }).on(STREAM_STATUS.FAILED, () => {
212
+ this.publishStatus = STREAM_STATUS.FAILED;
213
+ this.publishStatusClass = 'text-danger';
214
+ this.onUnpublished();
215
+ }).publish();
216
+ }
217
+ },
218
+ playStream() {
219
+ let session = this.session;
220
+ let streamName = this.playStreamName;
221
+ let remoteVideo = this.remoteVideo;
222
+
223
+ if(session && remoteVideo) {
224
+ session.createStream({
225
+ name: streamName,
226
+ display: remoteVideo
227
+ }).on(STREAM_STATUS.PENDING, (stream) => {
228
+ let video = document.getElementById(stream.id());
229
+ if (!video.hasListeners) {
230
+ video.hasListeners = true;
231
+ video.addEventListener('resize', (event) => {
232
+ FPUtils.resizeVideo(event.target);
233
+ });
234
+ }
235
+ }).on(STREAM_STATUS.PLAYING, (stream) => {
236
+ this.playStatus = STREAM_STATUS.PLAYING;
237
+ this.playStatusClass = 'text-success';
238
+ this.onPlaying(stream);
239
+ }).on(STREAM_STATUS.STOPPED, () => {
240
+ this.playStatus = STREAM_STATUS.STOPPED;
241
+ this.playStatusClass = 'text-success';
242
+ this.onStopped();
243
+ }).on(STREAM_STATUS.FAILED, () => {
244
+ this.playStatus = STREAM_STATUS.FAILED;
245
+ this.playStatusClass = 'text-danger';
246
+ this.onStopped();
247
+ }).play();
248
+ }
249
+ },
250
+ onConnectClick() {
251
+ let url = this.serverUrl;
252
+ let session = this.session;
253
+
254
+ if (!session) {
255
+ console.log("Create new session with url " + url);
256
+ this.connectButtonDisabled = true;
257
+ this.serverUrlDisabled = true;
258
+ Flashphoner.createSession({urlServer: url}).on(SESSION_STATUS.ESTABLISHED, (session) => {
259
+ this.sessionStatus = SESSION_STATUS.ESTABLISHED;
260
+ this.sessionStatusClass = 'text-success';
261
+ this.onConnected(session);
262
+ }).on(SESSION_STATUS.DISCONNECTED, () => {
263
+ this.sessionStatus = SESSION_STATUS.DISCONNECTED;
264
+ this.sessionStatusClass = 'text-success';
265
+ this.onDisconnected();
266
+ }).on(SESSION_STATUS.FAILED, () => {
267
+ this.sessionStatus = SESSION_STATUS.FAILED;
268
+ this.sessionStatusClass = 'text-danger';
269
+ this.onDisconnected();
270
+ });
271
+ } else {
272
+ this.connectButtonDisabled = true;
273
+ session.disconnect();
274
+ }
275
+ },
276
+ onPublishClick() {
277
+ let stream = this.publishStreamObj;
278
+ let localVideo = this.localVideo;
279
+
280
+ if (!localVideo) return;
281
+ if (!stream) {
282
+ this.publishButtonDisabled = true;
283
+ this.publishStreamNameDisabled = true;
284
+ if (Browser.isSafariWebRTC()) {
285
+ Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(() => {
286
+ this.publishStream();
287
+ });
288
+ return;
289
+ }
290
+ this.publishStream();
291
+ } else {
292
+ this.publishButtonDisabled = true;
293
+ stream.stop();
294
+ }
295
+ },
296
+ onPlayClick() {
297
+ let stream = this.playStreamObj;
298
+ let remoteVideo = this.remoteVideo;
299
+
300
+ if (!remoteVideo) return;
301
+ if (!stream) {
302
+ this.playButtonDisabled = true;
303
+ this.playStreamNameDisabled = true;
304
+ if (Flashphoner.getMediaProviders()[0] === "WSPlayer") {
305
+ Flashphoner.playFirstSound();
306
+ } else if (Browser.isSafariWebRTC()) {
307
+ Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(() => {
308
+ this.playStream();
309
+ });
310
+ return;
311
+ }
312
+ this.playStream();
313
+ } else {
314
+ this.playButtonDisabled = true;
315
+ stream.stop();
316
+ }
317
+ }
318
+ }
319
+ }
320
+ </script>
321
+
322
+ <style>
323
+ .fp-Video {
324
+ border: 1px double black;
325
+ width: 322px;
326
+ height: 242px;
327
+ text-align: center;
328
+ background: #c0c0c0;
329
+ margin: 0 auto 0 auto;
330
+ }
331
+
332
+ .display {
333
+ width: 100%;
334
+ height: 100%;
335
+ display: inline-block;
336
+ }
337
+
338
+ .display > video, object {
339
+ width: 100%;
340
+ height: 100%;
341
+ }
342
+
343
+ video:-webkit-full-screen {
344
+ border-radius: 1px;
345
+ }
346
+ </style>