Skip to content
The Chat Archive
gpt-4-0314· OpenAI WildChat-4.8M (AI2)

کد یک صفحه پخش آهنگ با قابلیت زدن آهنگ قبلی و بعدی مانند اسپاتیفای

  1. User

    کد یک صفحه پخش آهنگ با قابلیت زدن آهنگ قبلی و بعدی مانند اسپاتیفای

  2. Assistant
    <script>
        const player = document.getElementById('player');
        const audioSource = document.getElementById('audioSource');
        const prevButton = document.getElementById('prev');
        const nextButton = document.getElementById('next');
    
        let playlist = [
            'song1.mp3',
            'song2.mp3',
            'song3.mp3'
        ];
    
        let currentIndex = 0;
    
        prevButton.addEventListener('click', () => {
            currentIndex--;
            if (currentIndex < 0) {
                currentIndex = playlist.length - 1;
            }
            playSong();
        });
    
        nextButton.addEventListener('click', () => {
            currentIndex++;
            if (currentIndex > playlist.length - 1) {
                currentIndex = 0;
            }
            playSong();
        });
    
        function playSong() {
            audioSource.src = playlist[currentIndex];
            player.load();
            player.play();
        }
    </script>
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.