Sfoglia il codice sorgente

feat(docs) update README

In addition:

- Remove old doc pointer
- Replace example with a more comprehensive one
dev0
Saúl Ibarra Corretgé 8 mesi fa
parent
commit
e4c695fe6d
4 ha cambiato i file con 3 aggiunte e 315 eliminazioni
  1. 3
    9
      README.md
  2. 0
    4
      doc/API.md
  3. 0
    282
      doc/example/example.js
  4. 0
    20
      doc/example/index.html

+ 3
- 9
README.md Vedi File

@@ -5,28 +5,22 @@ You can use Jitsi Meet API to create Jitsi Meet video conferences with a custom
5 5
 ## Installation
6 6
 
7 7
 - [Installation guide](doc/API.md#installation)
8
-- [Checkout the example](doc/example)
8
+- [Checkout the example](https://github.com/jitsi/ljm-getting-started)
9 9
 
10 10
 ## Building the sources
11 11
 
12
-NOTE: you need Node.js >= 12 and npm >= 7
13
-
14 12
 To build the library, just type:
15 13
 ```
16 14
 npm install
17 15
 npm run build
18 16
 ```
17
+
19 18
 To lint:
20 19
 ```
21 20
 npm run lint
22 21
 ```
22
+
23 23
 and to run unit tests:
24 24
 ```
25 25
 npm test
26 26
 ```
27
-if you need to rebuild lib-jitsi-meet.min.js
28
-```
29
-npm run build
30
-```
31
-
32
-Both linting and units will also be done by a pre-commit hook.

+ 0
- 4
doc/API.md Vedi File

@@ -1,4 +0,0 @@
1
-Jitsi Meet API
2
-============
3
-
4
-This document has been moved here: https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-ljm-api

+ 0
- 282
doc/example/example.js Vedi File

@@ -1,282 +0,0 @@
1
-/* global $, JitsiMeetJS */
2
-
3
-const options = {
4
-    hosts: {
5
-        domain: 'jitsi-meet.example.com',
6
-        muc: 'conference.jitsi-meet.example.com'
7
-    },
8
-    bosh: '//jitsi-meet.example.com/http-bind'
9
-};
10
-
11
-const confOptions = {
12
-};
13
-
14
-let connection = null;
15
-let isJoined = false;
16
-let room = null;
17
-
18
-let localTracks = [];
19
-const remoteTracks = {};
20
-
21
-/**
22
- * Handles local tracks.
23
- * @param tracks Array with JitsiTrack objects
24
- */
25
-function onLocalTracks(tracks) {
26
-    localTracks = tracks;
27
-    for (let i = 0; i < localTracks.length; i++) {
28
-        localTracks[i].addEventListener(
29
-            JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
30
-            audioLevel => console.log(`Audio Level local: ${audioLevel}`));
31
-        localTracks[i].addEventListener(
32
-            JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
33
-            () => console.log('local track muted'));
34
-        localTracks[i].addEventListener(
35
-            JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
36
-            () => console.log('local track stoped'));
37
-        localTracks[i].addEventListener(
38
-            JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
39
-            deviceId =>
40
-                console.log(
41
-                    `track audio output device was changed to ${deviceId}`));
42
-        if (localTracks[i].getType() === 'video') {
43
-            $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
44
-            localTracks[i].attach($(`#localVideo${i}`)[0]);
45
-        } else {
46
-            $('body').append(
47
-                `<audio autoplay='1' muted='true' id='localAudio${i}' />`);
48
-            localTracks[i].attach($(`#localAudio${i}`)[0]);
49
-        }
50
-        if (isJoined) {
51
-            room.addTrack(localTracks[i]);
52
-        }
53
-    }
54
-}
55
-
56
-/**
57
- * Handles remote tracks
58
- * @param track JitsiTrack object
59
- */
60
-function onRemoteTrack(track) {
61
-    if (track.isLocal()) {
62
-        return;
63
-    }
64
-    const participant = track.getParticipantId();
65
-
66
-    if (!remoteTracks[participant]) {
67
-        remoteTracks[participant] = [];
68
-    }
69
-    const idx = remoteTracks[participant].push(track);
70
-
71
-    track.addEventListener(
72
-        JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
73
-        audioLevel => console.log(`Audio Level remote: ${audioLevel}`));
74
-    track.addEventListener(
75
-        JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
76
-        () => console.log('remote track muted'));
77
-    track.addEventListener(
78
-        JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
79
-        () => console.log('remote track stoped'));
80
-    track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
81
-        deviceId =>
82
-            console.log(
83
-                `track audio output device was changed to ${deviceId}`));
84
-    const id = participant + track.getType() + idx;
85
-
86
-    if (track.getType() === 'video') {
87
-        $('body').append(
88
-            `<video autoplay='1' id='${participant}video${idx}' />`);
89
-    } else {
90
-        $('body').append(
91
-            `<audio autoplay='1' id='${participant}audio${idx}' />`);
92
-    }
93
-    track.attach($(`#${id}`)[0]);
94
-}
95
-
96
-/**
97
- * That function is executed when the conference is joined
98
- */
99
-function onConferenceJoined() {
100
-    console.log('conference joined!');
101
-    isJoined = true;
102
-    for (let i = 0; i < localTracks.length; i++) {
103
-        room.addTrack(localTracks[i]);
104
-    }
105
-}
106
-
107
-/**
108
- *
109
- * @param id
110
- */
111
-function onUserLeft(id) {
112
-    console.log('user left');
113
-    if (!remoteTracks[id]) {
114
-        return;
115
-    }
116
-    const tracks = remoteTracks[id];
117
-
118
-    for (let i = 0; i < tracks.length; i++) {
119
-        tracks[i].detach($(`#${id}${tracks[i].getType()}`));
120
-    }
121
-}
122
-
123
-/**
124
- * That function is called when connection is established successfully
125
- */
126
-function onConnectionSuccess() {
127
-    room = connection.initJitsiConference('conference', confOptions);
128
-    room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
129
-    room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, track => {
130
-        console.log(`track removed!!!${track}`);
131
-    });
132
-    room.on(
133
-        JitsiMeetJS.events.conference.CONFERENCE_JOINED,
134
-        onConferenceJoined);
135
-    room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
136
-        console.log('user join');
137
-        remoteTracks[id] = [];
138
-    });
139
-    room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
140
-    room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, track => {
141
-        console.log(`${track.getType()} - ${track.isMuted()}`);
142
-    });
143
-    room.on(
144
-        JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED,
145
-        (userID, displayName) => console.log(`${userID} - ${displayName}`));
146
-    room.on(
147
-        JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
148
-        (userID, audioLevel) => console.log(`${userID} - ${audioLevel}`));
149
-    room.on(
150
-        JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED,
151
-        () => console.log(`${room.getPhoneNumber()} - ${room.getPhonePin()}`));
152
-    room.join();
153
-}
154
-
155
-/**
156
- * This function is called when the connection fail.
157
- */
158
-function onConnectionFailed() {
159
-    console.error('Connection Failed!');
160
-}
161
-
162
-/**
163
- * This function is called when the connection fail.
164
- */
165
-function onDeviceListChanged(devices) {
166
-    console.info('current devices', devices);
167
-}
168
-
169
-/**
170
- * This function is called when we disconnect.
171
- */
172
-function disconnect() {
173
-    console.log('disconnect!');
174
-    connection.removeEventListener(
175
-        JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
176
-        onConnectionSuccess);
177
-    connection.removeEventListener(
178
-        JitsiMeetJS.events.connection.CONNECTION_FAILED,
179
-        onConnectionFailed);
180
-    connection.removeEventListener(
181
-        JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED,
182
-        disconnect);
183
-}
184
-
185
-/**
186
- *
187
- */
188
-function unload() {
189
-    for (let i = 0; i < localTracks.length; i++) {
190
-        localTracks[i].dispose();
191
-    }
192
-    room.leave();
193
-    connection.disconnect();
194
-}
195
-
196
-let isVideo = true;
197
-
198
-/**
199
- *
200
- */
201
-function switchVideo() { // eslint-disable-line no-unused-vars
202
-    isVideo = !isVideo;
203
-    if (localTracks[1]) {
204
-        localTracks[1].dispose();
205
-        localTracks.pop();
206
-    }
207
-    JitsiMeetJS.createLocalTracks({
208
-        devices: [ isVideo ? 'video' : 'desktop' ]
209
-    })
210
-        .then(tracks => {
211
-            localTracks.push(tracks[0]);
212
-            localTracks[1].addEventListener(
213
-                JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
214
-                () => console.log('local track muted'));
215
-            localTracks[1].addEventListener(
216
-                JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
217
-                () => console.log('local track stoped'));
218
-            localTracks[1].attach($('#localVideo1')[0]);
219
-            room.addTrack(localTracks[1]);
220
-        })
221
-        .catch(error => console.log(error));
222
-}
223
-
224
-/**
225
- *
226
- * @param selected
227
- */
228
-function changeAudioOutput(selected) { // eslint-disable-line no-unused-vars
229
-    JitsiMeetJS.mediaDevices.setAudioOutputDevice(selected.value);
230
-}
231
-
232
-$(window).bind('beforeunload', unload);
233
-$(window).bind('unload', unload);
234
-
235
-// JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
236
-const initOptions = {
237
-    disableAudioLevels: true
238
-};
239
-
240
-JitsiMeetJS.init(initOptions);
241
-
242
-connection = new JitsiMeetJS.JitsiConnection(null, null, options);
243
-
244
-connection.addEventListener(
245
-    JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
246
-    onConnectionSuccess);
247
-connection.addEventListener(
248
-    JitsiMeetJS.events.connection.CONNECTION_FAILED,
249
-    onConnectionFailed);
250
-connection.addEventListener(
251
-    JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED,
252
-    disconnect);
253
-
254
-JitsiMeetJS.mediaDevices.addEventListener(
255
-    JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
256
-    onDeviceListChanged);
257
-
258
-connection.connect();
259
-
260
-JitsiMeetJS.createLocalTracks({ devices: [ 'audio', 'video' ] })
261
-    .then(onLocalTracks)
262
-    .catch(error => {
263
-        throw error;
264
-    });
265
-
266
-if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
267
-    JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
268
-        const audioOutputDevices
269
-            = devices.filter(d => d.kind === 'audiooutput');
270
-
271
-        if (audioOutputDevices.length > 1) {
272
-            $('#audioOutputSelect').html(
273
-                audioOutputDevices
274
-                    .map(
275
-                        d =>
276
-                            `<option value="${d.deviceId}">${d.label}</option>`)
277
-                    .join('\n'));
278
-
279
-            $('#audioOutputSelectWrapper').show();
280
-        }
281
-    });
282
-}

+ 0
- 20
doc/example/index.html Vedi File

@@ -1,20 +0,0 @@
1
-<!DOCTYPE html>
2
-<html>
3
-<head lang="en">
4
-    <meta charset="UTF-8">
5
-    <title></title>
6
-    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
7
-    <script src="../../lib-jitsi-meet.min.js"></script>
8
-    <script src="example.js" ></script>
9
-</head>
10
-<body>
11
-    <a href="#" onclick="unload()">Unload</a>
12
-    <a href="#" onclick="switchVideo()">switchVideo</a>
13
-    <div id="audioOutputSelectWrapper" style="display: none;">
14
-        Change audio output device
15
-        <select id="audioOutputSelect" onchange="changeAudioOutput(this)"></select>
16
-    </div>
17
-    <!-- <video id="localVideo" autoplay="true"></video> -->
18
-    <!--<audio id="localAudio" autoplay="true" muted="true"></audio>-->
19
-</body>
20
-</html>

Loading…
Annulla
Salva