@christianriedl/media 1.0.6 → 1.0.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.6",
3
+ "version": "1.0.9",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -18,8 +18,8 @@
18
18
  "author": "Christian Riedl",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "@christianriedl/utils": "^1.0.51",
22
- "@christianriedl/rest": "^1.0.19"
21
+ "@christianriedl/utils": "^1.0.57",
22
+ "@christianriedl/rest": "^1.0.22"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "^4.6.3",
@@ -1,15 +1,18 @@
1
1
  <script setup lang="ts">
2
2
  import { inject, ref, reactive, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
3
3
  import { IAppState, Helper } from '@christianriedl/utils';
4
+ import { Authorize, EScope } from '@christianriedl/rest';
4
5
  import { EItemType, EMediaType, IMediaFolder, IMediaItem, IAudioFile, MediaService, EPlayState, PlayerService } from '@christianriedl/media';
5
6
 
6
7
  const appState = inject<IAppState>('appstate')!;
8
+ const authorize = inject<Authorize>('authorize')!;
7
9
  const getMediaService = inject<() => MediaService>('get-media')!;
8
10
  const mediaService = getMediaService();
9
11
  const getPlayerService = inject<() => PlayerService>('get-player')!;
10
12
  const playerService = getPlayerService();
11
13
  const heightStyle = computed(() => { return { height: appState.bodyHeight.value + 'px', overflowY: 'auto' } });
12
14
  const isMobile = appState.isMobile;
15
+ const supportsLocalMedia = authorize.checkScope(EScope.Media);
13
16
 
14
17
  const playerNames = reactive<string[]>(['Local']);
15
18
  const currentPlayer = ref('Local');
@@ -70,8 +73,10 @@
70
73
  selected.value = root;
71
74
  items.splice(0, items.length, ...root.Folders);
72
75
  computeListHeight();
73
- const players = await playerService.getPlayers(EMediaType.Audio, true);
74
- playerNames.splice(playerNames.length, 0, ...players);
76
+ if (supportsLocalMedia) {
77
+ const players = await playerService.getPlayers(EMediaType.Audio, true);
78
+ playerNames.splice(playerNames.length, 0, ...players);
79
+ }
75
80
  })
76
81
  watch(appState.bodyHeight, () => computeListHeight());
77
82
  function computeListHeight() {
@@ -302,7 +307,7 @@
302
307
  <v-list-item-subtitle v-if="playingTrack">{{playingTrack.Name}}</v-list-item-subtitle>
303
308
  </v-list-item-content>
304
309
  </v-col>
305
- <v-col cols="4">
310
+ <v-col cols="4" v-if="supportsLocalMedia">
306
311
  <v-select v-model="currentPlayer"
307
312
  :items="playerNames"
308
313
  persistent-hint
@@ -336,7 +341,7 @@
336
341
  <v-btn small v-if="downloadVisible" @click="download">
337
342
  <v-icon>{{$vuetify.icons.values.download}}</v-icon>
338
343
  </v-btn>
339
- <v-slider v-if="playingTrack" style="width:30%" color="red" track-color="blue" track-fill-color="red" v-model="volume" hide-details density="compact"
344
+ <v-slider v-if="!isLocal && playingTrack" style="width:30%" color="red" track-color="blue" track-fill-color="red" v-model="volume" hide-details density="compact"
340
345
  min="0" max="100" step="5" @update:modelValue="changeVolume">
341
346
  </v-slider>
342
347
  </v-card-actions>
@@ -2,17 +2,20 @@
2
2
  import { inject, ref, reactive, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
3
3
  import { useRouter } from 'vue-router';
4
4
  import { IAppState } from '@christianriedl/utils';
5
+ import { Authorize, EScope } from '@christianriedl/rest';
5
6
  import { EItemType, EMediaType, IMediaFolder, IMediaItem, IVideoFile, MediaService, PlayerService } from '@christianriedl/media';
6
7
  import { ISensorsState } from '@christianriedl/smarthome';
7
8
 
8
9
  const appState = inject<IAppState>('appstate')!;
9
10
  const sensors = inject<ISensorsState>('smarthome')!;
11
+ const authorize = inject<Authorize>('authorize')!;
10
12
  const getMediaService = inject<() => MediaService>('get-media')!;
11
13
  const mediaService = getMediaService();
12
14
  const getPlayerService = inject<() => PlayerService>('get-player')!;
13
15
  const playerService = getPlayerService();
14
16
  const rendererName = "[TV] Samsung Q9 Series (75)";
15
17
  const showRenderer = ref(false);
18
+ const supportsLocalMedia = authorize.checkScope(EScope.Media);
16
19
 
17
20
  const heightStyle = computed(() => { return { height: appState.bodyHeight.value + 'px', overflowY: 'auto' } });
18
21
  const isMobile = appState.isMobile;
@@ -142,18 +145,20 @@
142
145
  return "";
143
146
  }
144
147
  function getPlayer() {
145
- const samsungTV = sensors.sensors['HomeNetwork.SamsungTV'];
146
- if (samsungTV && samsungTV.values["Online"].value) {
147
- if (!showRenderer.value) {
148
- playerService.getPlayerState(rendererName)
149
- .then((playerState) => {
150
- if (playerState)
151
- showRenderer.value = true;
152
- });
148
+ if (supportsLocalMedia) {
149
+ const samsungTV = sensors.sensors['HomeNetwork.SamsungTV'];
150
+ if (samsungTV && samsungTV.values["Online"].value) {
151
+ if (!showRenderer.value) {
152
+ playerService.getPlayerState(rendererName)
153
+ .then((playerState) => {
154
+ if (playerState)
155
+ showRenderer.value = true;
156
+ });
157
+ }
158
+ }
159
+ else {
160
+ showRenderer.value = false;
153
161
  }
154
- }
155
- else {
156
- showRenderer.value = false;
157
162
  }
158
163
  }
159
164
  </script>