Skip to content

Commit 7a38890

Browse files
committed
fix media device selector
Signed-off-by: Laurent ARNAL <[email protected]>
1 parent 84ae26e commit 7a38890

File tree

7 files changed

+62
-44
lines changed

7 files changed

+62
-44
lines changed

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,8 @@
5454
icon-color="gray"
5555
@click="openDeviceSelectorPopup"/>
5656

57-
58-
<!--
59-
<media-device-popup :opened="deviceSelectorPopupOpened" :player-item="config.item" @update:opened=""/>
60-
<media-popup :opened="browserPopupOpened" :player-item="config.item" @update:opened=""/>
61-
62-
63-
-->
64-
65-
<!--
66-
browserPopupOpened = $event
67-
deviceSelectorPopupOpened = $event
68-
-->
57+
<media-popup :opened="browserPopupOpened" :player-item="config.item" @update:opened="browserPopupOpened = $event"/>
58+
<media-device-popup :opened="deviceSelectorPopupOpened" :player-item="config.item" @update:opened="deviceSelectorPopupOpened = $event"/>
6959
</f7-segmented>
7060
</div>
7161

@@ -165,7 +155,7 @@ export default {
165155
useStatesStore().sendCommand(this.config.item, 'NEXT')
166156
},
167157
mediaChange (value) {
168-
// this.$store.dispatch('sendCommand', { itemName: this.config.item, cmd: 'spotify:playlist:5Z4AD0u9fwnvtsj7ce5ZLS' }
158+
//useStatesStore().sendCommand(this.config.item, 'spotify:playlist:5Z4AD0u9fwnvtsj7ce5ZLS')
169159
}
170160
}
171161
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<f7-button color="blue" @click.stop="skipNext()" large icon-material="skip_next" icon-size="24" icon-color="gray" style="vertical-align: middle;display: flex;"/>
99

1010
<f7-button color="blue" large icon-material="speaker" icon-size="24" icon-color="gray" @click="openDeviceSelectorPopup" style="vertical-align: middle;display: flex;"/>
11-
<media-device-selector-popup :opened="deviceSelectorPopupOpened" :player-item="currentPlayerItem" @update:opened="deviceSelectorPopupOpened = $event"/>
11+
<media-device-selector-popup :opened="deviceSelectorPopupOpened" :player-item="currentPlayerItem" @update:opened="deviceSelectorPopupOpened = $event" :f7route="f7route" :f7router="f7router"/>
1212

1313
<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;"/>
1414
</f7-segmented>
@@ -36,6 +36,10 @@ import { useComponentsStore } from '@/js/stores/useComponentsStore'
3636
3737
export default {
3838
mixins: [mixin],
39+
props: {
40+
f7route: Object,
41+
f7router: Object
42+
},
3943
widget: OhPlayerDefinition,
4044
watch: {
4145
'useMediaStore().currentGlobalPlayerItem'(newVal) {

bundles/org.openhab.ui/web/src/js/routes.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import PageViewPage from '../pages/page/page-view.vue'
66
import AnalyzerPopup from '../pages/analyzer/analyzer-popup.vue'
77
import MediaPopup from '../pages/media/media-browser-popup.vue'
88
import MediaBrowser from '../pages/media/media-browser.vue'
9-
//import MediaDeviceSelectorPopup from '../pages/media/media-device-selector-popup.vue'
10-
//import MediaDeviceSelector from '../pages/media/media-device-selector.vue'
9+
import MediaDeviceSelectorPopup from '../pages/media/media-device-selector-popup.vue'
10+
import MediaDeviceSelector from '../pages/media/media-device-selector.vue'
1111
import { AddonTitles } from '@/assets/addon-store'
1212

1313
const AboutPage = () => import(/* webpackChunkName: "about-page" */ '@/pages/about.vue')
@@ -566,23 +566,18 @@ export default [
566566
animate: false,
567567
}
568568
},
569-
/*
570569
{
571-
path: '/mediadeviceselectorpopup/',
570+
path: '/mediadeviceselector/',
572571
popup: {
573-
component: MediaDeviceSelectorPopup
572+
component: MediaDeviceSelector
574573
}
575574
},
576-
*/
577-
/*
578575
{
579-
path: '/mediadeviceselector/',
580-
component: MediaDeviceSelector,
581-
options: {
582-
transition: 'f7-dive',
583-
animate: false,
576+
path: '/mediadeviceselectorpopup/',
577+
popup: {
578+
component: MediaDeviceSelectorPopup
584579
}
585-
},*/
580+
},
586581
{
587582
path: '(.*)',
588583
component: NotFoundPage

bundles/org.openhab.ui/web/src/js/stores/useMediaStore.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,4 @@ export const useMediaStore = defineStore('media', {
5151
}
5252
}
5353
}
54-
5554
})

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@
198198
-->
199199
<div>
200200
<div style="width:300px;padding:20px;padding-left: 140px;">
201-
202-
<oh-simple-player-controls />
201+
<oh-simple-player-controls :f7route="f7route" :f7router="f7router"/>
203202
</div>
204203
</div>
205204
<!--

