视频播放器Dplayer如何监听切换清晰度
视频播放器Dplayer如何监听切换清晰度
2条回答 默认 最新
关注// 监听playbackratechange事件 const player = new DPlayer({ container: document.getElementById('dplayer'), video: { url: 'https://example.com/path/to/video.mp4', type: 'auto' } }); player.on('playbackratechange', function () { console.log('Switch to new quality'); }); // 监听video:switchQuality事件 const player = new DPlayer({ container: document.getElementById('dplayer'), video: { url: 'https://example.com/path/to/video.mp4', quality: [ { name: '1080P', url: 'https://example.com/path/to/video_1080p.mp4', type: 'normal' }, { name: '720P', url: 'https://example.com/path/to/video_720p.mp4', type: 'normal' }, { name: '480P', url: 'https://example.com/path/to/video_480p.mp4', type: 'normal' } ] } }); player.on('video:switchQuality', function (index) { console.log('Switch to quality ' + index); });本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录