mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-03 20:20:03 +00:00
This pull request introduces a new audio playback widget for node UIs and integrates it into the node widget system. The main changes include the implementation of the `WidgetAudioUI` component, its registration in the widget registry, and updates to pass node data to the new widget. Additionally, some logging was added for debugging purposes. **Audio Widget Implementation and Integration:** * Added a new `WidgetAudioUI.vue` component that provides audio playback controls (play/pause, progress slider, volume, options) and loads audio files from the server based on node data. * Registered the new `WidgetAudioUI` component in the widget registry by importing it and adding an entry for the `audioUI` type. [[1]](diffhunk://#diff-c2a60954f7fdf638716fa1f83e437774d5250e9c99f3aa83c84a1c0e9cc5769bR21) [[2]](diffhunk://#diff-c2a60954f7fdf638716fa1f83e437774d5250e9c99f3aa83c84a1c0e9cc5769bR112-R115) * Updated `NodeWidgets.vue` to pass `nodeInfo` as the `node-data` prop to widgets of type `audioUI`, enabling the widget to access node-specific audio file information. **Debugging and Logging:** * Added logging of `nodeData` in `LGraphNode.vue` and `WidgetAudioUI.vue` to help with debugging and understanding the data structure. [[1]](diffhunk://#diff-a7744614cf842e54416047326db79ad81f7c7ab7bfb66ae2b46f5c73ac7d47f2R188-R189) [[2]](diffhunk://#diff-71cce190d74c6b5359288857ab9917caededb8cdf1a7e6377578b78aa32be2fcR1-R284) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5627-Vuenodes-audio-widgets-2716d73d365081fbbc06c1e6cf4ebf4d) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Arjan Singh <1598641+arjansingh@users.noreply.github.com> Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Alexander Brown <drjkl@comfy.org> Co-authored-by: Jin Yi <jin12cc@gmail.com> Co-authored-by: DrJKL <DrJKL@users.noreply.github.com> Co-authored-by: Robin Huang <robin.j.huang@gmail.com> Co-authored-by: github-actions <github-actions@github.com>
61 lines
1.6 KiB
Vue
61 lines
1.6 KiB
Vue
<template>
|
|
<div class="w-full">
|
|
<WidgetSelect v-model="modelValue" :widget />
|
|
<div class="my-4">
|
|
<AudioPreviewPlayer
|
|
:audio-url="audioUrlFromWidget"
|
|
:readonly="readonly"
|
|
:hide-when-empty="isOutputNodeRef"
|
|
:show-options-button="true"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
|
|
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
|
import { app } from '@/scripts/app'
|
|
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
|
import { isOutputNode } from '@/utils/nodeFilterUtil'
|
|
|
|
import { getAudioUrlFromPath } from '../utils/audioUtils'
|
|
import WidgetSelect from './WidgetSelect.vue'
|
|
import AudioPreviewPlayer from './audio/AudioPreviewPlayer.vue'
|
|
|
|
const props = defineProps<{
|
|
widget: SimplifiedWidget<string | number | undefined>
|
|
readonly?: boolean
|
|
nodeId: string
|
|
}>()
|
|
|
|
const modelValue = defineModel<string>('modelValue')
|
|
|
|
defineEmits<{
|
|
'update:modelValue': [value: string]
|
|
}>()
|
|
|
|
// Get litegraph node
|
|
const litegraphNode = computed(() => {
|
|
if (!props.nodeId || !app.rootGraph) return null
|
|
return app.rootGraph.getNodeById(props.nodeId) as LGraphNode | null
|
|
})
|
|
|
|
// Check if this is an output node (PreviewAudio, SaveAudio, etc)
|
|
const isOutputNodeRef = computed(() => {
|
|
const node = litegraphNode.value
|
|
if (!node) return false
|
|
return isOutputNode(node)
|
|
})
|
|
|
|
const audioFilePath = computed(() => props.widget.value as string)
|
|
|
|
// Computed audio URL from widget value (for input files)
|
|
const audioUrlFromWidget = computed(() => {
|
|
const path = audioFilePath.value
|
|
if (!path) return ''
|
|
return getAudioUrlFromPath(path, 'input')
|
|
})
|
|
</script>
|