이 페이지에서

미디어 플레이어 예시

Qt Widgets 를 사용하여 오디오 및 비디오 재생하기.

동영상 재생 화면과 제어 패널이 표시된 미디어 플레이어

미디어 플레이어는 다양한 코덱을 사용하여 오디오 및 비디오 파일을 재생할 수 있는 간단한 멀티미디어 플레이어를 보여줍니다.

예제 실행

다음에서 예제를 실행할 수 있습니다.

이 예제는 QMediaPlayer 에 전달된 QVideoWidget 객체를 사용하여 비디오 출력을 제어합니다. 애플리케이션에 재생 목록 기능을 제공하기 위해 QMediaPlaylist 객체도 사용합니다. QMediaPlaylist는 Qt 6에서 API에서 제거되었지만, 이 예제에는 해당 구현이 포함되어 있습니다.

오디오 레벨 미터는 재생 중 피크 및 RMS 레벨을 표시합니다. 이는 QAudioBufferOutput 를 QMediaPlayer 로 설정하고, 해당 객체가 방출하는 각 QAudioBuffer 를 별도의 스레드에서 처리한 뒤, QWidget::paintEvent 를 통해 값을 시각화함으로써 구현됩니다.

대화 상자에서 재생 및 중지 등의 다양한 기능을 활성화하기 위해, 버튼 클릭 이벤트는 play() 및 stop() 신호를 발생시키며, 이 신호들은 QMediaPlayer 의 play() 및 stop() 슬롯에 연결됩니다.

connect(controls, SIGNAL(play()), player, SLOT(play()));
connect(controls, SIGNAL(pause()), player, SLOT(pause()));
connect(controls, SIGNAL(stop()), player, SLOT(stop()));

볼륨을 확인하거나(사용자 인터페이스의 표시를 설정할 수 있으며)

controls->setVolume(player->volume());

위젯의 '볼륨' 값을 변경하면 실제 볼륨도 변경되도록 할 수 있습니다

connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));

또한 이 예제를 통해 QVideoWidget 객체를 이용하여 비디오 속성을 변경할 수도 있습니다. 버튼 한 번 클릭으로 전체 화면 모드로 전환하고, 다시 원래 상태로 돌아갈 수 있습니다.

예제 프로젝트 @ code.qt.io

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.