bundles/org.openhab.ui/web/src/pages/media/media-device-selector-popup.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:closeByBackdropClick="true" class="popup">
44
<f7-view class="view-sheet-modal" url="/mediadeviceselector/" :animate="false">
55
<f7-page>
6-
<media-device-selector @navigate="$emit('navigate', $event)" :player-item="playerItem" />
6+
<media-device-selector @navigate="$emit('navigate', $event)" :player-item="playerItem" :f7route="f7route" :f7router="f7router"/>
77
</f7-page>
88
</f7-view>
99
</f7-popup>
@@ -25,7 +25,9 @@ export default {
2525
playerItem: {
2626
type: String,
2727
required: false
28-
}
28+
},
29+
f7route: Object,
30+
f7router: Object
2931
},
3032
methods: {
3133
}

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

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
<!--
1212
currentPlayerItem: {{ currentPlayerItem }}
13-
-->
13+
-->
14+
1415
<div v-if="node">
1516
<f7-list form>
1617
<f7-list-item v-for="item in node.childs"
@@ -33,41 +34,69 @@
3334
</template>
3435

3536
<script>
37+
import { ref, onMounted, getCurrentInstance, computed } from 'vue'
38+
import { useStatesStore } from '@/js/stores/useStatesStore'
39+
import { useComponentsStore } from '@/js/stores/useComponentsStore'
40+
import { useMediaStore } from '@/js/stores/useMediaStore'
41+
42+
3643
export default {
37-
name: 'MediaBrowser',
44+
name: 'MediaDeviceSelector',
3845
props:
3946
{
47+
f7route: Object,
48+
f7router: Object,
4049
playerItem: {
4150
type: String,
4251
required: false
4352
}
4453
},
54+
setup(props) {
55+
const path = ref('');
56+
const query = ref('');
57+
58+
const { proxy } = getCurrentInstance(); // pour accéder à this.$f7route, this.$f7, etc.
59+
60+
onMounted(() => {
61+
const route = props.f7route;
62+
console.log('f7route1:', route);
63+
console.log('f7route2:', route.query);
64+
console.log('f7route3:', route.query?.path);
65+
66+
if (route.query?.path && !route.query.path.startsWith('/page/')) {
67+
path.value = route.query.path;
68+
}
69+
70+
if (route.query?.query) {
71+
query.value = route.query.query;
72+
}
73+
});
74+
75+
return { path, query };
76+
},
4577
data () {
4678
let currentPlayerItem = this.playerItem
4779
console.log("p0:" + currentPlayerItem);
4880
4981
5082
if (currentPlayerItem === undefined || currentPlayerItem === null || currentPlayerItem === '') {
5183
console.log("p1");
52-
currentPlayerItem = this.$store.state.media.playerItem
84+
currentPlayerItem = useMediaStore().playerItem
5385
}
5486
console.log("p2");
5587
if (currentPlayerItem === undefined || currentPlayerItem === null || currentPlayerItem === '') {
5688
console.log("p3");
57-
currentPlayerItem = this.$store.state.media.currentGlobalPlayerItem
89+
currentPlayerItem = useMediaStore().currentGlobalPlayerItem
5890
}
91+
5992
60-
this.$store.commit('setPlayerItem', currentPlayerItem)
61-
93+
useMediaStore().setCurrentGlobalPlayerItem(currentPlayerItem)
94+
6295
this.path = '/Root'
6396
64-
if (this.$f7route.query.path && !this.$f7route.query.path.startsWith('/page/')) {
65-
this.path = this.$f7route.query.path
66-
}
67-
6897
console.log('MediaBrowser path: ' + this.path)
69-
7098
let selectedOption= ""
99+
71100
this.$oh.api.get('/rest/media/sinks').then((data) => {
72101
data.childs = data.childs.sort((a, b) => {
73102
if (a.binding < b.binding) return -1
@@ -92,7 +121,7 @@ export default {
92121
93122
this.node = data
94123
})
95-
124+
96125
return {
97126
currentPlayerItem: currentPlayerItem,
98127
node: this.node,

0 commit comments

Comments
 (0)