Player hidden.
Sidebar space returned.Preview annotation only
A small spinner while loading. No ad returned? Remove the whole unit and give the sidebar its space back.
PlayerSpace.vue · state presentation + icon railText, Icon, JoyPixels PNGs and existing player controller<script setup>
import { computed } from 'vue'
import Text from '@/components/Text.vue'
import Icon from '@/components/Icon.vue'
const props = defineProps({
state: { type: String, default: 'loading', validator: v => ['loading', 'ready', 'playing', 'paused', 'buffering', 'unavailable'].includes(v) },
concept: { type: String, default: 'ring', validator: v => ['ring', 'emoji', 'dots'].includes(v) },
controls: { type: String, default: 'mute', validator: v => ['mute', 'full'].includes(v) },
muted: { type: Boolean, default: true },
canPause: { type: Boolean, default: false },
isPro: { type: Boolean, default: false },
isWeb: { type: Boolean, default: true }
})
const emit = defineEmits(['play', 'pause', 'resume', 'volume', 'pro'])
const hidden = computed(() => props.isPro || !props.isWeb || (props.state === 'unavailable' && props.concept === 'ring'))
const active = computed(() => ['playing', 'paused', 'buffering'].includes(props.state))
const muteLabel = computed(() => props.muted ? 'Unmute advertisement' : 'Mute advertisement')
const pauseLabel = computed(() => props.state === 'paused' ? 'Resume advertisement' : 'Pause advertisement')
</script>
<template>
<section v-if="!hidden" class="player-space" :data-state="props.state"
:aria-label="props.state === 'unavailable' ? 'EmojiCopy' : 'Advertisement'">
<div v-if="props.state === 'unavailable'" class="player-space__fallback"
:data-kind="props.concept === 'emoji' ? 'tip' : 'pro'">
<template v-if="props.concept === 'emoji'">
<img class="jp-font" src="https://cdn.jsdelivr.net/joypixels/assets/11.0/png/unicode/64/1f4a1.png" alt="" />
<Text type="body/m-heavy" color="text-primary" text="Copy an emoji" />
<Text type="body/s-med" color="text-secondary" text="Click any emoji to copy it." />
</template>
<template v-else>
<Text type="body/m-heavy" color="button-dark-green" text="Your space, ad-free." />
<Text type="body/s-med" color="text-secondary" text="More room for your emoji." />
<button class="player-space__pro" type="button" @click="emit('pro')">
<Text type="body/s-heavy" color="button-dark-green" text="Explore Pro" />
</button>
</template>
</div>
<template v-else>
<!-- Wrapper A is neutral context, not a newly selected wrapper design. -->
<div class="pro-space-prompt" data-variant="quiet">
<button class="pro-space-prompt__action" type="button" @click="emit('pro')">
<Icon class="pro-space-prompt__crown" name="crown-simple" color="var(--c-icon-yellow)" aria-hidden="true" />
<Text type="body/s-heavy" color="text-primary" text="Go Pro to remove ads" />
</button>
</div>
<div class="player-space__viewport">
<!-- Preserve the mounted provider container during pending/playing transitions. -->
<div v-show="active" class="player-space__media" :aria-hidden="!active" :inert="!active">
<slot />
</div>
<div v-if="props.state === 'loading'" class="player-space__pending" role="status">
<Text class="player-space__sr" text="Loading advertisement" />
<span v-if="props.concept === 'ring'" class="player-space__ring" aria-hidden="true" />
<template v-else>
<img v-if="props.concept === 'emoji'" class="player-space__face jp-font"
src="https://cdn.jsdelivr.net/joypixels/assets/11.0/png/unicode/64/1f60a.png" alt="" />
<span class="player-space__dots" aria-hidden="true"><i /><i /><i /></span>
</template>
</div>
<button v-if="props.state === 'ready'" class="player-space__start" type="button"
aria-label="Play advertisement" @click="emit('play')">
<Icon name="play" aria-hidden="true" />
<Text type="body/s-heavy" color="text-primary" text="Play ad" />
</button>
</div>
<div class="player-space__rail">
<div class="player-space__label">
<Text type="body/s-med" color="text-secondary" text="Advertisement" />
<span v-if="props.state === 'buffering'" class="player-space__buffer" role="status">
<Text class="player-space__sr" text="Advertisement buffering" />
<span class="player-space__ring" aria-hidden="true" />
</span>
</div>
<div class="player-space__actions">
<button v-if="props.controls === 'full' && props.canPause" class="player-space__icon"
type="button" :aria-label="pauseLabel" :title="pauseLabel"
:disabled="!['playing', 'paused'].includes(props.state)"
@click="emit(props.state === 'paused' ? 'resume' : 'pause')">
<Icon :name="props.state === 'paused' ? 'play' : 'pause'" aria-hidden="true" />
</button>
<button class="player-space__icon" type="button" :aria-label="muteLabel"
:title="muteLabel" :disabled="!active" @click="emit('volume', props.muted ? 'unmute' : 'mute')">
<Icon :name="props.muted ? 'speaker-slash' : 'speaker-high'" aria-hidden="true" />
</button>
</div>
</div>
</template>
</section>
</template>
<style scoped>
/* All states inherit light/dark color-scheme through semantic tokens. */
/* Sidebar player proposals. Media stays 224 × 126; controls occupy their own 32px rail. */
.player-space { width:224px; max-width:100%; overflow:hidden; border-radius:var(--r-xs); background:var(--c-surface-secondary); }
.player-space[hidden], .player-space [hidden] { display:none !important; }
.player-space__viewport { position:relative; display:grid; place-items:center; width:100%; aspect-ratio:16 / 9; background:var(--c-surface-cta); }
.player-space__media { position:absolute; inset:0; width:100%; height:100%; }
.player-space__pending { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--sp-3); }
.player-space__ring { width:32px; height:32px; border:3px solid var(--c-border-secondary); border-top-color:var(--c-button-dark-green); border-radius:50%; animation:player-space-turn 1.1s linear infinite; }
.player-space__face { width:40px; height:40px; object-fit:contain; animation:player-space-breathe 1.8s ease-in-out infinite; }
.player-space__dots { display:flex; align-items:center; gap:var(--sp-2); }
.player-space__dots i { width:7px; height:7px; border-radius:50%; background:var(--c-button-dark-green); animation:player-space-dot 1.4s ease-in-out infinite; }
.player-space__dots i:nth-child(2) { animation-delay:.16s; }
.player-space__dots i:nth-child(3) { animation-delay:.32s; }
.player-space__sr { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.player-space__rail { display:flex; align-items:center; justify-content:space-between; gap:var(--sp-2); min-height:32px; padding:0 var(--sp-2); background:var(--c-surface-secondary); }
.player-space__actions { display:flex; align-items:center; gap:var(--sp-1); }
.player-space__icon { display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; flex:none; padding:0; border:0; border-radius:var(--r-xs); background:transparent; color:var(--c-text-primary); cursor:pointer; }
.player-space__icon svg, .player-space__icon .icon { display:block; width:18px; height:18px; font-size:18px; }
.player-space__icon:hover { background:var(--c-surface-explore-hover); }
.player-space__icon:disabled { color:var(--c-text-disabled); cursor:default; background:transparent; }
.player-space__icon:focus-visible, .player-space__start:focus-visible, .player-space__pro:focus-visible { outline:2px solid var(--c-button-dark-green); outline-offset:-2px; }
.player-space__start { display:flex; flex-direction:column; align-items:center; gap:var(--sp-2); min-height:44px; padding:var(--sp-2); border:0; border-radius:var(--r-sm); background:transparent; color:var(--c-text-primary); cursor:pointer; }
.player-space__start svg, .player-space__start .icon { width:28px; height:28px; font-size:28px; }
.player-space__fallback { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--sp-2); min-height:126px; box-sizing:border-box; padding:var(--sp-4); text-align:center; background:var(--c-surface-cta); }
.player-space__fallback img { width:28px; height:28px; }
.player-space__fallback[data-kind="pro"] { background:var(--c-surface-highlight); }
.player-space__pro { min-height:28px; padding:0 var(--sp-3); border:1px solid var(--c-button-dark-green); border-radius:var(--r-pill); background:var(--c-surface-secondary); cursor:pointer; }
.player-space__label { display:flex; align-items:center; gap:var(--sp-2); }
.player-space__buffer { display:inline-flex; align-items:center; justify-content:center; }
.player-space__buffer .player-space__ring { width:14px; height:14px; border-width:2px; }
/* Review-only sample creative: never substitute this illustration for a provider ad. */
.player-space__sample { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:var(--sp-2); background:var(--c-surface-tertiary); }
.player-space__sample-row { display:flex; gap:var(--sp-2); align-items:center; }
.player-space__sample img { width:32px; height:32px; animation:player-space-breathe 2.4s ease-in-out infinite; }
.player-space__sample img:nth-child(2) { animation-delay:.2s; }
.player-space__sample img:nth-child(3) { animation-delay:.4s; }
.player-space[data-state="paused"] .player-space__sample img { animation-play-state:paused; }
@keyframes player-space-turn { to { transform:rotate(360deg); } }
@keyframes player-space-breathe { 0%,100% { transform:scale(.94); opacity:.72; } 50% { transform:scale(1); opacity:1; } }
@keyframes player-space-dot { 0%,80%,100% { opacity:.3; } 40% { opacity:1; } }
@media (prefers-reduced-motion:reduce) {
.player-space__ring, .player-space__face, .player-space__dots i, .player-space__sample img { animation:none; }
.player-space__dots i { opacity:.7; }
}
/* ProSpacePrompt: proposal for the 30px strip above existing web slots.
Inherits light/dark color-scheme through semantic surface and text tokens.
Uses the existing crown icon and Text tokens; all header surfaces are neutral. Deliberately named without ad-filter vocabulary. */
.pro-space-prompt {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-2);
width: 100%;
min-height: 30px;
box-sizing: border-box;
padding: 0 var(--sp-2);
border-radius: var(--r-xs) var(--r-xs) 0 0;
background: var(--c-surface-secondary);
}
.pro-space-prompt__action {
appearance: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--sp-1);
min-height: 24px;
flex-shrink: 0;
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
padding: 0 var(--sp-2);
border: 0;
border-radius: var(--r-pill);
background: transparent;
color: var(--c-text-primary);
cursor: pointer;
}
.pro-space-prompt__crown {
display: inline-block;
width: 16px;
height: 16px;
font-size: 16px;
flex: none;
color: var(--c-icon-yellow);
}
.pro-space-prompt__action:hover { text-decoration: underline; }
.pro-space-prompt__action:focus-visible {
outline: 2px solid var(--c-text-primary);
outline-offset: -2px;
}
.pro-space-prompt[data-variant="quiet"] { justify-content: flex-end; }
.pro-space-prompt[data-variant="quiet"] .pro-space-prompt__action {
min-height: 30px;
padding: 0;
}
.pro-space-prompt[data-variant="tint"] {
padding: 0;
}
.pro-space-prompt[data-variant="tint"] .pro-space-prompt__action {
width: 100%;
min-height: 30px;
border-radius: inherit;
}
.pro-space-prompt[data-variant="dark"] {
background: var(--c-surface-tertiary);
}
/* Keep text readable when a user increases font size. The parent shell
must use min-height:120px, not height:120px, for the header slot. */
.pro-space-prompt__message { min-width: 0; }
</style><!-- Presentation-only component inside staging's VideoAd.vue.
Bind these props to the existing controller's confirmed state.
Keep provider requests, consent, scheduling and cleanup in that owner. -->
<PlayerSpace
:state="playerState" concept="ring" controls="mute"
:muted="isMuted" :is-pro="account.isPro" :is-web="isWeb"
:can-pause="false"
@play="startFromUserGesture"
@pause="pauseCurrentAd"
@resume="resumeCurrentAd"
@volume="changeCurrentAdVolume"
@pro="upsell.updateShowPro(true)">
<!-- Move the existing provider video/container here, keeping its refs,
IDs, handlers and SDK-owned children. Do not use the old local stub. -->
</PlayerSpace>
// Imports added to the owning component:
import PlayerSpace from '@/components/Upsell/PlayerSpace.vue'
// useUpsellStore, account, and controller names above are integration bindings,
// not declarations of new stores. Retain the existing production equivalents.
// Add these four names to ui/components/IconIndex.vue.
// The app already uses @phosphor-icons/vue and defineAsyncComponent.
// These names were absent in the local reference; do not assume they ship.
const PhSpeakerSlash = defineAsyncComponent(() => import('@phosphor-icons/vue/dist/icons/PhSpeakerSlash.vue.mjs'))
const PhSpeakerHigh = defineAsyncComponent(() => import('@phosphor-icons/vue/dist/icons/PhSpeakerHigh.vue.mjs'))
const PhPlay = defineAsyncComponent(() => import('@phosphor-icons/vue/dist/icons/PhPlay.vue.mjs'))
const PhPause = defineAsyncComponent(() => import('@phosphor-icons/vue/dist/icons/PhPause.vue.mjs'))
// Append inside the existing icons array:
{ name: 'speaker-slash', comp: PhSpeakerSlash },
{ name: 'speaker-high', comp: PhSpeakerHigh },
{ name: 'play', comp: PhPlay },
{ name: 'pause', comp: PhPause },
/* All states inherit light/dark color-scheme through semantic tokens. */
/* Sidebar player proposals. Media stays 224 × 126; controls occupy their own 32px rail. */
.player-space { width:224px; max-width:100%; overflow:hidden; border-radius:var(--r-xs); background:var(--c-surface-secondary); }
.player-space[hidden], .player-space [hidden] { display:none !important; }
.player-space__viewport { position:relative; display:grid; place-items:center; width:100%; aspect-ratio:16 / 9; background:var(--c-surface-cta); }
.player-space__media { position:absolute; inset:0; width:100%; height:100%; }
.player-space__pending { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--sp-3); }
.player-space__ring { width:32px; height:32px; border:3px solid var(--c-border-secondary); border-top-color:var(--c-button-dark-green); border-radius:50%; animation:player-space-turn 1.1s linear infinite; }
.player-space__face { width:40px; height:40px; object-fit:contain; animation:player-space-breathe 1.8s ease-in-out infinite; }
.player-space__dots { display:flex; align-items:center; gap:var(--sp-2); }
.player-space__dots i { width:7px; height:7px; border-radius:50%; background:var(--c-button-dark-green); animation:player-space-dot 1.4s ease-in-out infinite; }
.player-space__dots i:nth-child(2) { animation-delay:.16s; }
.player-space__dots i:nth-child(3) { animation-delay:.32s; }
.player-space__sr { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.player-space__rail { display:flex; align-items:center; justify-content:space-between; gap:var(--sp-2); min-height:32px; padding:0 var(--sp-2); background:var(--c-surface-secondary); }
.player-space__actions { display:flex; align-items:center; gap:var(--sp-1); }
.player-space__icon { display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; flex:none; padding:0; border:0; border-radius:var(--r-xs); background:transparent; color:var(--c-text-primary); cursor:pointer; }
.player-space__icon svg, .player-space__icon .icon { display:block; width:18px; height:18px; font-size:18px; }
.player-space__icon:hover { background:var(--c-surface-explore-hover); }
.player-space__icon:disabled { color:var(--c-text-disabled); cursor:default; background:transparent; }
.player-space__icon:focus-visible, .player-space__start:focus-visible, .player-space__pro:focus-visible { outline:2px solid var(--c-button-dark-green); outline-offset:-2px; }
.player-space__start { display:flex; flex-direction:column; align-items:center; gap:var(--sp-2); min-height:44px; padding:var(--sp-2); border:0; border-radius:var(--r-sm); background:transparent; color:var(--c-text-primary); cursor:pointer; }
.player-space__start svg, .player-space__start .icon { width:28px; height:28px; font-size:28px; }
.player-space__fallback { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--sp-2); min-height:126px; box-sizing:border-box; padding:var(--sp-4); text-align:center; background:var(--c-surface-cta); }
.player-space__fallback img { width:28px; height:28px; }
.player-space__fallback[data-kind="pro"] { background:var(--c-surface-highlight); }
.player-space__pro { min-height:28px; padding:0 var(--sp-3); border:1px solid var(--c-button-dark-green); border-radius:var(--r-pill); background:var(--c-surface-secondary); cursor:pointer; }
.player-space__label { display:flex; align-items:center; gap:var(--sp-2); }
.player-space__buffer { display:inline-flex; align-items:center; justify-content:center; }
.player-space__buffer .player-space__ring { width:14px; height:14px; border-width:2px; }
/* Review-only sample creative: never substitute this illustration for a provider ad. */
.player-space__sample { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:var(--sp-2); background:var(--c-surface-tertiary); }
.player-space__sample-row { display:flex; gap:var(--sp-2); align-items:center; }
.player-space__sample img { width:32px; height:32px; animation:player-space-breathe 2.4s ease-in-out infinite; }
.player-space__sample img:nth-child(2) { animation-delay:.2s; }
.player-space__sample img:nth-child(3) { animation-delay:.4s; }
.player-space[data-state="paused"] .player-space__sample img { animation-play-state:paused; }
@keyframes player-space-turn { to { transform:rotate(360deg); } }
@keyframes player-space-breathe { 0%,100% { transform:scale(.94); opacity:.72; } 50% { transform:scale(1); opacity:1; } }
@keyframes player-space-dot { 0%,80%,100% { opacity:.3; } 40% { opacity:1; } }
@media (prefers-reduced-motion:reduce) {
.player-space__ring, .player-space__face, .player-space__dots i, .player-space__sample img { animation:none; }
.player-space__dots i { opacity:.7; }
}
/* ProSpacePrompt: proposal for the 30px strip above existing web slots.
Inherits light/dark color-scheme through semantic surface and text tokens.
Uses the existing crown icon and Text tokens; all header surfaces are neutral. Deliberately named without ad-filter vocabulary. */
.pro-space-prompt {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-2);
width: 100%;
min-height: 30px;
box-sizing: border-box;
padding: 0 var(--sp-2);
border-radius: var(--r-xs) var(--r-xs) 0 0;
background: var(--c-surface-secondary);
}
.pro-space-prompt__action {
appearance: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--sp-1);
min-height: 24px;
flex-shrink: 0;
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
padding: 0 var(--sp-2);
border: 0;
border-radius: var(--r-pill);
background: transparent;
color: var(--c-text-primary);
cursor: pointer;
}
.pro-space-prompt__crown {
display: inline-block;
width: 16px;
height: 16px;
font-size: 16px;
flex: none;
color: var(--c-icon-yellow);
}
.pro-space-prompt__action:hover { text-decoration: underline; }
.pro-space-prompt__action:focus-visible {
outline: 2px solid var(--c-text-primary);
outline-offset: -2px;
}
.pro-space-prompt[data-variant="quiet"] { justify-content: flex-end; }
.pro-space-prompt[data-variant="quiet"] .pro-space-prompt__action {
min-height: 30px;
padding: 0;
}
.pro-space-prompt[data-variant="tint"] {
padding: 0;
}
.pro-space-prompt[data-variant="tint"] .pro-space-prompt__action {
width: 100%;
min-height: 30px;
border-radius: inherit;
}
.pro-space-prompt[data-variant="dark"] {
background: var(--c-surface-tertiary);
}
/* Keep text readable when a user increases font size. The parent shell
must use min-height:120px, not height:120px, for the header slot. */
.pro-space-prompt__message { min-width: 0; }
Presentation state is owned by staging's existing player controller. PlayerSpace.vue emits intent; it never requests ads or touches provider DOM. loading An actual ad request is pending. Spinner/dots are indeterminate. ready Autoplay was blocked and a supported user-start path exists. playing SDK confirmed playback started or resumed. paused SDK confirmed pause, not merely a click on the preview control. buffering Playback is stalled; retain media and mute state, show a small loader. unavailable Confirmed no fill, terminal error, or an abandoned loading request. Proposed loading budget: 4 seconds per request, configurable by the owner. This is a UX proposal, not the SDK's timeout or evidence of a no-fill response. On budget expiry, explicitly cancel/retire the current request before fallback. Tag each request with an ID; ignore callbacks from retired or superseded requests. Clear pending timers on ready/started/error/unmount. Dispose listeners/managers before collapsing the provider host or swapping in a first-party fallback. Do not keep showing a spinner after no fill/error. No automatic retry loop. Existing refresh/viewability/consent scheduling remains with the owner. Between ads: keep a neutral, non-clickable frame until a real next request begins; then use loading. When the break ends with nothing queued, use unavailable. For prolonged buffering, use the player's terminal error/watchdog path rather than leaving an indefinite loader. Do not trigger new requests from rendering. Google IMA integration, if that is still staging's playback controller: • play: existing user-gesture start path and adDisplayContainer initialization. • pause/resume: adsManager.pause()/resume(), only when enabled for this slot. • volume: adsManager.getVolume()/setVolume(); save and restore the last nonzero volume. Update the icon from confirmed player state/events, not a guessed flip. • STARTED/RESUMED/PAUSED drive playback UI. VOLUME_CHANGED/VOLUME_MUTED sync audio. • AD_BUFFERING shows buffering; AD_CAN_PLAY is readiness, not proof of playback. • ALL_ADS_COMPLETED ends the break; AD_ERROR ends a failed request. Preserve the failure reason for diagnosis; unavailable is the shared user-facing fallback. Do not mute the underlying content <video> and assume it controls an IMA ad. Do not count loading/fallback as an impression. No invented remaining duration.