How do I loop an audio?

        const connection = joinVoiceChannel({
            channelId: voiceChannel.id,
            guildId: voiceChannel.guild.id,
            adapterCreator: voiceChannel.guild.voiceAdapterCreator,
        })

        let audio = pathName + 'yeay.mp3'

        let player = createAudioPlayer()
        let resource = createAudioResource(audio)

        player.play(resource)
        connection.subscribe(player)

        player.on(AudioPlayerStatus.Idle, () => {

            player.play(resource)

        })
I tried this but without luck. It plays fine the first time, but doesn't loop the audio which is what I want. How can I do that?
The error I am getting is: Error: Cannot play a resource that has already ended.
Was this page helpful?