@christianriedl/media 1.0.301 → 1.0.302

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/dist/iMedia.d.ts CHANGED
@@ -344,6 +344,7 @@ export interface IPlaylistState {
344
344
  position: string;
345
345
  }
346
346
  export interface IPlaylistService {
347
+ log: ILogger;
347
348
  soundbarOn: boolean;
348
349
  getTitles(): Promise<string[]>;
349
350
  getFeed(title: string): Promise<IRssFeed | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.301",
3
+ "version": "1.0.302",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -244,6 +244,9 @@
244
244
  function onlineRadio() {
245
245
  router.push({ path: 'onlineradios' });
246
246
  }
247
+ function onlinePodcast() {
248
+ router.push({ path: 'onlinepodcasts' });
249
+ }
247
250
  function download() {
248
251
  window.open(playingTrackUrl.value);
249
252
  }
@@ -319,9 +322,14 @@
319
322
  <v-btn v-if="backVisible" @click="listBack">
320
323
  <v-icon icon="$back" />
321
324
  </v-btn>
322
- <v-btn v-else @click.stop="onlineRadio">
325
+ <template v-else>
326
+ <v-btn @click.stop="onlineRadio">
323
327
  <v-icon size="x-large" icon="$radio" />
324
328
  </v-btn>
329
+ <v-btn @click.stop="onlinePodcast">
330
+ <v-icon size="x-large" icon="$podcast" />
331
+ </v-btn>
332
+ </template>
325
333
  <v-btn v-if="downloadAlbumVisible" @click="downloadAlbum">
326
334
  Album
327
335
  <v-icon icon="$download" />
@@ -3,7 +3,7 @@
3
3
  import type { ComponentPublicInstance } from 'vue';
4
4
  import { useRouter } from 'vue-router';
5
5
  import { IAppState, EScope, EDevice, appStateSymbol, appConfigSymbol } from '@christianriedl/utils';
6
- import { getPlaylistSymbol, IPlaylistService, IPlaylistState, IRssFeed } from '@christianriedl/media';
6
+ import { getPlaylistSymbol, IPlaylistService, IPlaylistState, IRssFeed, EPlaylistCommand } from '@christianriedl/media';
7
7
 
8
8
  const appState = inject(appStateSymbol)!;
9
9
  const getPlaylistService = inject(getPlaylistSymbol)!;
@@ -21,9 +21,12 @@
21
21
  const currentPlayer = ref<string>(playerNames[0]);
22
22
  const playLocal = computed(() => currentPlayer.value == 'Local');
23
23
  const playIndex = ref(-1);
24
+ const itemIndex = ref(0);
24
25
  const playingFeed = ref<IRssFeed|null>(null);
25
26
  const position = ref(0);
26
27
  const positionLength = ref(0);
28
+ const volume = ref(0);
29
+ const paused = ref(false);
27
30
  let statusTimer = 0;
28
31
 
29
32
 
@@ -52,20 +55,21 @@
52
55
  }
53
56
  async function play() {
54
57
  if (playLocal.value) {
55
- audio.value!.src = selected.value.link;
58
+ audio.value!.src = selected.value!.link;
56
59
  audio.value!.load();
57
- await audio.value!.play();
58
- playlistService.log.trace(`play local ${selected.value.title}`)
60
+ audio.value!.play().then(() => {
61
+ playlistService.log.trace(`play local ${selected.value!.title}`)
62
+ });
59
63
  }
60
64
  else {
61
- const rc = await playlistService.play(selected.value.link);
65
+ const rc = await playlistService.play(selected.value!.link);
62
66
  if (!rc)
63
67
  return;
64
68
  await getStatus();
65
- playlistService.log.trace(`play remote ${selected.value.title}`)
69
+ playlistService.log.trace(`play remote ${selected.value!.title}`)
66
70
  }
67
71
  playingFeed.value = selected.value;
68
- playIndex.value = feeds.findIndex((f) => f.link == selected.value.link);
72
+ itemIndex.value = playIndex.value = feeds.findIndex((f) => f.link == selected.value!.link);
69
73
  }
70
74
  function listItem(item: IRssFeed) {
71
75
  selected.value = item;
@@ -75,7 +79,7 @@
75
79
  router.back();
76
80
  }
77
81
  async function getStatus() {
78
- const status = await playlistService.getStatus();
82
+ const status = await playlistService.getState();
79
83
  status.value = status;
80
84
  setPosition(status.position.toNumber());
81
85
  statusTimer = setTimeout(async () => getStatus(), 1000);
@@ -112,11 +116,55 @@
112
116
  }
