Skip to content

Commit

Permalink
feat(usesound): improve impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed Dec 28, 2024
1 parent 98482f0 commit 00a62ba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Howl } from 'howler'
import { onMounted, ref, unref, watch } from 'vue-demi'
import type { ComposableOptions, HowlStatic, MaybeRef, PlayFunction, PlayOptions, ReturnedValue } from './types'
import { onMounted, ref, unref, watch } from 'vue-demi'

export type {
ComposableOptions
ComposableOptions,
}

export function useSound(
Expand All @@ -15,9 +15,8 @@ export function useSound(
const duration = ref<number | null>(null)
const sound = ref<Howl | null>(null)

function handleLoad() {
// @ts-expect-error - ?
if (typeof onload === 'function') onload.call(this as any)
function handleLoad(this: Howl, soundId: number) {
if (typeof onload === 'function') onload.call(this, soundId)
duration.value = (duration.value || sound.value?.duration() || 0) * 1000

if (autoplay === true) {
Expand Down

0 comments on commit 00a62ba

Please sign in to comment.