Clip this in video-player
@munsonlabs/video-player takes one extra HUD button through its action prop: { icon, label, onClick }, with icon as SVG markup. That's all a "Clip this" button needs. The player knows nothing about splice: the editor drives it through its public handle and draws over its picture.
Ask whether this video can be spliced
// Imported late, so Mediabunny isn't in the page bundle.
const { canSplice } = await import('@munsonlabs/splice')
const check = await canSplice(src, { crop: { aspect: '9:16' } })
Offer the action only when it works
const scissors = [
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">',
'<circle cx="6" cy="6" r="3"/>',
'<circle cx="6" cy="18" r="3"/>',
'<path d="M20 4 8.12 15.88M14.47 14.48 20 20M8.12 8.12 12 12"/>',
'</svg>',
].join('')
action.value = check.ok
? {
icon: scissors,
label: 'Clip this',
onClick: () => (open.value = true),
}
: null
Put the editor under the player
Give it the player's handle, and the player's deep-link id in origin.player so the clip's link comes back to this player.
<VideoPlayer ref="player" :src="src" :action="action" deep-link="interview" deep-link-end="loop" />
<SpliceEditor
v-model:open="open"
:player="player"
:source="src"
:origin="{
url: location.href,
title: 'The interview',
publisher: 'Example News',
player: 'interview',
}"
/>
Nested inside the player's slot, the editor finds the player itself and needs neither player nor for.
On a page without Vue, <ml-splice-editor for="interview"> does the same beside <ml-video-player id="interview">, opened with editor.show() from the action.
Let links come back
Turn on deep links on the same player. The clip's metadata and its copied link point at #ml-t=start,end&ml-player=interview, and that player opens there with the range highlighted.
The splice demo app is this recipe, with a switch between an MP4 with WebVTT captions and an HLS stream.