113
117
  function setPosition(value: number) {
114
118
  position.value = value;
115
- if (playingFeed.value && playingFeed.value.duration > 0)
116
- positionLength.value = position.value * 100 / playingFeed.value.duration;
119
+ if (playingFeed.value!.duration)
120
+ positionLength.value = position.value * 100 / playingFeed.value!.duration;
117
121
  else
118
122
  positionLength.value = 0;
119
123
  }
124
+ function onPlayerChange() {
125
+ if (statusTimer) {
126
+ clearTimeout(statusTimer);
127
+ statusTimer = 0;
128
+ }
129
+ if (!playLocal.value) {
130
+ statusTimer = setTimeout(() => getStatus(), 1000);
131
+ }
132
+ }
133
+ function playpause() {
134
+ if (playLocal.value) {
135
+ if (audio.value!.paused) {
136
+ paused.value = false;
137
+ audio.value!.play()
138
+ .then(() => { console.log("play ended") });
139
+ }
140
+ else {
141
+ paused.value = true;
142
+ audio.value!.pause();
143
+ }
144
+ }
145
+ else {
146
+ if (paused.value) {
147
+ playlistService.playCommand(EPlaylistCommand.Resume);
148
+ }
149
+ else {
150
+ playlistService.playCommand(EPlaylistCommand.Pause);
151
+ }
152
+ }
153
+ }
154
+ function previous() {
155
+ if (playIndex.value <= 0)
156
+ return;
157
+ selected.value = feeds[playIndex.value - 1];
158
+ play();
159
+ }
160
+ function next() {
161
+ if (playIndex.value >= feeds.length - 1)
162
+ return;
163
+ selected.value = feeds[playIndex.value + 1];
164
+ play();
165
+ }
166
+ function changeVolume() {
167
+ }
120
168
 
121
169
  </script>
122
170
 
@@ -126,8 +174,8 @@
126
174
  </audio>
127
175
  <v-list-item lines="three">
128
176
  <v-list-item-content>
129
- <v-list-item-title text-h6>{{selected.title}}</v-list-item-title>
130
- <v-list-item-subtitle>{{toSubTitle(selected)}}</v-list-item-subtitle>
177
+ <v-list-item-title text-h6>{{selected!.title}}</v-list-item-title>
178
+ <v-list-item-subtitle>{{toSubTitle(selected!)}}</v-list-item-subtitle>
131
179
  </v-list-item-content>
132
180
  <template v-slot:append>
133
181
  <v-select v-model="currentPlayer"
@@ -135,28 +183,28 @@
135
183
  persistent-hint
136
184
  @update:modelValue="onPlayerChange"
137
185
  hide-details single-line>
138
- </v-select>
186
+ </v-select>!
139
187
  </template>
140
188
  </v-list-item>
141
189
  <v-card-actions>
142
190
  <v-btn v-if="backVisible" @click="listBack">
143
191
  <v-icon icon="$back" />
144
192
  </v-btn>
145
- <v-btn size="small" v-if="playingTrack" @click="playpause">
193
+ <v-btn size="small" v-if="playingFeed" @click="playpause">
146
194
  <v-icon v-if="paused" icon="$play" />
147
195
  <v-icon v-else icon="$pause" />
148
196
  </v-btn>
149
- <v-btn size="small" v-if="playingTrack" @click="previous">
197
+ <v-btn size="small" v-if="playingFeed" @click="previous">
150
198
  <v-icon icon="$prev" />
151
199
  </v-btn>
152
- <v-btn size="small" v-if="playingTrack" @click="next">
200
+ <v-btn size="small" v-if="playingFeed" @click="next">
153
201
  <v-icon icon="$next" />
154
202
  </v-btn>
155
- <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"
203
+ <v-slider v-if="!playLocal && playingFeed" style="width:30%" color="red" track-color="blue" track-fill-color="red" v-model="volume" hide-details density="compact"
156
204
  min="0" max="100" step="5" @update:modelValue="changeVolume">
157
205
  </v-slider>
158
206
  </v-card-actions>
159
- <v-progress-linear v-if="playingTrack" v-model="positionLength" color="blue" height="25"><strong>{{positionText}}</strong></v-progress-linear>
207
+ <v-progress-linear v-if="playingFeed" v-model="positionLength" color="blue" height="25"><strong>{{positionText}}</strong></v-progress-linear>
160
208
  </v-card>
161
209
  <v-card :height="listHeight" density="compact" class="overflow-y-auto bg-media">
162
210
  <v-list lines="two" class="bg-media">