Skip to content

Commit e017219

Browse files
committed
add primary support for Media Queue
Signed-off-by: Laurent ARNAL <[email protected]>
1 parent 44053ee commit e017219

File tree

4 files changed

+54
-23
lines changed

4 files changed

+54
-23
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"media.title": "MediaBrowser",
33
"media.page.updated": "Media page updated",
4-
"media.page.created": "Media page created"
4+
"media.page.created": "Media page created",
5+
"media.loading": "Loading..."
56
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"media.title": "MediaBrowser",
33
"media.page.updated": "Media page updated",
4-
"media.page.created": "Media page created"
4+
"media.page.created": "Media page created",
5+
"media.loading": "Loading..."
56
}

bundles/org.openhab.ui/web/src/components/widgets/system/oh-simple-player-controls.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<f7-button color="blue" large icon-material="speaker" icon-size="24" icon-color="gray" @click="openDeviceSelectorPopup" style="vertical-align: middle;display: flex;"/>
1111
<media-device-selector-popup :opened="deviceSelectorPopupOpened" :player-item="currentPlayerItem" @update:opened="deviceSelectorPopupOpened = $event"/>
1212

13+
<f7-button color="blue" large icon-material="queue_music" icon-size="24" icon-color="gray" href="/mediabrowser/?path=/Root/CurrentQueue" style="vertical-align: middle;display: flex;"/>
1314
</f7-segmented>
1415
</div>
1516
</template>

bundles/org.openhab.ui/web/src/pages/media/media-browser.vue

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,50 @@
9898
<br>
9999
</div>
100100
<hr>
101+
</div>
102+
<div v-if="node.pres==='flat'">
101103
<!-- Track list -->
102104
<div v-for="child in items" style="display: inline;clear:both;" :class="{ 'sheet-opened': controlsOpened }" :key="child.path">
103-
<f7-link :href="`/mediabrowser/?path=` + child.path + `&item=` + item + `&device=` + device" :data-reload="true" :reload-current="true" :reload-detail="true">
104-
<f7-button outline style="height:30px;font-weight:bold;padding:2px;padding-left:30px;text-align:left;border:none 0px;" @click="doPlay(currentPlayerItem, child.path)" icon-material="play_arrow" small icon-size="24">
105-
Play
106-
</f7-button>
107-
<f7-button outline style="height:30px;font-weight:bold;padding:2px;padding-left:30px;text-align:left;border:none 0px;" @click="doEnqueue(currentPlayerItem, child.path)" icon-material="playlist_add" small icon-size="24">
108-
Enqueue
109-
</f7-button>
110-
<div style="padding-left:30px;color:black">
111-
{{ child.label }}
112-
</div>
113-
</f7-link>
105+
<f7-link :href="`/mediabrowser/?path=` + child.path + `&item=` + item + `&device=` + device" :data-reload="true" :reload-current="true" :reload-detail="true">
106+
<f7-button outline style="height:30px;font-weight:bold;padding:2px;padding-left:30px;text-align:left;border:none 0px;" @click="doPlay(currentPlayerItem, child.path)" icon-material="play_arrow" small icon-size="24">
107+
Play
108+
</f7-button>
109+
<f7-button outline style="height:30px;font-weight:bold;padding:2px;padding-left:30px;text-align:left;border:none 0px;" @click="doEnqueue(currentPlayerItem, child.path)" icon-material="playlist_add" small icon-size="24">
110+
Enqueue
111+
</f7-button>
112+
<div style="padding-left:30px;color:black">
113+
{{ child.label }}
114+
</div>
115+
</f7-link>
116+
<br>
117+
</div>
118+
<br>
119+
</div>
120+
<div v-else-if="node.pres==='queue'">
121+
<!-- Track list -->
122+
<div v-for="(child,index) in items" style="display: inline;clear:both;" :class="{ 'sheet-opened': controlsOpened }" :key="child.path">
123+
<f7-link :href="`/mediabrowser/?path=` + child.path + `&item=` + item + `&device=` + device" :data-reload="true" :reload-current="true" :reload-detail="true">
124+
<div style="padding-left:30px;width:20px;color:black;font-weight:bold;font-size:14pt;">
125+
{{ index + 1 }}
126+
</div>
127+
128+
<div v-if="index==1" style="width:50px;padding-left:20px;">
129+
<img src="/static/hp.gif" style="padding-left:15px;width:24px;"/>
130+
</div>
131+
<div v-else-if="index!=1" style="width:50px;padding-left:20px;">
132+
<f7-button outline style="height:30px;font-weight:bold;text-align:left;border:none 0px;" @click="doPlay(currentPlayerItem, child.path)" icon-material="play_arrow" small icon-size="24"/>
133+
</div>
134+
135+
<div style="padding-left:30px;width:120px;color:black">
136+
<img :src="child.artUri" width="50px"></img>
137+
</div>
138+
<div style="padding-left:30px;width:400px;color:black">
139+
{{ child.label }}
140+
</div>
141+
<div style="padding-left:30px;width:300px;color:black">
142+
{{ child.complement }}
143+
</div>
144+
</f7-link>
114145
<br>
115146
</div>
116147
<br>
@@ -243,11 +274,6 @@ export default {
243274
}
244275
},
245276
data () {
246-
this.$f7.toast.create({
247-
text: this.$t('media.page.updated'),
248-
destroyOnClose: true,
249-
closeTimeout: 2000
250-
}).open()
251277
252278
this.$store.commit('setMapping', { key: 'Root', value: 'Racine' })
253279
this.$store.commit('setMapping', { key: 'g', value: 'Genres' })
@@ -479,6 +505,7 @@ export default {
479505
this.lastItemIndex = this.items.length
480506
481507
if (this.node.type === 'org.openhab.core.media.model.MediaSearchResult') { this.node.pres = 'search' }
508+
if (this.node.type === 'org.openhab.core.media.model.MediaQueue') { this.node.pres = 'queue' }
482509
if (this.node.type === 'org.openhab.core.media.model.MediaAlbum') { this.node.pres = 'flat' }
483510
if (this.node.type === 'org.openhab.core.media.model.MediaPlayList') { this.node.pres = 'flat' }
484511
if (this.node.type === 'org.openhab.core.media.model.MediaCollection' && this.containsTrack(this.items)) { this.node.pres = 'flat' }
@@ -489,6 +516,12 @@ export default {
489516
this.loadItems(0)
490517
},
491518
loadMore () {
519+
this.$f7.toast.create({
520+
text: this.$t("media.loading"),
521+
destroyOnClose: true,
522+
closeTimeout: 1000
523+
}).open()
524+
492525
if (this.loading || !this.allowInfinite) {
493526
console.log('==> returning because loading or no infinite :' + this.loading + ' / ' + this.allowInfinite)
494527
return
@@ -521,11 +554,6 @@ export default {
521554
async fetchResults (query) {
522555
this.loading = true
523556
try {
524-
//console.log('query:', query.query)
525-
// Remplace cette URL par ton endpoint réel
526-
// const response = await fetch(`https://api.example.com/search?q=${encodeURIComponent(query)}`);
527-
// const data = await response.json();
528-
529557
this.$store.dispatch('sendCommand', { itemName: this.item, cmd: this.createMediaType('SEARCH', encodeURIComponent(query.query)) })
530558
this.$f7router.navigate('/mediabrowser/?path=/Root/Search&query=' + query.query, { reloadCurrent: true, reloadDetail: true })
531559

0 commit comments

Comments
 (0)