summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt7
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/multimedia/CMakeLists.txt19
-rw-r--r--examples/multimedia/audiodecoder/CMakeLists.txt42
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.cpp213
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.h103
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.pro13
-rw-r--r--examples/multimedia/audiodecoder/main.cpp129
-rw-r--r--examples/multimedia/audiodevices/CMakeLists.txt3
-rw-r--r--examples/multimedia/audiodevices/audiodevices.cpp144
-rw-r--r--examples/multimedia/audiodevices/audiodevices.h62
-rw-r--r--examples/multimedia/audiodevices/doc/src/audiodevices.qdoc32
-rw-r--r--examples/multimedia/audiodevices/main.cpp55
-rw-r--r--examples/multimedia/audiooutput/CMakeLists.txt3
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp92
-rw-r--r--examples/multimedia/audiooutput/audiooutput.h59
-rw-r--r--examples/multimedia/audiooutput/doc/src/audiooutput.qdoc32
-rw-r--r--examples/multimedia/audiooutput/main.cpp55
-rw-r--r--examples/multimedia/audiorecorder/CMakeLists.txt3
-rw-r--r--examples/multimedia/audiorecorder/audiolevel.cpp56
-rw-r--r--examples/multimedia/audiorecorder/audiolevel.h53
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.cpp218
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.h66
-rw-r--r--examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc32
-rw-r--r--examples/multimedia/audiorecorder/main.cpp53
-rw-r--r--examples/multimedia/audiosource/CMakeLists.txt4
-rw-r--r--examples/multimedia/audiosource/Info.plist.in44
-rw-r--r--examples/multimedia/audiosource/audioinput.pro13
-rw-r--r--examples/multimedia/audiosource/audiosource.cpp154
-rw-r--r--examples/multimedia/audiosource/audiosource.h55
-rw-r--r--examples/multimedia/audiosource/audiosource.pro13
-rw-r--r--examples/multimedia/audiosource/doc/src/audiosource.qdoc32
-rw-r--r--examples/multimedia/audiosource/main.cpp53
-rw-r--r--examples/multimedia/camera/CMakeLists.txt (renamed from examples/multimediawidgets/camera/CMakeLists.txt)5
-rw-r--r--examples/multimedia/camera/android/AndroidManifest.xml39
-rw-r--r--examples/multimedia/camera/camera.cpp (renamed from examples/multimediawidgets/camera/camera.cpp)227
-rw-r--r--examples/multimedia/camera/camera.h104
-rw-r--r--examples/multimedia/camera/camera.pro (renamed from examples/multimediawidgets/camera/camera.pro)2
-rw-r--r--examples/multimedia/camera/camera.qrc (renamed from examples/multimediawidgets/camera/camera.qrc)0
-rw-r--r--examples/multimedia/camera/camera.ui (renamed from examples/multimediawidgets/camera/camera.ui)0
-rw-r--r--examples/multimedia/camera/camera_mobile.ui (renamed from examples/multimediawidgets/camera/camera_mobile.ui)0
-rw-r--r--examples/multimedia/camera/doc/images/camera-example.pngbin0 -> 151290 bytes
-rw-r--r--examples/multimedia/camera/doc/src/camera.qdoc92
-rw-r--r--examples/multimedia/camera/images/shutter.svg (renamed from examples/multimediawidgets/camera/images/shutter.svg)0
-rw-r--r--examples/multimedia/camera/imagesettings.cpp84
-rw-r--r--examples/multimedia/camera/imagesettings.h41
-rw-r--r--examples/multimedia/camera/imagesettings.ui (renamed from examples/multimediawidgets/camera/imagesettings.ui)0
-rw-r--r--examples/multimedia/camera/ios/Info.plist.in (renamed from examples/multimediawidgets/camera/ios/Info.plist.in)0
-rw-r--r--examples/multimedia/camera/macos/Info.plist.in (renamed from examples/multimediawidgets/camera/macos/Info.plist.in)0
-rw-r--r--examples/multimedia/camera/main.cpp16
-rw-r--r--examples/multimedia/camera/metadatadialog.cpp107
-rw-r--r--examples/multimedia/camera/metadatadialog.h31
-rw-r--r--examples/multimedia/camera/videosettings.cpp196
-rw-r--r--examples/multimedia/camera/videosettings.h42
-rw-r--r--examples/multimedia/camera/videosettings.ui (renamed from examples/multimediawidgets/camera/videosettings.ui)0
-rw-r--r--examples/multimedia/camera/videosettings_mobile.ui (renamed from examples/multimediawidgets/camera/videosettings_mobile.ui)0
-rw-r--r--examples/multimedia/declarative-camera/CMakeLists.txt4
-rw-r--r--examples/multimedia/declarative-camera/CameraButton.qml51
-rw-r--r--examples/multimedia/declarative-camera/CameraListButton.qml68
-rw-r--r--examples/multimedia/declarative-camera/CameraListPopup.qml69
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyButton.qml69
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyPopup.qml69
-rw-r--r--examples/multimedia/declarative-camera/FlashControl.qml65
-rw-r--r--examples/multimedia/declarative-camera/Info.plist2
-rw-r--r--examples/multimedia/declarative-camera/PhotoCaptureControls.qml200
-rw-r--r--examples/multimedia/declarative-camera/PhotoPreview.qml52
-rw-r--r--examples/multimedia/declarative-camera/Popup.qml55
-rw-r--r--examples/multimedia/declarative-camera/VideoCaptureControls.qml220
-rw-r--r--examples/multimedia/declarative-camera/VideoPreview.qml53
-rw-r--r--examples/multimedia/declarative-camera/ZoomControl.qml54
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qml114
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qrc1
-rw-r--r--examples/multimedia/declarative-camera/doc/images/CaptureControls.pngbin0 -> 41278 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/FlashControls.pngbin0 -> 69725 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.pngbin0 -> 35913 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/ZoomControl.pngbin0 -> 28291 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-camera.pngbin28409 -> 51620 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.pngbin0 -> 49057 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc183
-rw-r--r--examples/multimedia/declarative-camera/permission-denied.qml20
-rw-r--r--examples/multimedia/declarative-camera/qmlcamera.cpp89
-rw-r--r--examples/multimedia/devices/CMakeLists.txt33
-rw-r--r--examples/multimedia/devices/main.cpp183
-rw-r--r--examples/multimedia/multimedia.pro13
-rw-r--r--examples/multimedia/player/CMakeLists.txt (renamed from examples/multimediawidgets/player/CMakeLists.txt)10
-rw-r--r--examples/multimedia/player/doc/images/mediaplayerex.jpg (renamed from examples/multimediawidgets/player/doc/images/mediaplayerex.jpg)bin28825 -> 28825 bytes
-rw-r--r--examples/multimedia/player/doc/src/player.qdoc (renamed from examples/multimediawidgets/player/doc/src/player.qdoc)31
-rw-r--r--examples/multimedia/player/main.cpp37
-rw-r--r--examples/multimedia/player/player.cpp (renamed from examples/multimediawidgets/player/player.cpp)214
-rw-r--r--examples/multimedia/player/player.h105
-rw-r--r--examples/multimedia/player/player.pro (renamed from examples/multimediawidgets/player/player.pro)5
-rw-r--r--examples/multimedia/player/playercontrols.cpp185
-rw-r--r--examples/multimedia/player/playercontrols.h64
-rw-r--r--examples/multimedia/player/playlistmodel.cpp105
-rw-r--r--examples/multimedia/player/playlistmodel.h50
-rw-r--r--examples/multimedia/player/qmediaplaylist.cpp (renamed from examples/multimediawidgets/player/qmediaplaylist.cpp)88
-rw-r--r--examples/multimedia/player/qmediaplaylist.h (renamed from examples/multimediawidgets/player/qmediaplaylist.h)57
-rw-r--r--examples/multimedia/player/qmediaplaylist_p.cpp65
-rw-r--r--examples/multimedia/player/qmediaplaylist_p.h66
-rw-r--r--examples/multimedia/player/qplaylistfileparser.cpp (renamed from examples/multimediawidgets/player/qplaylistfileparser.cpp)250
-rw-r--r--examples/multimedia/player/qplaylistfileparser.h76
-rw-r--r--examples/multimedia/player/videowidget.cpp46
-rw-r--r--examples/multimedia/player/videowidget.h22
-rw-r--r--examples/multimedia/screencapture/CMakeLists.txt50
-rw-r--r--examples/multimedia/screencapture/Info.plist.in41
-rw-r--r--examples/multimedia/screencapture/doc/images/screencapture.jpgbin0 -> 42725 bytes
-rw-r--r--examples/multimedia/screencapture/doc/src/screencapture.qdoc48
-rw-r--r--examples/multimedia/screencapture/main.cpp14
-rw-r--r--examples/multimedia/screencapture/screencapture.pro18
-rw-r--r--examples/multimedia/screencapture/screencapturepreview.cpp179
-rw-r--r--examples/multimedia/screencapture/screencapturepreview.h67
-rw-r--r--examples/multimedia/screencapture/screenlistmodel.cpp54
-rw-r--r--examples/multimedia/screencapture/screenlistmodel.h30
-rw-r--r--examples/multimedia/screencapture/windowlistmodel.cpp42
-rw-r--r--examples/multimedia/screencapture/windowlistmodel.h31
-rw-r--r--examples/multimedia/shared/shared.pri4
-rw-r--r--examples/multimedia/spatialaudio/doc/src/spatialaudio.qdoc51
-rw-r--r--examples/multimedia/spatialaudio/main.cpp208
-rw-r--r--examples/multimedia/spectrum/CMakeLists.txt4
-rw-r--r--examples/multimedia/spectrum/Info.plist.in43
-rw-r--r--examples/multimedia/spectrum/app.pro3
-rw-r--r--examples/multimedia/spectrum/doc/src/spectrum.qdoc31
-rw-r--r--examples/multimedia/spectrum/engine.cpp329
-rw-r--r--examples/multimedia/spectrum/engine.h140
-rw-r--r--examples/multimedia/spectrum/frequencyspectrum.cpp59
-rw-r--r--examples/multimedia/spectrum/frequencyspectrum.h67
-rw-r--r--examples/multimedia/spectrum/levelmeter.cpp83
-rw-r--r--examples/multimedia/spectrum/levelmeter.h54
-rw-r--r--examples/multimedia/spectrum/main.cpp52
-rw-r--r--examples/multimedia/spectrum/mainwidget.cpp213
-rw-r--r--examples/multimedia/spectrum/mainwidget.h120
-rw-r--r--examples/multimedia/spectrum/progressbar.cpp66
-rw-r--r--examples/multimedia/spectrum/progressbar.h53
-rw-r--r--examples/multimedia/spectrum/settingsdialog.cpp99
-rw-r--r--examples/multimedia/spectrum/settingsdialog.h59
-rw-r--r--examples/multimedia/spectrum/spectrograph.cpp91
-rw-r--r--examples/multimedia/spectrum/spectrograph.h72
-rw-r--r--examples/multimedia/spectrum/spectrum.h102
-rw-r--r--examples/multimedia/spectrum/spectrumanalyser.cpp150
-rw-r--r--examples/multimedia/spectrum/spectrumanalyser.h113
-rw-r--r--examples/multimedia/spectrum/tonegenerator.cpp60
-rw-r--r--examples/multimedia/spectrum/tonegenerator.h55
-rw-r--r--examples/multimedia/spectrum/tonegeneratordialog.cpp94
-rw-r--r--examples/multimedia/spectrum/tonegeneratordialog.h55
-rw-r--r--examples/multimedia/spectrum/utils.cpp69
-rw-r--r--examples/multimedia/spectrum/utils.h94
-rw-r--r--examples/multimedia/spectrum/waveform.cpp179
-rw-r--r--examples/multimedia/spectrum/waveform.h97
-rw-r--r--examples/multimedia/video/CMakeLists.txt3
-rw-r--r--examples/multimedia/video/mediaplayer/AudioControl.qml92
-rw-r--r--examples/multimedia/video/mediaplayer/CMakeLists.txt60
-rw-r--r--examples/multimedia/video/mediaplayer/Main.qml178
-rw-r--r--examples/multimedia/video/mediaplayer/MetadataInfo.qml116
-rw-r--r--examples/multimedia/video/mediaplayer/PlaybackControl.qml197
-rw-r--r--examples/multimedia/video/mediaplayer/PlaybackRateControl.qml80
-rw-r--r--examples/multimedia/video/mediaplayer/PlaybackSeekControl.qml89
-rw-r--r--examples/multimedia/video/mediaplayer/PlayerMenuBar.qml171
-rw-r--r--examples/multimedia/video/mediaplayer/TracksInfo.qml122
-rw-r--r--examples/multimedia/video/mediaplayer/controls/AudioControl.qml50
-rw-r--r--examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml30
-rw-r--r--examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml317
-rw-r--r--examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml56
-rw-r--r--examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml204
-rw-r--r--examples/multimedia/video/mediaplayer/controls/TracksInfo.qml25
-rw-r--r--examples/multimedia/video/mediaplayer/controls/UrlPopup.qml54
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/OqosZsDqvzQ.jpgbin181335 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/PlayerMenuBar.gifbin65177 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/architecture-overview.gifbin222405 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/audio-control.gifbin150039 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/mediaplayer.pngbin0 -> 49506 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/meta-data.pngbin66670 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/nHrBbW0H-pc.jpgbin84480 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/play-pause-stop.gifbin188432 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/playbackControlPanel.gifbin179494 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/qmlmediaplayer.jpgbin67156 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/settings.pngbin0 -> 33705 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/sf_yv01UtIw.jpgbin96819 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/url.pngbin68983 -> 0 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/qmlmediaplayer.qdocconf7
-rw-r--r--examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc325
-rw-r--r--examples/multimedia/video/mediaplayer/images/backward10.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/ff.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/forward10.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/link.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/loop.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/more.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/mute.svg (renamed from examples/multimedia/video/mediaplayer/Mute_Icon.svg)0
-rw-r--r--examples/multimedia/video/mediaplayer/images/open_new.svg6
-rw-r--r--examples/multimedia/video/mediaplayer/images/pause_symbol.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/play_symbol.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/rewind.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/settings.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/speaker.svg (renamed from examples/multimedia/video/mediaplayer/Speaker_Icon.svg)0
-rw-r--r--examples/multimedia/video/mediaplayer/images/stop_symbol.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/url.svg6
-rw-r--r--examples/multimedia/video/mediaplayer/images/volume.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/volume_mute.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/zoom_maximize.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/zoom_minimize.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/main.cpp68
-rw-r--r--examples/multimedia/video/mediaplayer/main.qml200
-rw-r--r--examples/multimedia/video/qmlvideo/CMakeLists.txt96
-rw-r--r--examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg (renamed from examples/multimedia/video/doc/images/qmlvideo-menu.jpg)bin21959 -> 21959 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg (renamed from examples/multimedia/video/doc/images/qmlvideo-overlay.jpg)bin23787 -> 23787 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc (renamed from examples/multimedia/video/doc/src/qmlvideo.qdoc)50
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor.cpp108
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor.h62
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt30
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml67
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/qmldir3
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp53
-rw-r--r--examples/multimedia/video/qmlvideo/main.cpp126
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor.cpp51
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor.h60
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt31
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml100
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/qmldir3
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp60
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitordeclarative.h55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml114
-rw-r--r--examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml150
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml90
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml78
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml94
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml165
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml118
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml419
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml83
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml94
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml112
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml117
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml96
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml130
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml88
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml109
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml151
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml84
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml95
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml89
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml137
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml115
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml285
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo.pro119
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt81
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml31
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml47
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Content.qml125
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml70
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Main.qml188
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml31
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml47
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml34
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml67
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml70
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml49
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml (renamed from examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml)106
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml83
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml41
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml57
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml88
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml34
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml (renamed from examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml)69
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml37
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml49
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml42
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml80
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml65
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml36
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png (renamed from examples/multimedia/video/qmlvideo/images/folder.png)bin1829 -> 1829 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg (renamed from examples/multimedia/video/qmlvideo/images/leaves.jpg)bin257378 -> 257378 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/up.png (renamed from examples/multimedia/video/qmlvideo/images/up.png)bin1268 -> 1268 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/qmldir44
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h10
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp54
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h48
-rw-r--r--examples/multimedia/video/qmlvideo/trace.h100
-rw-r--r--examples/multimedia/video/recorder/AudioInputSelect.qml81
-rw-r--r--examples/multimedia/video/recorder/CMakeLists.txt6
-rw-r--r--examples/multimedia/video/recorder/CameraSelect.qml85
-rw-r--r--examples/multimedia/video/recorder/Controls.qml66
-rw-r--r--examples/multimedia/video/recorder/MediaList.qml51
-rw-r--r--examples/multimedia/video/recorder/Playback.qml51
-rw-r--r--examples/multimedia/video/recorder/RecordButton.qml51
-rw-r--r--examples/multimedia/video/recorder/SettingsEncoder.qml56
-rw-r--r--examples/multimedia/video/recorder/SettingsMetaData.qml71
-rw-r--r--examples/multimedia/video/recorder/Style.qml51
-rw-r--r--examples/multimedia/video/recorder/StyleParameter.qml53
-rw-r--r--examples/multimedia/video/recorder/StyleRectangle.qml51
-rw-r--r--examples/multimedia/video/recorder/StyleSlider.qml53
-rw-r--r--examples/multimedia/video/recorder/VideoSourceSelect.qml165
-rw-r--r--examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gifbin0 -> 111693 bytes
-rw-r--r--examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gifbin0 -> 138905 bytes
-rw-r--r--examples/multimedia/video/recorder/doc/src/recorder.qdoc118
-rw-r--r--examples/multimedia/video/recorder/main.cpp91
-rw-r--r--examples/multimedia/video/recorder/main.qml59
-rw-r--r--examples/multimedia/video/recorder/main_no_permissions.qml26
-rw-r--r--examples/multimedia/videographicsitem/CMakeLists.txt (renamed from examples/multimediawidgets/videographicsitem/CMakeLists.txt)5
-rw-r--r--examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png (renamed from examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png)bin54436 -> 54436 bytes
-rw-r--r--examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc20
-rw-r--r--examples/multimedia/videographicsitem/main.cpp37
-rw-r--r--examples/multimedia/videographicsitem/videographicsitem.pro (renamed from examples/multimediawidgets/videographicsitem/videographicsitem.pro)2
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.cpp (renamed from examples/multimediawidgets/videographicsitem/videoplayer.cpp)96
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.h47
-rw-r--r--examples/multimedia/videowidget/CMakeLists.txt (renamed from examples/multimediawidgets/videowidget/CMakeLists.txt)5
-rw-r--r--examples/multimedia/videowidget/doc/images/video-videowidget.png (renamed from examples/multimediawidgets/videowidget/doc/images/video-videowidget.png)bin54199 -> 54199 bytes
-rw-r--r--examples/multimedia/videowidget/doc/src/videowidget.qdoc18
-rw-r--r--examples/multimedia/videowidget/main.cpp40
-rw-r--r--examples/multimedia/videowidget/videoplayer.cpp (renamed from examples/multimediawidgets/videowidget/videoplayer.cpp)90
-rw-r--r--examples/multimedia/videowidget/videoplayer.h44
-rw-r--r--examples/multimedia/videowidget/videowidget.pro (renamed from examples/multimediawidgets/videowidget/videowidget.pro)2
-rw-r--r--examples/multimediawidgets/CMakeLists.txt6
-rw-r--r--examples/multimediawidgets/camera/android/AndroidManifest.xml68
-rw-r--r--examples/multimediawidgets/camera/camera.h148
-rw-r--r--examples/multimediawidgets/camera/doc/images/camera-example.pngbin13647 -> 0 bytes
-rw-r--r--examples/multimediawidgets/camera/doc/src/camera.qdoc82
-rw-r--r--examples/multimediawidgets/camera/imagesettings.cpp130
-rw-r--r--examples/multimediawidgets/camera/imagesettings.h86
-rw-r--r--examples/multimediawidgets/camera/main.cpp63
-rw-r--r--examples/multimediawidgets/camera/metadatadialog.cpp127
-rw-r--r--examples/multimediawidgets/camera/metadatadialog.h78
-rw-r--r--examples/multimediawidgets/camera/videosettings.cpp248
-rw-r--r--examples/multimediawidgets/camera/videosettings.h85
-rw-r--r--examples/multimediawidgets/multimediawidgets.pro10
-rw-r--r--examples/multimediawidgets/player/main.cpp84
-rw-r--r--examples/multimediawidgets/player/player.h146
-rw-r--r--examples/multimediawidgets/player/playercontrols.cpp219
-rw-r--r--examples/multimediawidgets/player/playercontrols.h109
-rw-r--r--examples/multimediawidgets/player/playlistmodel.cpp149
-rw-r--r--examples/multimediawidgets/player/playlistmodel.h99
-rw-r--r--examples/multimediawidgets/player/qmediaplaylist_p.h148
-rw-r--r--examples/multimediawidgets/player/qplaylistfileparser_p.h116
-rw-r--r--examples/multimediawidgets/player/videowidget.cpp93
-rw-r--r--examples/multimediawidgets/player/videowidget.h69
-rw-r--r--examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc43
-rw-r--r--examples/multimediawidgets/videographicsitem/main.cpp86
-rw-r--r--examples/multimediawidgets/videographicsitem/videoplayer.h95
-rw-r--r--examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc41
-rw-r--r--examples/multimediawidgets/videowidget/main.cpp88
-rw-r--r--examples/multimediawidgets/videowidget/videoplayer.h91
-rw-r--r--examples/spatialaudio/CMakeLists.txt1
-rw-r--r--examples/spatialaudio/audiopanning/CMakeLists.txt (renamed from examples/multimedia/spatialaudio/CMakeLists.txt)17
-rw-r--r--examples/spatialaudio/audiopanning/audiopanning.pro9
-rw-r--r--examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png (renamed from examples/multimedia/spatialaudio/doc/images/spatialaudio-example.png)bin171760 -> 171760 bytes
-rw-r--r--examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc28
-rw-r--r--examples/spatialaudio/audiopanning/main.cpp241
-rw-r--r--examples/spatialaudio/spatialaudio.pro3
385 files changed, 8668 insertions, 15451 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 573b1c7c3..76d01581a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,6 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
qt_examples_build_begin(EXTERNAL_BUILD)
add_subdirectory(multimedia)
-add_subdirectory(multimediawidgets)
+if(QT_FEATURE_spatialaudio)
+ add_subdirectory(spatialaudio)
+endif()
qt_examples_build_end()
diff --git a/examples/examples.pro b/examples/examples.pro
index 979671672..3cda36046 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += multimedia multimediawidgets
+SUBDIRS += multimedia spatialaudio
diff --git a/examples/multimedia/CMakeLists.txt b/examples/multimedia/CMakeLists.txt
index 44b701120..07bf4debd 100644
--- a/examples/multimedia/CMakeLists.txt
+++ b/examples/multimedia/CMakeLists.txt
@@ -1,16 +1,19 @@
-qt_internal_add_example(audiodecoder)
-if(NOT ANDROID AND NOT IOS)
- qt_internal_add_example(devices)
-endif()
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
if(TARGET Qt::Widgets)
- qt_internal_add_example(spectrum)
- qt_internal_add_example(audiorecorder)
if(NOT ANDROID AND NOT IOS)
qt_internal_add_example(audiodevices)
endif()
- qt_internal_add_example(audiosource)
qt_internal_add_example(audiooutput)
- qt_internal_add_example(spatialaudio)
+ qt_internal_add_example(audiorecorder)
+ qt_internal_add_example(audiosource)
+ qt_internal_add_example(camera)
+ qt_internal_add_example(player)
+ qt_internal_add_example(spectrum)
+ qt_internal_add_example(videographicsitem)
+ qt_internal_add_example(videowidget)
+ qt_internal_add_example(screencapture)
endif()
if(TARGET Qt::Quick)
qt_internal_add_example(declarative-camera)
diff --git a/examples/multimedia/audiodecoder/CMakeLists.txt b/examples/multimedia/audiodecoder/CMakeLists.txt
deleted file mode 100644
index 85b9a45be..000000000
--- a/examples/multimedia/audiodecoder/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(audiodecoder LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/audiodecoder")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
-
-if(ANDROID)
-
-endif()
-
-qt_add_executable(audiodecoder
- audiodecoder.cpp audiodecoder.h
- main.cpp
-)
-
-set_target_properties(audiodecoder PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(audiodecoder PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Multimedia
-)
-
-if(ANDROID)
- target_link_libraries(audiodecoder PUBLIC Qt::Widgets)
-endif()
-
-install(TARGETS audiodecoder
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/multimedia/audiodecoder/audiodecoder.cpp b/examples/multimedia/audiodecoder/audiodecoder.cpp
deleted file mode 100644
index c65a3838c..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "audiodecoder.h"
-#include <QFile>
-#include <stdio.h>
-
-AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete, const QString &targetFileName)
- : m_cout(stdout, QIODevice::WriteOnly),
- m_targetFilename(targetFileName)
-{
- m_isPlayback = isPlayback;
- m_isDelete = isDelete;
-
- connect(&m_decoder, &QAudioDecoder::bufferReady,
- this, &AudioDecoder::bufferReady);
- connect(&m_decoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error),
- this, QOverload<QAudioDecoder::Error>::of(&AudioDecoder::error));
- connect(&m_decoder, &QAudioDecoder::isDecodingChanged,
- this, &AudioDecoder::isDecodingChanged);
- connect(&m_decoder, &QAudioDecoder::finished,
- this, &AudioDecoder::finished);
- connect(&m_decoder, &QAudioDecoder::positionChanged,
- this, &AudioDecoder::updateProgress);
- connect(&m_decoder, &QAudioDecoder::durationChanged,
- this, &AudioDecoder::updateProgress);
-
- connect(&m_soundEffect, &QSoundEffect::statusChanged,
- this, &AudioDecoder::playbackStatusChanged);
- connect(&m_soundEffect, &QSoundEffect::playingChanged,
- this, &AudioDecoder::playingChanged);
-
- m_progress = -1.0;
-}
-
-AudioDecoder::~AudioDecoder()
-{
- delete m_waveDecoder;
-}
-
-void AudioDecoder::setSource(const QString &fileName)
-{
- m_decoder.setSource(QUrl::fromLocalFile(fileName));
-}
-
-void AudioDecoder::start()
-{
- m_decoder.start();
-}
-
-void AudioDecoder::stop()
-{
- m_decoder.stop();
-}
-
-QAudioDecoder::Error AudioDecoder::getError()
-{
- return m_decoder.error();
-}
-
-void AudioDecoder::setTargetFilename(const QString &fileName)
-{
- m_targetFilename = fileName;
-}
-
-void AudioDecoder::bufferReady()
-{
- // read a buffer from audio decoder
- QAudioBuffer buffer = m_decoder.read();
- if (!buffer.isValid())
- return;
-
- if (!m_waveDecoder) {
- QIODevice* target = new QFile(m_targetFilename, this);
- if (!target->open(QIODevice::WriteOnly)) {
- qWarning() << "target file is not writable";
- m_decoder.stop();
- return;
- }
- m_waveDecoder = new QWaveDecoder(target, buffer.format());
- }
-
- if (!m_waveDecoder || (!m_waveDecoder->isOpen()
- && !m_waveDecoder->open(QIODevice::WriteOnly))) {
- m_decoder.stop();
- return;
- }
-
- m_waveDecoder->write(buffer.constData<char>(), buffer.byteCount());
-}
-
-void AudioDecoder::error(QAudioDecoder::Error error)
-{
- switch (error) {
- case QAudioDecoder::NoError:
- return;
- case QAudioDecoder::ResourceError:
- m_cout << "Resource error\n";
- break;
- case QAudioDecoder::FormatError:
- m_cout << "Format error\n";
- break;
- case QAudioDecoder::AccessDeniedError:
- m_cout << "Access denied error\n";
- break;
- case QAudioDecoder::NotSupportedError:
- m_cout << "Service missing error\n";
- break;
- }
-
- emit done();
-}
-
-void AudioDecoder::isDecodingChanged(bool isDecoding)
-{
- if (isDecoding)
- m_cout << "Decoding...\n";
- else
- m_cout << "Decoding stopped\n";
-}
-
-void AudioDecoder::finished()
-{
- m_waveDecoder->close();
- m_cout << "Decoding finished\n";
-
- if (m_isPlayback) {
- m_cout << "Starting playback\n";
- m_soundEffect.setSource(QUrl::fromLocalFile(m_targetFilename));
- m_soundEffect.play();
- } else {
- emit done();
- }
-}
-
-void AudioDecoder::playbackStatusChanged()
-{
- if (m_soundEffect.status() == QSoundEffect::Error) {
- m_cout << "Playback error\n";
- emit done();
- }
-}
-
-void AudioDecoder::playingChanged()
-{
- if (!m_soundEffect.isPlaying()) {
- m_cout << "Playback finished\n";
- if (m_isDelete)
- QFile::remove(m_targetFilename);
- emit done();
- }
-}
-
-void AudioDecoder::updateProgress()
-{
- qint64 position = m_decoder.position();
- qint64 duration = m_decoder.duration();
- qreal progress = m_progress;
- if (position >= 0 && duration > 0)
- progress = position / (qreal)duration;
-
- if (progress > m_progress + 0.1) {
- m_cout << "Decoding progress: " << (int)(progress * 100.0) << "%\n";
- m_progress = progress;
- }
-}
diff --git a/examples/multimedia/audiodecoder/audiodecoder.h b/examples/multimedia/audiodecoder/audiodecoder.h
deleted file mode 100644
index d75eecb8d..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AUDIODECODER_H
-#define AUDIODECODER_H
-
-#include <QAudioDecoder>
-#include <QSoundEffect>
-#include <QTextStream>
-#include <QAudioDecoder>
-#include <QWaveDecoder>
-
-class AudioDecoder : public QObject
-{
- Q_OBJECT
-
-public:
- AudioDecoder(bool isPlayback, bool isDelete, const QString &targetFileName);
- ~AudioDecoder();
-
- void setSource(const QString &fileName);
- void start();
- void stop();
- QAudioDecoder::Error getError();
-
- void setTargetFilename(const QString &fileName);
-
-signals:
- void done();
-
-public slots:
- void bufferReady();
- void error(QAudioDecoder::Error error);
- void isDecodingChanged(bool isDecoding);
- void finished();
-
- void playbackStatusChanged();
- void playingChanged();
-
-private slots:
- void updateProgress();
-
-private:
- bool m_isPlayback;
- bool m_isDelete;
- QAudioDecoder m_decoder;
- QTextStream m_cout;
-
- QString m_targetFilename;
- QWaveDecoder *m_waveDecoder = nullptr;
- QSoundEffect m_soundEffect;
-
- qreal m_progress;
-};
-
-#endif // AUDIODECODER_H
diff --git a/examples/multimedia/audiodecoder/audiodecoder.pro b/examples/multimedia/audiodecoder/audiodecoder.pro
deleted file mode 100644
index 7870d340e..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-TARGET = audiodecoder
-
-HEADERS = \
- audiodecoder.h
-SOURCES = main.cpp \
- audiodecoder.cpp
-
-QT += multimedia
-CONFIG += console
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audiodecoder
-INSTALLS += target
diff --git a/examples/multimedia/audiodecoder/main.cpp b/examples/multimedia/audiodecoder/main.cpp
deleted file mode 100644
index 2f6637b22..000000000
--- a/examples/multimedia/audiodecoder/main.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "audiodecoder.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QFileInfo>
-#include <QTextStream>
-#ifdef Q_OS_ANDROID
-#include <QApplication>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <qstandardpaths.h>
-#endif
-
-#include <stdio.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef Q_OS_ANDROID
- QApplication app(argc, argv);
-#else
- QCoreApplication app(argc, argv);
-#endif
-
- QFileInfo sourceFile;
- QFileInfo targetFile;
- bool isPlayback = false;
- bool isDelete = false;
-
-#ifndef Q_OS_ANDROID
- QTextStream cout(stdout, QIODevice::WriteOnly);
- if (app.arguments().size() < 2) {
- cout << "Usage: audiodecoder [-p] [-pd] SOURCEFILE [TARGETFILE]\n";
- cout << "Set -p option if you want to play output file.\n";
- cout << "Set -pd option if you want to play output file and delete it after successful playback.\n";
- cout << "Default TARGETFILE name is \"out.wav\" in the same directory as the source file.\n";
- return 0;
- }
-
- if (app.arguments().at(1) == "-p")
- isPlayback = true;
- else if (app.arguments().at(1) == "-pd") {
- isPlayback = true;
- isDelete = true;
- }
-
- int sourceFileIndex = (isPlayback || isDelete) ? 2 : 1;
- if (app.arguments().size() <= sourceFileIndex) {
- cout << "Error: source filename is not specified.\n";
- return 0;
- }
-
- sourceFile.setFile(app.arguments().at(sourceFileIndex));
- if (app.arguments().size() > sourceFileIndex + 1)
- targetFile.setFile(app.arguments().at(sourceFileIndex + 1));
- else
- targetFile.setFile(sourceFile.dir().absoluteFilePath("out.wav"));
-
-#else
-
- const QString message = "You will be prompted to select an audio file (e.g. mp3 or ogg format) "
- "which will be decoded and played back to you.";
- QMessageBox messageBox(QMessageBox::Information, "Audio Decoder", message, QMessageBox::Ok);
- messageBox.exec();
- sourceFile = QFileInfo(QFileDialog::getOpenFileName(messageBox.parentWidget(),
- "Select Audio File"));
- auto musicPath = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
- targetFile = QFileInfo(musicPath.append("/out.wav"));
- isPlayback = true;
-#endif
- AudioDecoder decoder(isPlayback, isDelete, targetFile.absoluteFilePath());
- QObject::connect(&decoder, &AudioDecoder::done,
- &app, &QCoreApplication::quit);
- decoder.setSource(sourceFile.absoluteFilePath());
- decoder.start();
- if (decoder.getError() != QAudioDecoder::NoError)
- return 0;
-
- return app.exec();
-}
diff --git a/examples/multimedia/audiodevices/CMakeLists.txt b/examples/multimedia/audiodevices/CMakeLists.txt
index 6bf07e6e5..a3003c4c5 100644
--- a/examples/multimedia/audiodevices/CMakeLists.txt
+++ b/examples/multimedia/audiodevices/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(audiodevices LANGUAGES CXX)
diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp
index 812613df1..d211189fd 100644
--- a/examples/multimedia/audiodevices/audiodevices.cpp
+++ b/examples/multimedia/audiodevices/audiodevices.cpp
@@ -1,57 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiodevices.h"
-#include <qmediadevices.h>
-#include <qcameradevice.h>
-#include <qmediaformat.h>
+
+#include <QCameraDevice>
+#include <QMediaDevices>
+#include <QMediaFormat>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
// Utility functions for converting QAudioFormat fields into text
@@ -71,28 +29,55 @@ static QString toString(QAudioFormat::SampleFormat sampleFormat)
}
}
-AudioDevicesBase::AudioDevicesBase(QWidget *parent)
- : QMainWindow(parent)
+AudioDevicesBase::AudioDevicesBase(QWidget *parent) : QMainWindow(parent)
{
setupUi(this);
}
AudioDevicesBase::~AudioDevicesBase() = default;
+AudioTest::AudioTest(QWidget *parent) : AudioDevicesBase(parent), m_devices(new QMediaDevices(this))
+{
+ init();
+}
-AudioTest::AudioTest(QWidget *parent)
- : AudioDevicesBase(parent),
- m_devices(new QMediaDevices(this))
+void AudioTest::init()
{
+#if QT_CONFIG(permissions)
+ // camera
+ QCameraPermission cameraPermission;
+ switch (qApp->checkPermission(cameraPermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(cameraPermission, this, &AudioTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Camera permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+ // microphone
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &AudioTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
m_devices->videoInputs();
- qDebug() << "<<<<<<<<<<<<<<<<<<";
QMediaFormat().supportedFileFormats(QMediaFormat::Encode);
connect(testButton, &QPushButton::clicked, this, &AudioTest::test);
connect(modeBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::modeChanged);
connect(deviceBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::deviceChanged);
connect(sampleRateSpinBox, &QSpinBox::valueChanged, this, &AudioTest::sampleRateChanged);
connect(channelsSpinBox, &QSpinBox::valueChanged, this, &AudioTest::channelChanged);
- connect(sampleFormatBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::sampleFormatChanged);
+ connect(sampleFormatBox, QOverload<int>::of(&QComboBox::activated), this,
+ &AudioTest::sampleFormatChanged);
connect(populateTableButton, &QPushButton::clicked, this, &AudioTest::populateTable);
connect(m_devices, &QMediaDevices::audioInputsChanged, this, &AudioTest::updateAudioDevices);
connect(m_devices, &QMediaDevices::audioOutputsChanged, this, &AudioTest::updateAudioDevices);
@@ -117,24 +102,23 @@ void AudioTest::test()
} else {
QAudioFormat nearest = m_deviceInfo.preferredFormat();
testResult->setText(tr("Failed"));
- nearestSampleRate->setText(QString("%1").arg(nearest.sampleRate()));
- nearestChannel->setText(QString("%1").arg(nearest.channelCount()));
+ nearestSampleRate->setText(QStringLiteral("%1").arg(nearest.sampleRate()));
+ nearestChannel->setText(QStringLiteral("%1").arg(nearest.channelCount()));
nearestSampleFormat->setText(toString(nearest.sampleFormat()));
}
- }
- else
+ } else
testResult->setText(tr("No Device"));
}
void AudioTest::updateAudioDevices()
{
deviceBox->clear();
- const auto devices = m_mode == QAudioDevice::Input ? m_devices->audioInputs() : m_devices->audioOutputs();
- for (auto &deviceInfo: devices)
+ const auto devices =
+ m_mode == QAudioDevice::Input ? m_devices->audioInputs() : m_devices->audioOutputs();
+ for (auto &deviceInfo : devices)
deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
}
-
void AudioTest::modeChanged(int idx)
{
testResult->clear();
@@ -157,16 +141,16 @@ void AudioTest::deviceChanged(int idx)
sampleRateSpinBox->clear();
sampleRateSpinBox->setMinimum(m_deviceInfo.minimumSampleRate());
sampleRateSpinBox->setMaximum(m_deviceInfo.maximumSampleRate());
- int sampleValue = qBound(m_deviceInfo.minimumSampleRate(), 48000,
- m_deviceInfo.maximumSampleRate());
+ int sampleValue =
+ qBound(m_deviceInfo.minimumSampleRate(), 48000, m_deviceInfo.maximumSampleRate());
sampleRateSpinBox->setValue(sampleValue);
m_settings.setSampleRate(sampleValue);
channelsSpinBox->clear();
channelsSpinBox->setMinimum(m_deviceInfo.minimumChannelCount());
channelsSpinBox->setMaximum(m_deviceInfo.maximumChannelCount());
- int channelValue = qBound(m_deviceInfo.minimumChannelCount(), 2,
- m_deviceInfo.maximumChannelCount());
+ int channelValue =
+ qBound(m_deviceInfo.minimumChannelCount(), 2, m_deviceInfo.maximumChannelCount());
channelsSpinBox->setValue(channelValue);
sampleFormatBox->clear();
@@ -187,15 +171,19 @@ void AudioTest::populateTable()
allFormatsTable->setRowCount(row + 1);
QTableWidgetItem *sampleTypeItem = new QTableWidgetItem(toString(sampleFormat));
- allFormatsTable->setItem(row, 2, sampleTypeItem);
+ allFormatsTable->setItem(row, 0, sampleTypeItem);
- QTableWidgetItem *sampleRateItem = new QTableWidgetItem(QString("%1 - %2")
- .arg(m_deviceInfo.minimumSampleRate()).arg(m_deviceInfo.maximumSampleRate()));
- allFormatsTable->setItem(row, 0, sampleRateItem);
+ QTableWidgetItem *sampleRateItem =
+ new QTableWidgetItem(QStringLiteral("%1 - %2")
+ .arg(m_deviceInfo.minimumSampleRate())
+ .arg(m_deviceInfo.maximumSampleRate()));
+ allFormatsTable->setItem(row, 1, sampleRateItem);
- QTableWidgetItem *channelsItem = new QTableWidgetItem(QString("%1 - %2")
- .arg(m_deviceInfo.minimumChannelCount()).arg(m_deviceInfo.maximumChannelCount()));
- allFormatsTable->setItem(row, 1, channelsItem);
+ QTableWidgetItem *channelsItem =
+ new QTableWidgetItem(QStringLiteral("%1 - %2")
+ .arg(m_deviceInfo.minimumChannelCount())
+ .arg(m_deviceInfo.maximumChannelCount()));
+ allFormatsTable->setItem(row, 2, channelsItem);
++row;
}
@@ -217,3 +205,5 @@ void AudioTest::sampleFormatChanged(int idx)
auto formats = m_deviceInfo.supportedSampleFormats();
m_settings.setSampleFormat(formats.at(idx));
}
+
+#include "moc_audiodevices.cpp"
diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h
index a2c5325bc..efe4e373c 100644
--- a/examples/multimedia/audiodevices/audiodevices.h
+++ b/examples/multimedia/audiodevices/audiodevices.h
@@ -1,67 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIODEVICES_H
#define AUDIODEVICES_H
+#include "ui_audiodevicesbase.h"
+
#include <QAudioDevice>
-#include <QMediaDevices>
#include <QMainWindow>
+#include <QMediaDevices>
#include <QObject>
-#include "ui_audiodevicesbase.h"
-
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
{
public:
- AudioDevicesBase(QWidget *parent = 0);
+ AudioDevicesBase(QWidget *parent = nullptr);
virtual ~AudioDevicesBase();
};
@@ -79,6 +32,7 @@ private:
QMediaDevices *m_devices = nullptr;
private slots:
+ void init();
void updateAudioDevices();
void modeChanged(int idx);
void deviceChanged(int idx);
@@ -87,8 +41,6 @@ private slots:
void sampleFormatChanged(int idx);
void test();
void populateTable();
-
};
#endif
-
diff --git a/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc b/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
index 4ff9d7f80..1aac6abb0 100644
--- a/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
+++ b/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
@@ -1,34 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiodevices
+ \example audiodevices
\title Audio Devices Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Testing the available audio devices and their configuration.
\meta {tag} {widgets}
diff --git a/examples/multimedia/audiodevices/main.cpp b/examples/multimedia/audiodevices/main.cpp
index 9042d391a..411f67092 100644
--- a/examples/multimedia/audiodevices/main.cpp
+++ b/examples/multimedia/audiodevices/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiodevices.h"
+#include <QApplication>
+
int main(int argv, char **args)
{
QApplication app(argv, args);
diff --git a/examples/multimedia/audiooutput/CMakeLists.txt b/examples/multimedia/audiooutput/CMakeLists.txt
index 09e6d13ac..9308463d2 100644
--- a/examples/multimedia/audiooutput/CMakeLists.txt
+++ b/examples/multimedia/audiooutput/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(audiooutput LANGUAGES CXX)
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 381ccca1d..809b79293 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiooutput.h"
@@ -54,8 +7,8 @@
#include <QAudioSink>
#include <QDebug>
#include <QVBoxLayout>
-#include <qmath.h>
-#include <qendian.h>
+#include <QtEndian>
+#include <QtMath>
Generator::Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate)
{
@@ -88,9 +41,10 @@ void Generator::generateData(const QAudioFormat &format, qint64 durationUs, int
while (length) {
// Produces value (-1..1)
- const qreal x = qSin(2 * M_PI * sampleRate * qreal(sampleIndex++ % format.sampleRate()) / format.sampleRate());
- for (int i=0; i<format.channelCount(); ++i) {
- switch(format.sampleFormat()) {
+ const qreal x = qSin(2 * M_PI * sampleRate * qreal(sampleIndex++ % format.sampleRate())
+ / format.sampleRate());
+ for (int i = 0; i < format.channelCount(); ++i) {
+ switch (format.sampleFormat()) {
case QAudioFormat::UInt8:
*reinterpret_cast<quint8 *>(ptr) = static_cast<quint8>((1.0 + x) / 2 * 255);
break;
@@ -98,7 +52,8 @@ void Generator::generateData(const QAudioFormat &format, qint64 durationUs, int
*reinterpret_cast<qint16 *>(ptr) = static_cast<qint16>(x * 32767);
break;
case QAudioFormat::Int32:
- *reinterpret_cast<qint32 *>(ptr) = static_cast<qint32>(x * std::numeric_limits<qint32>::max());
+ *reinterpret_cast<qint32 *>(ptr) =
+ static_cast<qint32>(x * std::numeric_limits<qint32>::max());
break;
case QAudioFormat::Float:
*reinterpret_cast<float *>(ptr) = x;
@@ -140,9 +95,7 @@ qint64 Generator::bytesAvailable() const
return m_buffer.size() + QIODevice::bytesAvailable();
}
-AudioTest::AudioTest()
- : m_devices(new QMediaDevices(this)),
- m_pushTimer(new QTimer(this))
+AudioTest::AudioTest() : m_devices(new QMediaDevices(this)), m_pushTimer(new QTimer(this))
{
initializeWindow();
initializeAudio(m_devices->defaultAudioOutput());
@@ -161,11 +114,12 @@ void AudioTest::initializeWindow()
m_deviceBox = new QComboBox(this);
const QAudioDevice &defaultDeviceInfo = m_devices->defaultAudioOutput();
m_deviceBox->addItem(defaultDeviceInfo.description(), QVariant::fromValue(defaultDeviceInfo));
- for (auto &deviceInfo: m_devices->audioOutputs()) {
+ for (auto &deviceInfo : m_devices->audioOutputs()) {
if (deviceInfo != defaultDeviceInfo)
m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
}
- connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::deviceChanged);
+ connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this,
+ &AudioTest::deviceChanged);
connect(m_devices, &QMediaDevices::audioOutputsChanged, this, &AudioTest::updateAudioDevices);
layout->addWidget(m_deviceBox);
@@ -205,8 +159,7 @@ void AudioTest::initializeAudio(const QAudioDevice &deviceInfo)
m_audioOutput.reset(new QAudioSink(deviceInfo, format));
m_generator->start();
- qreal initialVolume = QAudio::convertVolume(m_audioOutput->volume(),
- QAudio::LinearVolumeScale,
+ qreal initialVolume = QAudio::convertVolume(m_audioOutput->volume(), QAudio::LinearVolumeScale,
QAudio::LogarithmicVolumeScale);
m_volumeSlider->setValue(qRound(initialVolume * 100));
toggleMode();
@@ -222,8 +175,7 @@ void AudioTest::deviceChanged(int index)
void AudioTest::volumeChanged(int value)
{
- qreal linearVolume = QAudio::convertVolume(value / qreal(100),
- QAudio::LogarithmicVolumeScale,
+ qreal linearVolume = QAudio::convertVolume(value / qreal(100), QAudio::LogarithmicVolumeScale,
QAudio::LinearVolumeScale);
m_audioOutput->setVolume(linearVolume);
@@ -233,7 +185,7 @@ void AudioTest::updateAudioDevices()
{
m_deviceBox->clear();
const QList<QAudioDevice> devices = m_devices->audioOutputs();
- for (const QAudioDevice &deviceInfo: devices)
+ for (const QAudioDevice &deviceInfo : devices)
m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
}
@@ -244,11 +196,11 @@ void AudioTest::toggleMode()
toggleSuspendResume();
if (m_pullMode) {
- //switch to pull mode (QAudioSink pulls from Generator as needed)
+ // switch to pull mode (QAudioSink pulls from Generator as needed)
m_modeButton->setText(tr("Enable push mode"));
m_audioOutput->start(m_generator.data());
} else {
- //switch to push mode (periodically push to QAudioSink using a timer)
+ // switch to push mode (periodically push to QAudioSink using a timer)
m_modeButton->setText(tr("Enable pull mode"));
auto io = m_audioOutput->start();
m_pushTimer->disconnect();
@@ -261,7 +213,7 @@ void AudioTest::toggleMode()
QByteArray buffer(len, 0);
len = m_generator->read(buffer.data(), len);
if (len)
- io->write(buffer.data(), len);
+ io->write(buffer.data(), len);
});
m_pushTimer->start(10);
@@ -272,7 +224,8 @@ void AudioTest::toggleMode()
void AudioTest::toggleSuspendResume()
{
- if (m_audioOutput->state() == QAudio::SuspendedState || m_audioOutput->state() == QAudio::StoppedState) {
+ if (m_audioOutput->state() == QAudio::SuspendedState
+ || m_audioOutput->state() == QAudio::StoppedState) {
m_audioOutput->resume();
m_suspendResumeButton->setText(tr("Suspend playback"));
} else if (m_audioOutput->state() == QAudio::ActiveState) {
@@ -283,3 +236,4 @@ void AudioTest::toggleSuspendResume()
}
}
+#include "moc_audiooutput.cpp"
diff --git a/examples/multimedia/audiooutput/audiooutput.h b/examples/multimedia/audiooutput/audiooutput.h
index 1d3792aff..3a82c57c4 100644
--- a/examples/multimedia/audiooutput/audiooutput.h
+++ b/examples/multimedia/audiooutput/audiooutput.h
@@ -1,70 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIOOUTPUT_H
#define AUDIOOUTPUT_H
-#include <math.h>
-
#include <QAudioSink>
#include <QByteArray>
#include <QComboBox>
#include <QIODevice>
#include <QLabel>
#include <QMainWindow>
+#include <QMediaDevices>
#include <QObject>
#include <QPushButton>
+#include <QScopedPointer>
#include <QSlider>
#include <QTimer>
-#include <QScopedPointer>
-#include <QMediaDevices>
+
+#include <math.h>
class Generator : public QIODevice
{
diff --git a/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc b/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
index 6aaf0639d..93636c49d 100644
--- a/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
+++ b/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
@@ -1,34 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiooutput
+ \example audiooutput
\title Audio Output Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Enabling audio playback using the QAudioSink class.
\meta {tag} {widgets}
diff --git a/examples/multimedia/audiooutput/main.cpp b/examples/multimedia/audiooutput/main.cpp
index 9ed586095..8c652f0ff 100644
--- a/examples/multimedia/audiooutput/main.cpp
+++ b/examples/multimedia/audiooutput/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiooutput.h"
+#include <QApplication>
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/examples/multimedia/audiorecorder/CMakeLists.txt b/examples/multimedia/audiorecorder/CMakeLists.txt
index af0e23e41..6ff9306fe 100644
--- a/examples/multimedia/audiorecorder/CMakeLists.txt
+++ b/examples/multimedia/audiorecorder/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(audiorecorder LANGUAGES CXX)
diff --git a/examples/multimedia/audiorecorder/audiolevel.cpp b/examples/multimedia/audiorecorder/audiolevel.cpp
index b13e7fbc8..444dca9a4 100644
--- a/examples/multimedia/audiorecorder/audiolevel.cpp
+++ b/examples/multimedia/audiorecorder/audiolevel.cpp
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiolevel.h"
+
#include <QPainter>
-AudioLevel::AudioLevel(QWidget *parent)
- : QWidget(parent)
+AudioLevel::AudioLevel(QWidget *parent) : QWidget(parent)
{
setMinimumHeight(15);
setMaximumHeight(50);
@@ -77,3 +30,4 @@ void AudioLevel::paintEvent(QPaintEvent *event)
// clear the rest of the control
painter.fillRect(widthLevel, 0, width(), height(), Qt::black);
}
+
diff --git a/examples/multimedia/audiorecorder/audiolevel.h b/examples/multimedia/audiorecorder/audiolevel.h
index 3c71264c5..7a42a8d01 100644
--- a/examples/multimedia/audiorecorder/audiolevel.h
+++ b/examples/multimedia/audiorecorder/audiolevel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIOLEVEL_H
#define AUDIOLEVEL_H
@@ -57,7 +10,7 @@ class AudioLevel : public QWidget
{
Q_OBJECT
public:
- explicit AudioLevel(QWidget *parent = 0);
+ explicit AudioLevel(QWidget *parent = nullptr);
// Using [0; 1.0] range
void setLevel(qreal level);
diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp
index 992e0a486..4131d5d51 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.cpp
+++ b/examples/multimedia/audiorecorder/audiorecorder.cpp
@@ -1,125 +1,103 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiorecorder.h"
#include "audiolevel.h"
-
#include "ui_audiorecorder.h"
-#include <QMediaRecorder>
+#include <QAudioBuffer>
+#include <QAudioDevice>
+#include <QAudioInput>
#include <QDir>
#include <QFileDialog>
+#include <QImageCapture>
+#include <QMediaDevices>
+#include <QMediaFormat>
#include <QMediaRecorder>
-#include <QStandardPaths>
-#include <qmediadevices.h>
-#include <qmediaformat.h>
-#include <qaudiodevice.h>
-#include <qaudiobuffer.h>
-#include <qaudioinput.h>
-#include <qimagecapture.h>
#include <QMimeType>
+#include <QStandardPaths>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
static QList<qreal> getBufferLevels(const QAudioBuffer &buffer);
-AudioRecorder::AudioRecorder()
- : ui(new Ui::AudioRecorder)
+AudioRecorder::AudioRecorder() : ui(new Ui::AudioRecorder)
{
ui->setupUi(this);
- m_audioRecorder = new QMediaRecorder(this);
- m_captureSession.setRecorder(m_audioRecorder);
- m_captureSession.setAudioInput(new QAudioInput(this));
- // ### replace with a monitoring output once we have it.
-// m_probe = new QAudioProbe(this);
-// connect(m_probe, &QAudioProbe::audioBufferProbed,
-// this, &AudioRecorder::processBuffer);
-// m_probe->setSource(m_audioRecorder);
-
- //audio devices
- ui->audioDeviceBox->addItem(tr("Default"), QVariant(QString()));
- for (auto device: QMediaDevices::audioInputs()) {
- auto name = device.description();
- ui->audioDeviceBox->addItem(name, QVariant::fromValue(device));
- }
-
- //audio codecs and container formats
- updateFormats();
- connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this, &AudioRecorder::updateFormats);
- connect(ui->containerBox, &QComboBox::currentIndexChanged, this, &AudioRecorder::updateFormats);
-
- //sample rate
- ui->sampleRateBox->setRange(m_captureSession.audioInput()->device().minimumSampleRate(),
- m_captureSession.audioInput()->device().maximumSampleRate());
- ui->sampleRateBox->setValue(qBound(m_captureSession.audioInput()->device().minimumSampleRate(), 44100,
- m_captureSession.audioInput()->device().maximumSampleRate()));
-
- //channels
+ // channels
ui->channelsBox->addItem(tr("Default"), QVariant(-1));
ui->channelsBox->addItem(QStringLiteral("1"), QVariant(1));
ui->channelsBox->addItem(QStringLiteral("2"), QVariant(2));
ui->channelsBox->addItem(QStringLiteral("4"), QVariant(4));
- //quality
+ // quality
ui->qualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
ui->qualitySlider->setValue(int(QImageCapture::NormalQuality));
- //bit rates:
+ // bit rates:
ui->bitrateBox->addItem(tr("Default"), QVariant(0));
ui->bitrateBox->addItem(QStringLiteral("32000"), QVariant(32000));
ui->bitrateBox->addItem(QStringLiteral("64000"), QVariant(64000));
ui->bitrateBox->addItem(QStringLiteral("96000"), QVariant(96000));
ui->bitrateBox->addItem(QStringLiteral("128000"), QVariant(128000));
- connect(m_audioRecorder, &QMediaRecorder::durationChanged, this, &AudioRecorder::updateProgress);
- connect(m_audioRecorder, &QMediaRecorder::recorderStateChanged, this, &AudioRecorder::onStateChanged);
- connect(m_audioRecorder, &QMediaRecorder::errorChanged, this, &AudioRecorder::displayErrorMessage);
+ // audio input initialization
+ init();
+}
+
+void AudioRecorder::init()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &AudioRecorder::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+
+ m_audioRecorder = new QMediaRecorder(this);
+ m_captureSession.setRecorder(m_audioRecorder);
+ m_captureSession.setAudioInput(new QAudioInput(this));
+ // ### replace with a monitoring output once we have it.
+ // m_probe = new QAudioProbe(this);
+ // connect(m_probe, &QAudioProbe::audioBufferProbed,
+ // this, &AudioRecorder::processBuffer);
+ // m_probe->setSource(m_audioRecorder);
+
+ // audio devices
+ m_mediaDevices = new QMediaDevices(this);
+ connect(m_mediaDevices, &QMediaDevices::audioInputsChanged, this,
+ &AudioRecorder::updateDevices);
+ updateDevices();
+
+ // audio codecs and container formats
+ updateFormats();
+ connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this,
+ &AudioRecorder::updateFormats);
+ connect(ui->containerBox, &QComboBox::currentIndexChanged, this, &AudioRecorder::updateFormats);
+
+ // sample rate
+ ui->sampleRateBox->setRange(m_captureSession.audioInput()->device().minimumSampleRate(),
+ m_captureSession.audioInput()->device().maximumSampleRate());
+ ui->sampleRateBox->setValue(
+ qBound(m_captureSession.audioInput()->device().minimumSampleRate(), 44100,
+ m_captureSession.audioInput()->device().maximumSampleRate()));
+
+ connect(m_audioRecorder, &QMediaRecorder::durationChanged, this,
+ &AudioRecorder::updateProgress);
+ connect(m_audioRecorder, &QMediaRecorder::recorderStateChanged, this,
+ &AudioRecorder::onStateChanged);
+ connect(m_audioRecorder, &QMediaRecorder::errorChanged, this,
+ &AudioRecorder::displayErrorMessage);
}
void AudioRecorder::updateProgress(qint64 duration)
@@ -171,20 +149,20 @@ static QVariant boxValue(const QComboBox *box)
void AudioRecorder::toggleRecord()
{
if (m_audioRecorder->recorderState() == QMediaRecorder::StoppedState) {
- m_captureSession.audioInput()->setDevice(boxValue(ui->audioDeviceBox).value<QAudioDevice>());
+ m_captureSession.audioInput()->setDevice(
+ boxValue(ui->audioDeviceBox).value<QAudioDevice>());
m_audioRecorder->setMediaFormat(selectedMediaFormat());
m_audioRecorder->setAudioSampleRate(ui->sampleRateBox->value());
m_audioRecorder->setAudioBitRate(boxValue(ui->bitrateBox).toInt());
m_audioRecorder->setAudioChannelCount(boxValue(ui->channelsBox).toInt());
m_audioRecorder->setQuality(QMediaRecorder::Quality(ui->qualitySlider->value()));
- m_audioRecorder->setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
- QMediaRecorder::ConstantQualityEncoding :
- QMediaRecorder::ConstantBitRateEncoding);
+ m_audioRecorder->setEncodingMode(ui->constantQualityRadioButton->isChecked()
+ ? QMediaRecorder::ConstantQualityEncoding
+ : QMediaRecorder::ConstantBitRateEncoding);
m_audioRecorder->record();
- }
- else {
+ } else {
m_audioRecorder->stop();
}
}
@@ -200,9 +178,9 @@ void AudioRecorder::togglePause()
void AudioRecorder::setOutputLocation()
{
#ifdef Q_OS_ANDROID
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save Recording"),
- "output."
- + selectedMediaFormat().mimeType().preferredSuffix());
+ QString fileName = QFileDialog::getSaveFileName(
+ this, tr("Save Recording"),
+ "output." + selectedMediaFormat().mimeType().preferredSuffix());
#else
QString fileName = QFileDialog::getSaveFileName();
#endif
@@ -215,6 +193,25 @@ void AudioRecorder::displayErrorMessage()
ui->statusbar->showMessage(m_audioRecorder->errorString());
}
+void AudioRecorder::updateDevices()
+{
+ const auto currentDevice = boxValue(ui->audioDeviceBox).value<QAudioDevice>();
+ int currentDeviceIndex = 0;
+
+ ui->audioDeviceBox->clear();
+
+ ui->audioDeviceBox->addItem(tr("Default"), {});
+ for (const auto &device : m_mediaDevices->audioInputs()) {
+ const auto name = device.description();
+ ui->audioDeviceBox->addItem(name, QVariant::fromValue(device));
+
+ if (device.id() == currentDevice.id())
+ currentDeviceIndex = ui->audioDeviceBox->count() - 1;
+ }
+
+ ui->audioDeviceBox->setCurrentIndex(currentDeviceIndex);
+}
+
void AudioRecorder::updateFormats()
{
if (m_updatingFormats)
@@ -229,23 +226,27 @@ void AudioRecorder::updateFormats()
int currentIndex = 0;
ui->audioCodecBox->clear();
- ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
+ ui->audioCodecBox->addItem(tr("Default audio codec"),
+ QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
for (auto codec : format.supportedAudioCodecs(QMediaFormat::Encode)) {
if (codec == format.audioCodec())
currentIndex = ui->audioCodecBox->count();
- ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec), QVariant::fromValue(codec));
+ ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec),
+ QVariant::fromValue(codec));
}
ui->audioCodecBox->setCurrentIndex(currentIndex);
currentIndex = 0;
ui->containerBox->clear();
- ui->containerBox->addItem(tr("Default file format"), QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
+ ui->containerBox->addItem(tr("Default file format"),
+ QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
for (auto container : format.supportedFileFormats(QMediaFormat::Encode)) {
if (container < QMediaFormat::Mpeg4Audio) // Skip video formats
continue;
if (container == format.fileFormat())
currentIndex = ui->containerBox->count();
- ui->containerBox->addItem(QMediaFormat::fileFormatDescription(container), QVariant::fromValue(container));
+ ui->containerBox->addItem(QMediaFormat::fileFormatDescription(container),
+ QVariant::fromValue(container));
}
ui->containerBox->setCurrentIndex(currentIndex);
@@ -254,7 +255,7 @@ void AudioRecorder::updateFormats()
void AudioRecorder::clearAudioLevels()
{
- for (auto m_audioLevel : qAsConst(m_audioLevels))
+ for (auto m_audioLevel : std::as_const(m_audioLevels))
m_audioLevel->setLevel(0);
}
@@ -295,7 +296,7 @@ QList<qreal> getBufferLevels(const QAudioBuffer &buffer)
return max_values;
}
-void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
+void AudioRecorder::processBuffer(const QAudioBuffer &buffer)
{
if (m_audioLevels.count() != buffer.format().channelCount()) {
qDeleteAll(m_audioLevels);
@@ -311,3 +312,4 @@ void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
for (int i = 0; i < levels.count(); ++i)
m_audioLevels.at(i)->setLevel(levels.at(i));
}
+
diff --git a/examples/multimedia/audiorecorder/audiorecorder.h b/examples/multimedia/audiorecorder/audiorecorder.h
index 9ef20f0d5..2ce71c162 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.h
+++ b/examples/multimedia/audiorecorder/audiorecorder.h
@@ -1,64 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIORECORDER_H
#define AUDIORECORDER_H
#include <QMainWindow>
-#include <QMediaRecorder>
#include <QMediaCaptureSession>
+#include <QMediaRecorder>
#include <QUrl>
QT_BEGIN_NAMESPACE
-namespace Ui { class AudioRecorder; }
+namespace Ui {
+class AudioRecorder;
+}
class QAudioBuffer;
+class QMediaDevices;
QT_END_NAMESPACE
class AudioLevel;
@@ -71,9 +27,10 @@ public:
AudioRecorder();
public slots:
- void processBuffer(const QAudioBuffer&);
+ void processBuffer(const QAudioBuffer &);
private slots:
+ void init();
void setOutputLocation();
void togglePause();
void toggleRecord();
@@ -82,6 +39,7 @@ private slots:
void updateProgress(qint64 pos);
void displayErrorMessage();
+ void updateDevices();
void updateFormats();
private:
@@ -92,7 +50,9 @@ private:
QMediaCaptureSession m_captureSession;
QMediaRecorder *m_audioRecorder = nullptr;
- QList<AudioLevel*> m_audioLevels;
+ QMediaDevices *m_mediaDevices = nullptr;
+
+ QList<AudioLevel *> m_audioLevels;
bool m_outputLocationSet = false;
bool m_updatingFormats = false;
};
diff --git a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
index c96066687..71481f24d 100644
--- a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
+++ b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
@@ -1,34 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiorecorder
+ \example audiorecorder
\title Audio Recorder Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Discovering the available devices and supported codecs.
\meta {tag} {widgets}
diff --git a/examples/multimedia/audiorecorder/main.cpp b/examples/multimedia/audiorecorder/main.cpp
index f13940b23..407729616 100644
--- a/examples/multimedia/audiorecorder/main.cpp
+++ b/examples/multimedia/audiorecorder/main.cpp
@@ -1,56 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiorecorder.h"
-#include <QtWidgets>
+#include <QApplication>
int main(int argc, char *argv[])
{
diff --git a/examples/multimedia/audiosource/CMakeLists.txt b/examples/multimedia/audiosource/CMakeLists.txt
index 8584dc2fb..65226247a 100644
--- a/examples/multimedia/audiosource/CMakeLists.txt
+++ b/examples/multimedia/audiosource/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(audiosource LANGUAGES CXX)
@@ -19,6 +22,7 @@ qt_add_executable(audiosource
set_target_properties(audiosource PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
)
target_include_directories(audiosource PUBLIC
diff --git a/examples/multimedia/audiosource/Info.plist.in b/examples/multimedia/audiosource/Info.plist.in
new file mode 100644
index 000000000..43b966509
--- /dev/null
+++ b/examples/multimedia/audiosource/Info.plist.in
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/audiosource/audioinput.pro b/examples/multimedia/audiosource/audioinput.pro
deleted file mode 100644
index 708d40d93..000000000
--- a/examples/multimedia/audiosource/audioinput.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-TARGET = audioinput
-
-QT += multimedia widgets
-
-HEADERS = audioinput.h
-
-SOURCES = audioinput.cpp \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audioinput
-INSTALLS += target
-include(../shared/shared.pri)
diff --git a/examples/multimedia/audiosource/audiosource.cpp b/examples/multimedia/audiosource/audiosource.cpp
index ef0379e02..48e33fa2d 100644
--- a/examples/multimedia/audiosource/audiosource.cpp
+++ b/examples/multimedia/audiosource/audiosource.cpp
@@ -1,70 +1,26 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiosource.h"
-#include <stdlib.h>
-#include <math.h>
-
+#include <QAudioDevice>
+#include <QAudioSource>
#include <QDateTime>
#include <QDebug>
+#include <QLabel>
#include <QPainter>
#include <QVBoxLayout>
-#include <QAudioDevice>
-#include <QAudioSource>
-#include <qendian.h>
+#include <QtEndian>
-AudioInfo::AudioInfo(const QAudioFormat &format)
- : m_format(format)
-{
-}
+#if QT_CONFIG(permissions)
+ #include <QCoreApplication>
+ #include <QPermission>
+#endif
+
+#include <math.h>
+#include <stdlib.h>
+
+AudioInfo::AudioInfo(const QAudioFormat &format) : m_format(format) { }
void AudioInfo::start()
{
@@ -110,8 +66,7 @@ qint64 AudioInfo::writeData(const char *data, qint64 len)
return len;
}
-RenderArea::RenderArea(QWidget *parent)
- : QWidget(parent)
+RenderArea::RenderArea(QWidget *parent) : QWidget(parent)
{
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
@@ -132,8 +87,7 @@ void RenderArea::paintEvent(QPaintEvent * /* event */)
return;
const int pos = qRound(qreal(frame.width() - 1) * m_level);
- painter.fillRect(frame.left() + 1, frame.top() + 1,
- pos, frame.height() - 1, Qt::red);
+ painter.fillRect(frame.left() + 1, frame.top() + 1, pos, frame.height() - 1, Qt::red);
}
void RenderArea::setLevel(qreal value)
@@ -142,12 +96,9 @@ void RenderArea::setLevel(qreal value)
update();
}
-
-InputTest::InputTest()
- : m_devices(new QMediaDevices(this))
+InputTest::InputTest() : m_devices(new QMediaDevices(this))
{
- initializeWindow();
- initializeAudio(QMediaDevices::defaultAudioInput());
+ init();
}
void InputTest::initializeWindow()
@@ -160,7 +111,7 @@ void InputTest::initializeWindow()
m_deviceBox = new QComboBox(this);
const QAudioDevice &defaultDeviceInfo = QMediaDevices::defaultAudioInput();
m_deviceBox->addItem(defaultDeviceInfo.description(), QVariant::fromValue(defaultDeviceInfo));
- for (auto &deviceInfo: m_devices->audioInputs()) {
+ for (auto &deviceInfo : m_devices->audioInputs()) {
if (deviceInfo != defaultDeviceInfo)
m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
}
@@ -191,18 +142,45 @@ void InputTest::initializeAudio(const QAudioDevice &deviceInfo)
format.setSampleFormat(QAudioFormat::Int16);
m_audioInfo.reset(new AudioInfo(format));
- connect(m_audioInfo.data(), &AudioInfo::levelChanged,
- m_canvas, &RenderArea::setLevel);
+ connect(m_audioInfo.data(), &AudioInfo::levelChanged, m_canvas, &RenderArea::setLevel);
m_audioInput.reset(new QAudioSource(deviceInfo, format));
- qreal initialVolume = QAudio::convertVolume(m_audioInput->volume(),
- QAudio::LinearVolumeScale,
+ qreal initialVolume = QAudio::convertVolume(m_audioInput->volume(), QAudio::LinearVolumeScale,
QAudio::LogarithmicVolumeScale);
m_volumeSlider->setValue(qRound(initialVolume * 100));
m_audioInfo->start();
toggleMode();
}
+void InputTest::initializeErrorWindow()
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QLabel *errorLabel = new QLabel(tr("Microphone permission is not granted!"));
+ errorLabel->setWordWrap(true);
+ errorLabel->setAlignment(Qt::AlignCenter);
+ layout->addWidget(errorLabel);
+}
+
+void InputTest::init()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &InputTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ initializeErrorWindow();
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+ initializeWindow();
+ initializeAudio(QMediaDevices::defaultAudioInput());
+}
+
void InputTest::toggleMode()
{
m_audioInput->stop();
@@ -218,18 +196,17 @@ void InputTest::toggleMode()
if (!io)
return;
- connect(io, &QIODevice::readyRead,
- [this, io]() {
- static const qint64 BufferSize = 4096;
- const qint64 len = qMin(m_audioInput->bytesAvailable(), BufferSize);
-
- QByteArray buffer(len, 0);
- qint64 l = io->read(buffer.data(), len);
- if (l > 0) {
- const qreal level = m_audioInfo->calculateLevel(buffer.constData(), l);
- m_canvas->setLevel(level);
- }
- });
+ connect(io, &QIODevice::readyRead, [this, io]() {
+ static const qint64 BufferSize = 4096;
+ const qint64 len = qMin(m_audioInput->bytesAvailable(), BufferSize);
+
+ QByteArray buffer(len, 0);
+ qint64 l = io->read(buffer.data(), len);
+ if (l > 0) {
+ const qreal level = m_audioInfo->calculateLevel(buffer.constData(), l);
+ m_canvas->setLevel(level);
+ }
+ });
}
m_pullMode = !m_pullMode;
@@ -256,18 +233,19 @@ void InputTest::toggleSuspend()
void InputTest::deviceChanged(int index)
{
- m_audioInfo->stop();
m_audioInput->stop();
m_audioInput->disconnect(this);
+ m_audioInfo->stop();
initializeAudio(m_deviceBox->itemData(index).value<QAudioDevice>());
}
void InputTest::sliderChanged(int value)
{
- qreal linearVolume = QAudio::convertVolume(value / qreal(100),
- QAudio::LogarithmicVolumeScale,
+ qreal linearVolume = QAudio::convertVolume(value / qreal(100), QAudio::LogarithmicVolumeScale,
QAudio::LinearVolumeScale);
m_audioInput->setVolume(linearVolume);
}
+
+#include "moc_audiosource.cpp"
diff --git a/examples/multimedia/audiosource/audiosource.h b/examples/multimedia/audiosource/audiosource.h
index fce664fd9..dd9a7bc4a 100644
--- a/examples/multimedia/audiosource/audiosource.h
+++ b/examples/multimedia/audiosource/audiosource.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIOINPUT_H
#define AUDIOINPUT_H
@@ -89,7 +42,6 @@ private:
qreal m_level = 0.0; // 0.0 <= m_level <= 1.0
};
-
class RenderArea : public QWidget
{
Q_OBJECT
@@ -106,7 +58,6 @@ private:
qreal m_level = 0;
};
-
class InputTest : public QWidget
{
Q_OBJECT
@@ -117,8 +68,10 @@ public:
private:
void initializeWindow();
void initializeAudio(const QAudioDevice &deviceInfo);
+ void initializeErrorWindow();
private slots:
+ void init();
void toggleMode();
void toggleSuspend();
void deviceChanged(int index);
diff --git a/examples/multimedia/audiosource/audiosource.pro b/examples/multimedia/audiosource/audiosource.pro
new file mode 100644
index 000000000..35105dace
--- /dev/null
+++ b/examples/multimedia/audiosource/audiosource.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = audiosource
+
+QT += multimedia widgets
+
+HEADERS = audiosource.h
+
+SOURCES = audiosource.cpp \
+ main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audiosource
+INSTALLS += target
+include(../shared/shared.pri)
diff --git a/examples/multimedia/audiosource/doc/src/audiosource.qdoc b/examples/multimedia/audiosource/doc/src/audiosource.qdoc
index 4c89dbeae..2f120ce77 100644
--- a/examples/multimedia/audiosource/doc/src/audiosource.qdoc
+++ b/examples/multimedia/audiosource/doc/src/audiosource.qdoc
@@ -1,34 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiosource
+ \example audiosource
\title Audio Source Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Recording audio using the QAudioSource class.
\meta {tag} {widgets}
diff --git a/examples/multimedia/audiosource/main.cpp b/examples/multimedia/audiosource/main.cpp
index e45c2bd67..49156d860 100644
--- a/examples/multimedia/audiosource/main.cpp
+++ b/examples/multimedia/audiosource/main.cpp
@@ -1,56 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiosource.h"
-#include <QtWidgets/QApplication>
+#include <QApplication>
int main(int argv, char **args)
{
diff --git a/examples/multimediawidgets/camera/CMakeLists.txt b/examples/multimedia/camera/CMakeLists.txt
index 530126ba5..f4d97c535 100644
--- a/examples/multimediawidgets/camera/CMakeLists.txt
+++ b/examples/multimedia/camera/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(camera LANGUAGES CXX)
@@ -8,7 +11,7 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/camera")
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/camera")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
diff --git a/examples/multimedia/camera/android/AndroidManifest.xml b/examples/multimedia/camera/android/AndroidManifest.xml
new file mode 100644
index 000000000..9f77579b4
--- /dev/null
+++ b/examples/multimedia/camera/android/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.example.camera"
+ android:installLocation="auto"
+ android:versionCode="-- %%INSERT_VERSION_CODE%% --"
+ android:versionName="-- %%INSERT_VERSION_NAME%% --">
+ <!-- %%INSERT_PERMISSIONS -->
+ <!-- %%INSERT_FEATURES -->
+
+ <supports-screens
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true" />
+ <application
+ android:name="org.qtproject.qt.android.bindings.QtApplication"
+ android:extractNativeLibs="true"
+ android:hardwareAccelerated="true"
+ android:label="-- %%INSERT_APP_NAME%% --"
+ android:requestLegacyExternalStorage="true"
+ android:allowBackup="true"
+ android:fullBackupOnly="false">
+ <activity
+ android:name="org.qtproject.qt.android.bindings.QtActivity"
+ android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
+ android:launchMode="singleTop"
+ android:screenOrientation="portrait"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ <meta-data
+ android:name="android.app.lib_name"
+ android:value="-- %%INSERT_APP_LIB_NAME%% --" />
+
+ </activity>
+ </application>
+</manifest>
diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimedia/camera/camera.cpp
index e71e209f3..c5aa19e2d 100644
--- a/examples/multimediawidgets/camera/camera.cpp
+++ b/examples/multimedia/camera/camera.cpp
@@ -1,88 +1,90 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "camera.h"
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
-#include "ui_camera_mobile.h"
+# include "ui_camera_mobile.h"
#else
-#include "ui_camera.h"
+# include "ui_camera.h"
#endif
-#include "videosettings.h"
+
#include "imagesettings.h"
#include "metadatadialog.h"
+#include "videosettings.h"
-#include <QMediaRecorder>
-#include <QVideoWidget>
-#include <QCameraDevice>
-#include <QMediaMetaData>
-#include <QMediaDevices>
#include <QAudioDevice>
#include <QAudioInput>
+#include <QCameraDevice>
+#include <QMediaDevices>
+#include <QMediaFormat>
+#include <QMediaMetaData>
+#include <QMediaRecorder>
+#include <QVideoWidget>
+#include <QLineEdit>
#include <QMessageBox>
-#include <QPalette>
+
+#include <QAction>
+#include <QActionGroup>
#include <QImage>
+#include <QKeyEvent>
+#include <QPalette>
-#include <QtWidgets>
-#include <QMediaDevices>
-#include <QMediaFormat>
+#include <QDir>
+#include <QTimer>
-Camera::Camera()
- : ui(new Ui::Camera)
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
+Camera::Camera() : ui(new Ui::Camera)
{
ui->setupUi(this);
+ // disable all buttons by default
+ updateCameraActive(false);
+ readyForCapture(false);
+ ui->recordButton->setEnabled(false);
+ ui->pauseButton->setEnabled(false);
+ ui->stopButton->setEnabled(false);
+ ui->metaDataButton->setEnabled(false);
+
+ // try to actually initialize camera & mic
+ init();
+}
+
+void Camera::init()
+{
+#if QT_CONFIG(permissions)
+ // camera
+ QCameraPermission cameraPermission;
+ switch (qApp->checkPermission(cameraPermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(cameraPermission, this, &Camera::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Camera permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+ // microphone
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &Camera::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
m_audioInput.reset(new QAudioInput);
m_captureSession.setAudioInput(m_audioInput.get());
- //Camera devices:
+ // Camera devices:
videoDevicesGroup = new QActionGroup(this);
videoDevicesGroup->setExclusive(true);
@@ -93,6 +95,8 @@ Camera::Camera()
connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode);
connect(ui->metaDataButton, &QPushButton::clicked, this, &Camera::showMetaDataDialog);
+ connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this,
+ &Camera::setExposureCompensation);
setCamera(QMediaDevices::defaultVideoInput());
}
@@ -108,54 +112,38 @@ void Camera::setCamera(const QCameraDevice &cameraDevice)
if (!m_mediaRecorder) {
m_mediaRecorder.reset(new QMediaRecorder);
m_captureSession.setRecorder(m_mediaRecorder.data());
- connect(m_mediaRecorder.data(), &QMediaRecorder::recorderStateChanged, this, &Camera::updateRecorderState);
+ connect(m_mediaRecorder.data(), &QMediaRecorder::recorderStateChanged, this,
+ &Camera::updateRecorderState);
+ connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this,
+ &Camera::updateRecordTime);
+ connect(m_mediaRecorder.data(), &QMediaRecorder::errorChanged, this,
+ &Camera::displayRecorderError);
}
- m_imageCapture = new QImageCapture;
- m_captureSession.setImageCapture(m_imageCapture);
-
- connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this, &Camera::updateRecordTime);
- connect(m_mediaRecorder.data(), &QMediaRecorder::errorChanged, this, &Camera::displayRecorderError);
-
- connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this, &Camera::setExposureCompensation);
+ if (!m_imageCapture) {
+ m_imageCapture.reset(new QImageCapture);
+ m_captureSession.setImageCapture(m_imageCapture.get());
+ connect(m_imageCapture.get(), &QImageCapture::readyForCaptureChanged, this,
+ &Camera::readyForCapture);
+ connect(m_imageCapture.get(), &QImageCapture::imageCaptured, this,
+ &Camera::processCapturedImage);
+ connect(m_imageCapture.get(), &QImageCapture::imageSaved, this, &Camera::imageSaved);
+ connect(m_imageCapture.get(), &QImageCapture::errorOccurred, this,
+ &Camera::displayCaptureError);
+ }
m_captureSession.setVideoOutput(ui->viewfinder);
updateCameraActive(m_camera->isActive());
updateRecorderState(m_mediaRecorder->recorderState());
-
- connect(m_imageCapture, &QImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture);
- connect(m_imageCapture, &QImageCapture::imageCaptured, this, &Camera::processCapturedImage);
- connect(m_imageCapture, &QImageCapture::imageSaved, this, &Camera::imageSaved);
- connect(m_imageCapture, &QImageCapture::errorOccurred, this, &Camera::displayCaptureError);
readyForCapture(m_imageCapture->isReadyForCapture());
updateCaptureMode();
- if (m_camera->cameraFormat().isNull()) {
- auto formats = cameraDevice.videoFormats();
- if (!formats.isEmpty()) {
- // Choose a decent camera format: Maximum resolution at at least 30 FPS
- // we use 29 FPS to compare against as some cameras report 29.97 FPS...
- QCameraFormat bestFormat;
- for (const auto &fmt : formats) {
- if (bestFormat.maxFrameRate() < 29 && fmt.maxFrameRate() > bestFormat.maxFrameRate())
- bestFormat = fmt;
- else if (bestFormat.maxFrameRate() == fmt.maxFrameRate() &&
- bestFormat.resolution().width()*bestFormat.resolution().height() <
- fmt.resolution().width()*fmt.resolution().height())
- bestFormat = fmt;
- }
-
- m_camera->setCameraFormat(bestFormat);
- m_mediaRecorder->setVideoFrameRate(bestFormat.maxFrameRate());
- }
- }
-
m_camera->start();
}
-void Camera::keyPressEvent(QKeyEvent * event)
+void Camera::keyPressEvent(QKeyEvent *event)
{
if (event->isAutoRepeat())
return;
@@ -181,23 +169,17 @@ void Camera::keyPressEvent(QKeyEvent * event)
}
}
-void Camera::keyReleaseEvent(QKeyEvent *event)
-{
- QMainWindow::keyReleaseEvent(event);
-}
-
void Camera::updateRecordTime()
{
- QString str = QString("Recorded %1 sec").arg(m_mediaRecorder->duration()/1000);
+ QString str = tr("Recorded %1 sec").arg(m_mediaRecorder->duration() / 1000);
ui->statusbar->showMessage(str);
}
-void Camera::processCapturedImage(int requestId, const QImage& img)
+void Camera::processCapturedImage(int requestId, const QImage &img)
{
Q_UNUSED(requestId);
- QImage scaledImage = img.scaled(ui->viewfinder->size(),
- Qt::KeepAspectRatio,
- Qt::SmoothTransformation);
+ QImage scaledImage =
+ img.scaled(ui->viewfinder->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage));
@@ -217,7 +199,6 @@ void Camera::configureCaptureSettings()
void Camera::configureVideoSettings()
{
VideoSettings settingsDialog(m_mediaRecorder.data());
- settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
if (settingsDialog.exec())
settingsDialog.applySettings();
@@ -225,12 +206,10 @@ void Camera::configureVideoSettings()
void Camera::configureImageSettings()
{
- ImageSettings settingsDialog(m_imageCapture);
- settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ ImageSettings settingsDialog(m_imageCapture.get());
- if (settingsDialog.exec()) {
+ if (settingsDialog.exec() == QDialog::Accepted)
settingsDialog.applyImageSettings();
- }
}
void Camera::record()
@@ -260,7 +239,8 @@ void Camera::takeImage()
m_imageCapture->captureToFile();
}
-void Camera::displayCaptureError(int id, const QImageCapture::Error error, const QString &errorString)
+void Camera::displayCaptureError(int id, const QImageCapture::Error error,
+ const QString &errorString)
{
Q_UNUSED(id);
Q_UNUSED(error);
@@ -325,7 +305,7 @@ void Camera::updateRecorderState(QMediaRecorder::RecorderState state)
void Camera::setExposureCompensation(int index)
{
- m_camera->setExposureCompensation(index*0.5);
+ m_camera->setExposureCompensation(index * 0.5);
}
void Camera::displayRecorderError()
@@ -411,20 +391,26 @@ void Camera::saveMetaData()
for (int i = 0; i < QMediaMetaData::NumMetaData; i++) {
QString val = m_metaDataDialog->m_metaDataFields[i]->text();
if (!val.isEmpty()) {
- auto key = static_cast<QMediaMetaData::Key>(i);
- if (i == QMediaMetaData::CoverArtImage) {
+ const auto key = static_cast<QMediaMetaData::Key>(i);
+ switch (key) {
+ case QMediaMetaData::CoverArtImage: {
QImage coverArt(val);
data.insert(key, coverArt);
+ break;
}
- else if (i == QMediaMetaData::ThumbnailImage) {
+ case QMediaMetaData::ThumbnailImage: {
QImage thumbnail(val);
data.insert(key, thumbnail);
+ break;
}
- else if (i == QMediaMetaData::Date) {
+ case QMediaMetaData::Date: {
QDateTime date = QDateTime::fromString(val);
data.insert(key, date);
+ break;
}
- else {
+ case QMediaMetaData::HasHdrContent:
+ break;
+ default:
data.insert(key, val);
}
}
@@ -432,3 +418,4 @@ void Camera::saveMetaData()
m_mediaRecorder->setMetaData(data);
}
+#include "moc_camera.cpp"
diff --git a/examples/multimedia/camera/camera.h b/examples/multimedia/camera/camera.h
new file mode 100644
index 000000000..c92aa2d6a
--- /dev/null
+++ b/examples/multimedia/camera/camera.h
@@ -0,0 +1,104 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef CAMERA_H
+#define CAMERA_H
+
+#include <QAudioInput>
+#include <QCamera>
+#include <QImageCapture>
+#include <QMediaCaptureSession>
+#include <QMediaDevices>
+#include <QMediaMetaData>
+#include <QMediaRecorder>
+#include <QScopedPointer>
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Camera;
+}
+class QActionGroup;
+QT_END_NAMESPACE
+
+class MetaDataDialog;
+
+class Camera : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ Camera();
+
+public slots:
+ void saveMetaData();
+
+private slots:
+ void init();
+
+ void setCamera(const QCameraDevice &cameraDevice);
+
+ void startCamera();
+ void stopCamera();
+
+ void record();
+ void pause();
+ void stop();
+ void setMuted(bool);
+
+ void takeImage();
+ void displayCaptureError(int, QImageCapture::Error, const QString &errorString);
+
+ void configureCaptureSettings();
+ void configureVideoSettings();
+ void configureImageSettings();
+
+ void displayRecorderError();
+ void displayCameraError();
+
+ void updateCameraDevice(QAction *action);
+
+ void updateCameraActive(bool active);
+ void updateCaptureMode();
+ void updateRecorderState(QMediaRecorder::RecorderState state);
+ void setExposureCompensation(int index);
+
+ void updateRecordTime();
+
+ void processCapturedImage(int requestId, const QImage &img);
+
+ void displayViewfinder();
+ void displayCapturedImage();
+
+ void readyForCapture(bool ready);
+ void imageSaved(int id, const QString &fileName);
+
+ void updateCameras();
+
+ void showMetaDataDialog();
+
+protected:
+ void keyPressEvent(QKeyEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
+
+private:
+ Ui::Camera *ui;
+
+ QActionGroup *videoDevicesGroup = nullptr;
+
+ QMediaDevices m_devices;
+ QScopedPointer<QImageCapture> m_imageCapture;
+ QMediaCaptureSession m_captureSession;
+ QScopedPointer<QCamera> m_camera;
+ QScopedPointer<QAudioInput> m_audioInput;
+ QScopedPointer<QMediaRecorder> m_mediaRecorder;
+
+ bool m_isCapturingImage = false;
+ bool m_applicationExiting = false;
+ bool m_doImageCapture = true;
+
+ MetaDataDialog *m_metaDataDialog = nullptr;
+};
+
+#endif
diff --git a/examples/multimediawidgets/camera/camera.pro b/examples/multimedia/camera/camera.pro
index e1d98c06e..283d84640 100644
--- a/examples/multimediawidgets/camera/camera.pro
+++ b/examples/multimedia/camera/camera.pro
@@ -30,7 +30,7 @@ android|ios {
}
RESOURCES += camera.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/camera
INSTALLS += target
QT += widgets
diff --git a/examples/multimediawidgets/camera/camera.qrc b/examples/multimedia/camera/camera.qrc
index a915eb596..a915eb596 100644
--- a/examples/multimediawidgets/camera/camera.qrc
+++ b/examples/multimedia/camera/camera.qrc
diff --git a/examples/multimediawidgets/camera/camera.ui b/examples/multimedia/camera/camera.ui
index 560ee7fed..560ee7fed 100644
--- a/examples/multimediawidgets/camera/camera.ui
+++ b/examples/multimedia/camera/camera.ui
diff --git a/examples/multimediawidgets/camera/camera_mobile.ui b/examples/multimedia/camera/camera_mobile.ui
index 7f269b17b..7f269b17b 100644
--- a/examples/multimediawidgets/camera/camera_mobile.ui
+++ b/examples/multimedia/camera/camera_mobile.ui
diff --git a/examples/multimedia/camera/doc/images/camera-example.png b/examples/multimedia/camera/doc/images/camera-example.png
new file mode 100644
index 000000000..f7d7e4f67
--- /dev/null
+++ b/examples/multimedia/camera/doc/images/camera-example.png
Binary files differ
diff --git a/examples/multimedia/camera/doc/src/camera.qdoc b/examples/multimedia/camera/doc/src/camera.qdoc
new file mode 100644
index 000000000..ae6877129
--- /dev/null
+++ b/examples/multimedia/camera/doc/src/camera.qdoc
@@ -0,0 +1,92 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+/*!
+
+\example camera
+\title Camera Example
+\ingroup multimedia_examples
+\ingroup video_examples
+\ingroup camera_examples
+\examplecategory {Multimedia}
+\meta {tag} {widgets}
+\brief Shows how to capture a still image or record video.
+
+\image camera-example.png
+
+The Camera Example demonstrates how you can use \l{Qt Multimedia} to implement
+some basic Camera functionality to take still images and record video clips
+with audio.
+
+\include examples-run.qdocinc
+
+The example implements a \c Camera class that acts as our camera interface. It
+has a user interface, control functions, setting values and a means of defining
+the location where the image or video clip is to be saved. It will also store
+the image and video settings.
+
+The Camera class uses:
+\list
+ \li An instance of \l {QCamera}, the API class interface to the hardware.
+ \li An instance of \l {QImageCapture} to take still images.
+ \li An instance of \l {QMediaRecorder} to record video. It also contains
+ the user interface object.
+\endlist
+
+\section1 The Camera constructor
+
+The Camera constructor does some basic initialization of the user interface
+including disabling all buttons by default.
+
+\quotefromfile camera/camera.cpp
+\skipto Camera::Camera()
+\printuntil ui->metaDataButton->setEnabled(false);
+
+It seeks permissions for input device access:
+
+\skipto #if QT_CONFIG(permissions)
+\printuntil #endif
+
+Inputs are assigned:
+\printuntil updateCameras()
+
+ UI signals are connected to slots that react to the triggering event:
+\printuntil setCamera(QMediaDevices::defaultVideoInput());
+
+However, most of the work is done when the \e{setCamera()} function is called,
+passing in a \l QCameraDevice.
+
+\section1 setCamera()
+
+\c{setCamera()} sets up various connections between the user interface and the
+functionality of the Camera class using signals and slots. It also instantiates
+and initializes the \l {QCamera}, \l {QImageCapture}, and \l {QMediaRecorder}
+objects.
+
+\skipto void Camera::setCamera(const QCameraDevice &cameraDevice)
+\printto m_captureSession.setVideoOutput(ui->viewfinder);
+
+The still and video recording visual tabs are enabled:
+
+\printuntil updateCaptureMode();
+
+Finally the \l {QCamera::start}{start()} function of the \l{QCamera}
+object is called.
+
+\printuntil m_camera->start();
+
+\section1 Triggering capturing
+
+Now that the camera is ready for user commands it waits for a suitable event.
+Such an event can be a key press of either the \l {Qt::Key_CameraFocus} or
+\l {Qt::Key_Camera} buttons on the application window.
+
+Key_CameraFocus will simply display the preview and lock the camera settings.
+\printto case Qt::Key_Camera:
+
+\c Key_Camera will either call \e{takeImage()} if doing an image capture, or call
+\c record() or \c stop() (if already recording) on the QMediaRecorder instance
+when recording video.
+
+\printuntil break;
+
+*/
diff --git a/examples/multimediawidgets/camera/images/shutter.svg b/examples/multimedia/camera/images/shutter.svg
index 18493361d..18493361d 100644
--- a/examples/multimediawidgets/camera/images/shutter.svg
+++ b/examples/multimedia/camera/images/shutter.svg
diff --git a/examples/multimedia/camera/imagesettings.cpp b/examples/multimedia/camera/imagesettings.cpp
new file mode 100644
index 000000000..c2b022a70
--- /dev/null
+++ b/examples/multimedia/camera/imagesettings.cpp
@@ -0,0 +1,84 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "imagesettings.h"
+#include "ui_imagesettings.h"
+
+#include <QCamera>
+#include <QImageCapture>
+#include <QMediaCaptureSession>
+
+#include <QComboBox>
+
+#include <QDebug>
+
+using namespace Qt::StringLiterals;
+
+ImageSettings::ImageSettings(QImageCapture *imageCapture, QWidget *parent)
+ : QDialog(parent), ui(new Ui::ImageSettingsUi), imagecapture(imageCapture)
+{
+ ui->setupUi(this);
+
+ // image codecs
+ ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString()));
+ const auto supportedImageFormats = QImageCapture::supportedFormats();
+ for (const auto &f : supportedImageFormats) {
+ QString description = QImageCapture::fileFormatDescription(f);
+ ui->imageCodecBox->addItem(QImageCapture::fileFormatName(f) + ": " + description,
+ QVariant::fromValue(f));
+ }
+
+ ui->imageQualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
+
+ ui->imageResolutionBox->addItem(tr("Default Resolution"));
+ const QList<QSize> supportedResolutions =
+ imagecapture->captureSession()->camera()->cameraDevice().photoResolutions();
+ for (const QSize &resolution : supportedResolutions) {
+ ui->imageResolutionBox->addItem(
+ u"%1x%2"_s.arg(resolution.width()).arg(resolution.height()),
+ QVariant(resolution));
+ }
+
+ selectComboBoxItem(ui->imageCodecBox, QVariant::fromValue(imagecapture->fileFormat()));
+ selectComboBoxItem(ui->imageResolutionBox, QVariant(imagecapture->resolution()));
+ ui->imageQualitySlider->setValue(imagecapture->quality());
+}
+
+ImageSettings::~ImageSettings()
+{
+ delete ui;
+}
+
+void ImageSettings::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void ImageSettings::applyImageSettings() const
+{
+ imagecapture->setFileFormat(boxValue(ui->imageCodecBox).value<QImageCapture::FileFormat>());
+ imagecapture->setQuality(QImageCapture::Quality(ui->imageQualitySlider->value()));
+ imagecapture->setResolution(boxValue(ui->imageResolutionBox).toSize());
+}
+
+QVariant ImageSettings::boxValue(const QComboBox *box) const
+{
+ const int idx = box->currentIndex();
+ return idx != -1 ? box->itemData(idx) : QVariant{};
+}
+
+void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
+{
+ const int idx = box->findData(value);
+ if (idx != -1)
+ box->setCurrentIndex(idx);
+}
+
+#include "moc_imagesettings.cpp"
diff --git a/examples/multimedia/camera/imagesettings.h b/examples/multimedia/camera/imagesettings.h
new file mode 100644
index 000000000..0e2ef8e5b
--- /dev/null
+++ b/examples/multimedia/camera/imagesettings.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef IMAGESETTINGS_H
+#define IMAGESETTINGS_H
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QImageCapture;
+namespace Ui {
+class ImageSettingsUi;
+}
+QT_END_NAMESPACE
+
+class ImageSettings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ImageSettings(QImageCapture *imageCapture, QWidget *parent = nullptr);
+ ~ImageSettings();
+
+ void applyImageSettings() const;
+
+ QString format() const;
+ void setFormat(const QString &format);
+
+protected:
+ void changeEvent(QEvent *e) override;
+
+private:
+ QVariant boxValue(const QComboBox *box) const;
+ void selectComboBoxItem(QComboBox *box, const QVariant &value);
+
+ Ui::ImageSettingsUi *ui;
+ QImageCapture *imagecapture;
+};
+
+#endif // IMAGESETTINGS_H
diff --git a/examples/multimediawidgets/camera/imagesettings.ui b/examples/multimedia/camera/imagesettings.ui
index 8c59ca01d..8c59ca01d 100644
--- a/examples/multimediawidgets/camera/imagesettings.ui
+++ b/examples/multimedia/camera/imagesettings.ui
diff --git a/examples/multimediawidgets/camera/ios/Info.plist.in b/examples/multimedia/camera/ios/Info.plist.in
index 6a6b8db11..6a6b8db11 100644
--- a/examples/multimediawidgets/camera/ios/Info.plist.in
+++ b/examples/multimedia/camera/ios/Info.plist.in
diff --git a/examples/multimediawidgets/camera/macos/Info.plist.in b/examples/multimedia/camera/macos/Info.plist.in
index ae2d945f1..ae2d945f1 100644
--- a/examples/multimediawidgets/camera/macos/Info.plist.in
+++ b/examples/multimedia/camera/macos/Info.plist.in
diff --git a/examples/multimedia/camera/main.cpp b/examples/multimedia/camera/main.cpp
new file mode 100644
index 000000000..13554fc2b
--- /dev/null
+++ b/examples/multimedia/camera/main.cpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "camera.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Camera camera;
+ camera.show();
+
+ return app.exec();
+};
diff --git a/examples/multimedia/camera/metadatadialog.cpp b/examples/multimedia/camera/metadatadialog.cpp
new file mode 100644
index 000000000..8213baa6f
--- /dev/null
+++ b/examples/multimedia/camera/metadatadialog.cpp
@@ -0,0 +1,107 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "metadatadialog.h"
+
+#include <QMediaMetaData>
+
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QFileDialog>
+#include <QFormLayout>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QScrollArea>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include <QString>
+
+static QString defaultValue(QMediaMetaData::Key key)
+{
+ switch (key) {
+ case QMediaMetaData::Title:
+ return MetaDataDialog::tr("Qt Camera Example");
+ case QMediaMetaData::Author:
+ return MetaDataDialog::tr("The Qt Company");
+ case QMediaMetaData::Date:
+ return QDateTime::currentDateTime().toString();
+ default:
+ break;
+ }
+ return {};
+}
+
+MetaDataDialog::MetaDataDialog(QWidget *parent) : QDialog(parent)
+{
+ auto *viewport = new QWidget;
+ auto *metaDataLayout = new QFormLayout(viewport);
+
+ for (int i = 0; i < QMediaMetaData::NumMetaData; ++i) {
+ const auto key = static_cast<QMediaMetaData::Key>(i);
+ QString label = QMediaMetaData::metaDataKeyToString(key);
+ auto *lineEdit = new QLineEdit(defaultValue(key));
+ lineEdit->setClearButtonEnabled(true);
+ m_metaDataFields[key] = lineEdit;
+
+ switch (key) {
+ case QMediaMetaData::ThumbnailImage: {
+ QPushButton *openThumbnail = new QPushButton(tr("Open"));
+ connect(openThumbnail, &QPushButton::clicked, this,
+ &MetaDataDialog::openThumbnailImage);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(lineEdit);
+ layout->addWidget(openThumbnail);
+ metaDataLayout->addRow(label, layout);
+ }
+ break;
+ case QMediaMetaData::CoverArtImage: {
+ QPushButton *openCoverArt = new QPushButton(tr("Open"));
+ connect(openCoverArt, &QPushButton::clicked, this, &MetaDataDialog::openCoverArtImage);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(lineEdit);
+ layout->addWidget(openCoverArt);
+ metaDataLayout->addRow(label, layout);
+ }
+ break;
+ case QMediaMetaData::HasHdrContent:
+ break; // Read-only
+ default:
+ metaDataLayout->addRow(label, lineEdit);
+ break;
+ }
+ }
+
+ QScrollArea *scrollArea = new QScrollArea;
+ scrollArea->setWidget(viewport);
+ auto *dialogLayout = new QVBoxLayout(this);
+ dialogLayout->addWidget(scrollArea);
+
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ dialogLayout->addWidget(buttonBox);
+
+ setWindowTitle(tr("Set Metadata"));
+ resize(400, 300);
+
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &MetaDataDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &MetaDataDialog::reject);
+}
+
+void MetaDataDialog::openThumbnailImage()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::currentPath(),
+ tr("Image Files (*.png *.jpg *.bmp)"));
+ if (!fileName.isEmpty())
+ m_metaDataFields[QMediaMetaData::ThumbnailImage]->setText(fileName);
+}
+
+void MetaDataDialog::openCoverArtImage()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::currentPath(),
+ tr("Image Files (*.png *.jpg *.bmp)"));
+ if (!fileName.isEmpty())
+ m_metaDataFields[QMediaMetaData::CoverArtImage]->setText(fileName);
+}
+
+#include "moc_metadatadialog.cpp"
diff --git a/examples/multimedia/camera/metadatadialog.h b/examples/multimedia/camera/metadatadialog.h
new file mode 100644
index 000000000..5bb5a4b0b
--- /dev/null
+++ b/examples/multimedia/camera/metadatadialog.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <QDialog>
+#include <QMediaMetaData>
+
+QT_BEGIN_NAMESPACE
+class QLabel;
+class QLineEdit;
+QT_END_NAMESPACE
+
+//! [0]
+class MetaDataDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit MetaDataDialog(QWidget *parent = nullptr);
+
+ QLineEdit *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
+
+private slots:
+ void openThumbnailImage();
+ void openCoverArtImage();
+};
+//! [0]
+
+#endif
diff --git a/examples/multimedia/camera/videosettings.cpp b/examples/multimedia/camera/videosettings.cpp
new file mode 100644
index 000000000..68177e0f3
--- /dev/null
+++ b/examples/multimedia/camera/videosettings.cpp
@@ -0,0 +1,196 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videosettings.h"
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+# include "ui_videosettings_mobile.h"
+#else
+# include "ui_videosettings.h"
+#endif
+
+#include <QAudioDevice>
+#include <QAudioInput>
+#include <QCamera>
+#include <QCameraDevice>
+#include <QMediaCaptureSession>
+#include <QMediaFormat>
+#include <QMediaRecorder>
+
+#include <QComboBox>
+#include <QSpinBox>
+
+#include <QDebug>
+#include <QTextStream>
+
+static QString toFormattedString(const QCameraFormat &cameraFormat)
+{
+ QString string;
+ QTextStream str(&string);
+ str << QVideoFrameFormat::pixelFormatToString(cameraFormat.pixelFormat())
+ << ' ' << cameraFormat.resolution().width()
+ << 'x' << cameraFormat.resolution().height()
+ << ' ' << cameraFormat.minFrameRate()
+ << '-' << cameraFormat.maxFrameRate() << "FPS";
+ return string;
+}
+
+VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent)
+ : QDialog(parent), ui(new Ui::VideoSettingsUi), mediaRecorder(mediaRecorder)
+{
+ ui->setupUi(this);
+
+ // sample rate:
+ auto audioDevice = mediaRecorder->captureSession()->audioInput()->device();
+ ui->audioSampleRateBox->setRange(audioDevice.minimumSampleRate(),
+ audioDevice.maximumSampleRate());
+
+ // camera format
+ ui->videoFormatBox->addItem(tr("Default camera format"));
+
+ auto *camera = mediaRecorder->captureSession()->camera();
+ const QList<QCameraFormat> videoFormats = camera->cameraDevice().videoFormats();
+
+ for (const QCameraFormat &format : videoFormats)
+ ui->videoFormatBox->addItem(toFormattedString(format), QVariant::fromValue(format));
+
+ connect(ui->videoFormatBox, &QComboBox::currentIndexChanged, [this](int /*index*/) {
+ this->setFpsRange(boxValue(ui->videoFormatBox).value<QCameraFormat>());
+ });
+
+ setFpsRange(camera->cameraFormat());
+
+ connect(ui->fpsSlider, &QSlider::valueChanged, ui->fpsSpinBox, &QSpinBox::setValue);
+ connect(ui->fpsSpinBox, &QSpinBox::valueChanged, ui->fpsSlider, &QSlider::setValue);
+
+ updateFormatsAndCodecs();
+ connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+ connect(ui->videoCodecBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+ connect(ui->containerFormatBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+
+ ui->qualitySlider->setRange(0, int(QMediaRecorder::VeryHighQuality));
+
+ QMediaFormat format = mediaRecorder->mediaFormat();
+ selectComboBoxItem(ui->containerFormatBox, QVariant::fromValue(format.fileFormat()));
+ selectComboBoxItem(ui->audioCodecBox, QVariant::fromValue(format.audioCodec()));
+ selectComboBoxItem(ui->videoCodecBox, QVariant::fromValue(format.videoCodec()));
+
+ ui->qualitySlider->setValue(mediaRecorder->quality());
+ ui->audioSampleRateBox->setValue(mediaRecorder->audioSampleRate());
+ selectComboBoxItem(ui->videoFormatBox,
+ QVariant::fromValue(camera->cameraFormat()));
+
+ ui->fpsSlider->setValue(mediaRecorder->videoFrameRate());
+ ui->fpsSpinBox->setValue(mediaRecorder->videoFrameRate());
+}
+
+VideoSettings::~VideoSettings()
+{
+ delete ui;
+}
+
+void VideoSettings::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void VideoSettings::setFpsRange(const QCameraFormat &format)
+{
+ ui->fpsSlider->setRange(format.minFrameRate(), format.maxFrameRate());
+ ui->fpsSpinBox->setRange(format.minFrameRate(), format.maxFrameRate());
+}
+
+void VideoSettings::applySettings()
+{
+ QMediaFormat format;
+ format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+ format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
+
+ mediaRecorder->setMediaFormat(format);
+ mediaRecorder->setQuality(QMediaRecorder::Quality(ui->qualitySlider->value()));
+ mediaRecorder->setAudioSampleRate(ui->audioSampleRateBox->value());
+
+ const auto &cameraFormat = boxValue(ui->videoFormatBox).value<QCameraFormat>();
+ mediaRecorder->setVideoResolution(cameraFormat.resolution());
+ mediaRecorder->setVideoFrameRate(ui->fpsSlider->value());
+
+ mediaRecorder->captureSession()->camera()->setCameraFormat(cameraFormat);
+}
+
+void VideoSettings::updateFormatsAndCodecs()
+{
+ if (m_updatingFormats)
+ return;
+ m_updatingFormats = true;
+
+ QMediaFormat format;
+ if (ui->containerFormatBox->count())
+ format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
+ if (ui->audioCodecBox->count())
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+ if (ui->videoCodecBox->count())
+ format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
+
+ int currentIndex = 0;
+ ui->audioCodecBox->clear();
+ ui->audioCodecBox->addItem(tr("Default audio codec"),
+ QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
+ for (auto codec : format.supportedAudioCodecs(QMediaFormat::Encode)) {
+ if (codec == format.audioCodec())
+ currentIndex = ui->audioCodecBox->count();
+ ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec),
+ QVariant::fromValue(codec));
+ }
+ ui->audioCodecBox->setCurrentIndex(currentIndex);
+
+ currentIndex = 0;
+ ui->videoCodecBox->clear();
+ ui->videoCodecBox->addItem(tr("Default video codec"),
+ QVariant::fromValue(QMediaFormat::VideoCodec::Unspecified));
+ for (auto codec : format.supportedVideoCodecs(QMediaFormat::Encode)) {
+ if (codec == format.videoCodec())
+ currentIndex = ui->videoCodecBox->count();
+ ui->videoCodecBox->addItem(QMediaFormat::videoCodecDescription(codec),
+ QVariant::fromValue(codec));
+ }
+ ui->videoCodecBox->setCurrentIndex(currentIndex);
+
+ currentIndex = 0;
+ ui->containerFormatBox->clear();
+ ui->containerFormatBox->addItem(tr("Default file format"),
+ QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
+ for (auto container : format.supportedFileFormats(QMediaFormat::Encode)) {
+ if (container == format.fileFormat())
+ currentIndex = ui->containerFormatBox->count();
+ ui->containerFormatBox->addItem(QMediaFormat::fileFormatDescription(container),
+ QVariant::fromValue(container));
+ }
+ ui->containerFormatBox->setCurrentIndex(currentIndex);
+
+ m_updatingFormats = false;
+}
+
+QVariant VideoSettings::boxValue(const QComboBox *box) const
+{
+ const int idx = box->currentIndex();
+ return idx != -1 ? box->itemData(idx) : QVariant{};
+}
+
+void VideoSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
+{
+ const int idx = box->findData(value);
+ if (idx != -1)
+ box->setCurrentIndex(idx);
+}
+
+#include "moc_videosettings.cpp"
diff --git a/examples/multimedia/camera/videosettings.h b/examples/multimedia/camera/videosettings.h
new file mode 100644
index 000000000..358b1fb16
--- /dev/null
+++ b/examples/multimedia/camera/videosettings.h
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOSETTINGS_H
+#define VIDEOSETTINGS_H
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QCameraFormat;
+class QComboBox;
+class QMediaRecorder;
+namespace Ui {
+class VideoSettingsUi;
+}
+QT_END_NAMESPACE
+
+class VideoSettings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr);
+ ~VideoSettings();
+
+ void applySettings();
+ void updateFormatsAndCodecs();
+
+protected:
+ void changeEvent(QEvent *e) override;
+
+private:
+ void setFpsRange(const QCameraFormat &format);
+ QVariant boxValue(const QComboBox *) const;
+ void selectComboBoxItem(QComboBox *box, const QVariant &value);
+
+ Ui::VideoSettingsUi *ui;
+ QMediaRecorder *mediaRecorder;
+ bool m_updatingFormats = false;
+};
+
+#endif // VIDEOSETTINGS_H
diff --git a/examples/multimediawidgets/camera/videosettings.ui b/examples/multimedia/camera/videosettings.ui
index 3c1f71f11..3c1f71f11 100644
--- a/examples/multimediawidgets/camera/videosettings.ui
+++ b/examples/multimedia/camera/videosettings.ui
diff --git a/examples/multimediawidgets/camera/videosettings_mobile.ui b/examples/multimedia/camera/videosettings_mobile.ui
index 6584f07f9..6584f07f9 100644
--- a/examples/multimediawidgets/camera/videosettings_mobile.ui
+++ b/examples/multimedia/camera/videosettings_mobile.ui
diff --git a/examples/multimedia/declarative-camera/CMakeLists.txt b/examples/multimedia/declarative-camera/CMakeLists.txt
index 7bc0ff7b3..50b0ba48d 100644
--- a/examples/multimedia/declarative-camera/CMakeLists.txt
+++ b/examples/multimedia/declarative-camera/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(declarative-camera LANGUAGES CXX)
@@ -40,6 +43,7 @@ set(declarative-camera_resource_files
"CameraListPopup.qml"
"CameraPropertyButton.qml"
"CameraPropertyPopup.qml"
+ "FlashControl.qml"
"PhotoCaptureControls.qml"
"PhotoPreview.qml"
"Popup.qml"
diff --git a/examples/multimedia/declarative-camera/CameraButton.qml b/examples/multimedia/declarative-camera/CameraButton.qml
index 1547e015f..43837bcb3 100644
--- a/examples/multimedia/declarative-camera/CameraButton.qml
+++ b/examples/multimedia/declarative-camera/CameraButton.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
diff --git a/examples/multimedia/declarative-camera/CameraListButton.qml b/examples/multimedia/declarative-camera/CameraListButton.qml
index 2b2716eb7..b6361eac2 100644
--- a/examples/multimedia/declarative-camera/CameraListButton.qml
+++ b/examples/multimedia/declarative-camera/CameraListButton.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -91,23 +44,30 @@ Item {
name: "MobilePortrait"
AnchorChanges {
target: popup
- anchors.bottom: parent.top;
+ // qmllint disable incompatible-type
+ anchors.bottom: cameraListButton.top
+ anchors.left: cameraListButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/CameraListPopup.qml b/examples/multimedia/declarative-camera/CameraListPopup.qml
index a9ccb6275..83c9843ee 100644
--- a/examples/multimedia/declarative-camera/CameraListPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraListPopup.qml
@@ -1,61 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
import QtQuick
+import QtMultimedia
Popup {
id: cameraListPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model[view.currentIndex]
+ property cameraDevice currentValue
+ property cameraDevice currentItem : model[view.currentIndex]
property int itemWidth : 200
property int itemHeight : 50
@@ -76,11 +31,16 @@ Popup {
clip: true
delegate: Item {
+ id: cameraListItem
+
+ required property int index
+ required property cameraDevice modelData
+
width: cameraListPopup.itemWidth
height: cameraListPopup.itemHeight
Text {
- text: modelData.description
+ text: cameraListItem.modelData.description
anchors.fill: parent
anchors.margins: 5
@@ -96,8 +56,9 @@ Popup {
MouseArea {
anchors.fill: parent
onClicked: {
- view.currentIndex = index
- cameraListPopup.currentValue = modelData
+ view.currentIndex = cameraListItem.index
+ cameraListPopup.currentValue = cameraListItem.modelData
+ cameraListPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/CameraPropertyButton.qml b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
index 91961ebf0..3a9e60a98 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyButton.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
id: propertyButton
@@ -90,23 +42,30 @@ Item {
name: "MobilePortrait"
AnchorChanges {
target: popup
- anchors.bottom: parent.top;
+ // qmllint disable incompatible-type
+ anchors.bottom: propertyButton.top
+ anchors.left: propertyButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
AnchorChanges {
target: popup
- anchors.verticalCenter: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.verticalCenter: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
index 6fc125144..774775a5b 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
@@ -1,61 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
import QtQuick
Popup {
id: propertyPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model.get(view.currentIndex)
+ property var currentValue
+ property var currentItem : model.get(view.currentIndex)
property int itemWidth : 100
property int itemHeight : 70
@@ -85,21 +39,26 @@ Popup {
snapMode: ListView.SnapOneItem
highlightFollowsCurrentItem: true
highlight: Rectangle { color: "gray"; radius: 5 }
- currentIndex: indexForValue(propertyPopup.currentValue)
+ currentIndex: propertyPopup.indexForValue(propertyPopup.currentValue)
delegate: Item {
+ id: propertyItem
+
+ required property url icon
+ required property var value
+
width: propertyPopup.itemWidth
height: 70
Image {
anchors.centerIn: parent
- source: icon
+ source: propertyItem.icon
}
MouseArea {
anchors.fill: parent
onClicked: {
- propertyPopup.currentValue = value
- propertyPopup.selected(value)
+ propertyPopup.currentValue = propertyItem.value
+ propertyPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/FlashControl.qml b/examples/multimedia/declarative-camera/FlashControl.qml
new file mode 100644
index 000000000..61550f098
--- /dev/null
+++ b/examples/multimedia/declarative-camera/FlashControl.qml
@@ -0,0 +1,65 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Item {
+ id: flashControl
+
+ height: column.height
+
+ property Camera cameraDevice
+ property bool mIsFlashSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isFlashModeSupported(Camera.FlashOn) : false
+ property bool mIsTorchSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isTorchModeSupported(Camera.TorchOn) : false
+
+ Column {
+ id: column
+
+ Switch {
+ id: flashModeControl
+ visible: flashControl.mIsFlashSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Flash"
+ contentItem: Text {
+ text: flashModeControl.text
+ color: "white"
+ leftPadding: flashModeControl.indicator.width + flashModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (torchModeControl.checked)
+ torchModeControl.toggle();
+ flashControl.cameraDevice.flashMode = Camera.FlashOn
+
+ } else {
+ flashControl.cameraDevice.flashMode = Camera.FlashOff
+ }
+ }
+ }
+
+ Switch {
+ id: torchModeControl
+ visible: flashControl.mIsTorchSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Torch"
+ contentItem: Text {
+ text: torchModeControl.text
+ color: "white"
+ leftPadding: torchModeControl.indicator.width + torchModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (flashModeControl.checked)
+ flashModeControl.toggle();
+ flashControl.cameraDevice.torchMode = Camera.TorchOn
+ } else {
+ flashControl.cameraDevice.torchMode = Camera.TorchOff
+ }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/declarative-camera/Info.plist b/examples/multimedia/declarative-camera/Info.plist
index d664a2460..7a1b26e1e 100644
--- a/examples/multimedia/declarative-camera/Info.plist
+++ b/examples/multimedia/declarative-camera/Info.plist
@@ -13,7 +13,7 @@
<key>CFBundleExecutable</key>
<string>declarative-camera</string>
<key>CFBundleIdentifier</key>
- <string>com.digia.${PRODUCT_NAME:rfc1034identifier}</string>
+ <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleDisplayName</key>
<string>declarative-camera</string>
<key>CFBundleName</key>
diff --git a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
index 0f2745665..f4ecee37b 100644
--- a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -71,19 +24,19 @@ FocusScope {
GridLayout {
id: buttonsColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraButton {
text: "Capture"
- implicitWidth: buttonsWidth
- visible: captureSession.imageCapture.readyForCapture
- onClicked: captureSession.imageCapture.captureToFile("")
+ implicitWidth: captureControls.buttonsWidth
+ visible: captureControls.captureSession.imageCapture.readyForCapture
+ onClicked: captureControls.captureSession.imageCapture.captureToFile("")
}
CameraPropertyButton {
id : wbModesButton
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
state: captureControls.state
value: Camera.WhiteBalanceAuto
model: ListModel {
@@ -117,12 +70,12 @@ FocusScope {
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "View"
anchors.fill: parent
- onClicked:state = captureControls.previewSelected()
+ onClicked: captureControls.previewSelected()
visible: captureControls.previewAvailable
}
}
@@ -130,25 +83,25 @@ FocusScope {
GridLayout {
id: bottomColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
state: captureControls.state
- onValueChanged: captureSession.camera.cameraDevice = value
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
}
CameraButton {
text: "Switch to Video"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.videoModeSelected()
}
CameraButton {
id: quitButton
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
text: "Quit"
onClicked: Qt.quit()
}
@@ -156,107 +109,120 @@ FocusScope {
}
ZoomControl {
+ id: zoomControl
x : 0
- y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
- currentZoom: camera.zoomFactor
- maximumZoom: camera.maximumZoomFactor
- onZoomTo: camera.setDigitalZoom(value)
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
+ }
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
+
+ cameraDevice: captureControls.captureSession.camera
}
states: [
State {
name: "MobilePortrait"
PropertyChanges {
- target: buttonPaneShadow
- width: parent.width
- height: captureControls.buttonsPanelPortraitHeight
- }
- PropertyChanges {
- target: buttonsColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
- }
- PropertyChanges {
- target: bottomColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: captureControls.buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
}
AnchorChanges {
target: buttonPaneShadow
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
PropertyChanges {
- target: buttonPaneShadow
- width: buttonsPanelWidth
- height: parent.height
- }
- PropertyChanges {
- target: buttonsColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
- }
- PropertyChanges {
- target: bottomColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: parent.left
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
PropertyChanges {
- target: buttonPaneShadow
- width: bottomColumn.width + 16
- height: parent.height
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.bottom: parent.bottom
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/PhotoPreview.qml b/examples/multimedia/declarative-camera/PhotoPreview.qml
index 8aeb116dd..98af8a12a 100644
--- a/examples/multimedia/declarative-camera/PhotoPreview.qml
+++ b/examples/multimedia/declarative-camera/PhotoPreview.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
property alias source : preview.source
diff --git a/examples/multimedia/declarative-camera/Popup.qml b/examples/multimedia/declarative-camera/Popup.qml
index db304dccb..fc57f3002 100644
--- a/examples/multimedia/declarative-camera/Popup.qml
+++ b/examples/multimedia/declarative-camera/Popup.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
@@ -64,12 +17,12 @@ Rectangle {
states: [
State {
name: "invisible"
- PropertyChanges { target: popup; opacity: 0 }
+ PropertyChanges { popup.opacity: 0 }
},
State {
name: "visible"
- PropertyChanges { target: popup; opacity: 1.0 }
+ PropertyChanges { popup.opacity: 1.0 }
}
]
diff --git a/examples/multimedia/declarative-camera/VideoCaptureControls.qml b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
index b2dbe3bd3..39acae106 100644
--- a/examples/multimedia/declarative-camera/VideoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -71,67 +24,68 @@ FocusScope {
GridLayout {
id: buttonsColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "Record"
anchors.fill: parent
- visible: captureSession.recorder.recorderState !== MediaRecorder.RecordingState
- onClicked: captureSession.recorder.record()
+ visible: captureControls.captureSession.recorder.recorderState !== MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.record()
}
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
id: stopButton
text: "Stop"
anchors.fill: parent
- visible: captureSession.recorder.recorderState === MediaRecorder.RecordingState
- onClicked: captureSession.recorder.stop()
+ visible: captureControls.captureSession.recorder.recorderState === MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.stop()
}
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "View"
anchors.fill: parent
onClicked: captureControls.previewSelected()
//don't show View button during recording
- visible: captureSession.recorder.actualLocation && !stopButton.visible
+ visible: captureControls.captureSession.recorder.actualLocation.toString() !== ""
+ && !stopButton.visible
}
}
}
GridLayout {
id: bottomColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- implicitWidth: buttonsWidth
- onValueChanged: captureSession.camera.cameraDevice = value
+ implicitWidth: captureControls.buttonsWidth
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
state: captureControls.state
}
CameraButton {
text: "Switch to Photo"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.photoModeSelected()
}
CameraButton {
id: quitButton
text: "Quit"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: Qt.quit()
}
}
@@ -139,106 +93,118 @@ FocusScope {
ZoomControl {
x : 0
- y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
- currentZoom: captureSession.camera.zoomFactor
- maximumZoom: captureSession.camera.maximumZoomFactor
- onZoomTo: captureSession.camera.zoomFactor = value
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
+ }
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
+
+ cameraDevice: captureControls.captureSession.camera
}
states: [
State {
name: "MobilePortrait"
PropertyChanges {
- target: buttonPaneShadow
- width: parent.width
- height: buttonsPanelPortraitHeight
- }
- PropertyChanges {
- target: buttonsColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
- }
- PropertyChanges {
- target: bottomColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
}
AnchorChanges {
target: buttonPaneShadow
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
PropertyChanges {
- target: buttonPaneShadow
- width: buttonsPanelWidth
- height: parent.height
- }
- PropertyChanges {
- target: buttonsColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
- }
- PropertyChanges {
- target: bottomColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: buttonsColumn;
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: parent.left;
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.top: parent.top;
- anchors.bottom: parent.bottom;
- anchors.right: parent.right;
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
PropertyChanges {
- target: buttonPaneShadow;
- width: bottomColumn.width + 16;
- height: parent.height;
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
}
AnchorChanges {
- target: buttonPaneShadow;
- anchors.top: parent.top;
- anchors.right: parent.right;
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: buttonsColumn;
- anchors.top: parent.top
- anchors.right: parent.right
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.bottom: parent.bottom;
- anchors.right: parent.right;
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/VideoPreview.qml b/examples/multimedia/declarative-camera/VideoPreview.qml
index e2d6a47e0..f7b306794 100644
--- a/examples/multimedia/declarative-camera/VideoPreview.qml
+++ b/examples/multimedia/declarative-camera/VideoPreview.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -65,7 +18,7 @@ Item {
videoPreview.closed();
}
onSourceChanged: {
- if (visible && source !== "")
+ if (videoPreview.visible && source !== "")
play();
}
diff --git a/examples/multimedia/declarative-camera/ZoomControl.qml b/examples/multimedia/declarative-camera/ZoomControl.qml
index 9107ab4ae..c60495fd0 100644
--- a/examples/multimedia/declarative-camera/ZoomControl.qml
+++ b/examples/multimedia/declarative-camera/ZoomControl.qml
@@ -1,61 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
id : zoomControl
property real currentZoom : 1
property real maximumZoom : 1
- signal zoomTo(real value)
+ signal zoomTo(real target)
visible: zoomControl.maximumZoom > 1
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qml b/examples/multimedia/declarative-camera/declarative-camera.qml
index 6260c4281..24477150e 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qml
+++ b/examples/multimedia/declarative-camera/declarative-camera.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -56,30 +9,13 @@ Rectangle {
width: 800
height: 480
+
color: "black"
state: "PhotoCapture"
property string platformScreen: ""
- property int buttonsPanelLandscapeWidth: 328
- property int buttonsPanelPortraitHeight: 180
-
- onWidthChanged: {
- setState()
- }
- function setState() {
- if (Qt.platform.os === "android" || Qt.platform.os === "ios") {
- if (Screen.desktopAvailableWidth < Screen.desktopAvailableHeight) {
- stillControls.state = "MobilePortrait";
- } else {
- stillControls.state = "MobileLandscape";
- }
- } else {
- stillControls.state = "Other";
- }
- console.log("State: " + stillControls.state);
- stillControls.buttonsWidth = (stillControls.state === "MobilePortrait")
- ? Screen.desktopAvailableWidth/3.4 : 144
- }
+ property int buttonsPanelLandscapeWidth: cameraUI.width/2
+ property int buttonsPanelPortraitHeight: cameraUI.height/3
states: [
State {
@@ -151,18 +87,42 @@ Rectangle {
VideoOutput {
id: viewfinder
visible: ((cameraUI.state === "PhotoCapture") || (cameraUI.state === "VideoCapture"))
-
- x: 0
- y: 0
- width: ((stillControls.state === "MobilePortrait") ? parent.width : (parent.width-buttonsPanelLandscapeWidth))
- height: ((stillControls.state === "MobilePortrait") ? parent.height - buttonsPanelPortraitHeight : parent.height)
+ anchors.fill: parent
// autoOrientation: true
}
+ Item {
+ id: controlLayout
+
+ readonly property bool isMobile: Qt.platform.os === "android" || Qt.platform.os === "ios"
+ readonly property bool isLandscape: Screen.desktopAvailableWidth >= Screen.desktopAvailableHeight
+ property int buttonsWidth: state === "MobilePortrait" ? Screen.desktopAvailableWidth / 3.4 : 114
+
+ states: [
+ State {
+ name: "MobileLandscape"
+ when: controlLayout.isMobile && controlLayout.isLandscape
+ },
+ State {
+ name: "MobilePortrait"
+ when: controlLayout.isMobile && !controlLayout.isLandscape
+ },
+ State {
+ name: "Other"
+ when: !controlLayout.isMobile
+ }
+ ]
+
+ onStateChanged: {
+ console.log("State: " + controlLayout.state)
+ }
+ }
+
PhotoCaptureControls {
id: stillControls
- state: setState()
+ state: controlLayout.state
anchors.fill: parent
+ buttonsWidth: controlLayout.buttonsWidth
buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
captureSession: captureSession
@@ -174,9 +134,9 @@ Rectangle {
VideoCaptureControls {
id: videoControls
- state: stillControls.state
+ state: controlLayout.state
anchors.fill: parent
- buttonsWidth: stillControls.buttonsWidth
+ buttonsWidth: controlLayout.buttonsWidth
buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
captureSession: captureSession
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qrc b/examples/multimedia/declarative-camera/declarative-camera.qrc
index e4f6ee981..ddfcefa7b 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qrc
+++ b/examples/multimedia/declarative-camera/declarative-camera.qrc
@@ -12,6 +12,7 @@
<file>CameraButton.qml</file>
<file>CameraListPopup.qml</file>
<file>CameraListButton.qml</file>
+ <file>FlashControl.qml</file>
<file>images/camera_auto_mode.png</file>
<file>images/camera_camera_setting.png</file>
<file>images/camera_flash_auto.png</file>
diff --git a/examples/multimedia/declarative-camera/doc/images/CaptureControls.png b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
new file mode 100644
index 000000000..8c24d8030
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/FlashControls.png b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
new file mode 100644
index 000000000..93eec867b
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
new file mode 100644
index 000000000..c35be7beb
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/ZoomControl.png b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
new file mode 100644
index 000000000..d628e60f1
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-camera.png b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
index 0cd61f0a0..4b710670d 100644
--- a/examples/multimedia/declarative-camera/doc/images/qml-camera.png
+++ b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
new file mode 100644
index 000000000..7adfdb021
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
index 6aa8e8fa6..c6701a68b 100644
--- a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
+++ b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
@@ -1,55 +1,158 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\example multimedia/declarative-camera
-\title QML Camera Example
+\example declarative-camera
+\title QML Camera Application
\ingroup multimedia_examples
\ingroup camera_examples_qml
-\brief The Camera Example shows how to use the API to capture a still image
-or video.
+\examplecategory {Multimedia}
+\examplecategory {Mobile}
+\brief This Qt Quick based application shows how to use the API to capture a
+still image or video.
\image qml-camera.png
This example demonstrates how to access camera functions via QML.
-It shows how to change settings and to capture images.
+It shows how to change settings and capture images or video.
\include examples-run.qdocinc
-\section1 Application Structure
+\section1 Application structure
-Most of the QML code supports the user interface for this application with the
-camera types being mostly found in \e {declarative-camera.qml} and
-\e {CaptureControls.qml}.
+Most of the QML code in this example supports the user interface. Custom types
+that support the requirements have been implemented using existing Qt Quick
+controls.
-CaptureControls, which is implemented in \e {CaptureControls.qml},
-generates a column on the right hand side of the screen which includes control
-buttons for focus (not initially visible), capture, flash modes,
-white balance, exposure compensation, and if a preview is
-available, a preview button. The last button exits from the application.
+\section1 Using screen orientation to select layout
+The orientation and control layout state logic is encapsulated in a separate
+Item, \c controlLayout like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto Item {
+\printuntil /^ }/
+
+The \c stillControls and \c videoControls objects both bind to the \c state
+and \c buttonsWidth properties of this Item, as shown in \c stillControls:
+
+\skipto PhotoCaptureControls
+\printuntil /^ }/
+
+To support debugging, a message about layout state change is logged.
+
+Here is the portrait layout:
+
+\image qml-declarative-portrait.png
+
+You can see the \c state property is initially set as \c PhotoCapture.
+
+Then the \c states themselves are defined like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto states: [
+\printuntil /^ ]/
+
+\section1 Controls for capturing
+
+Controls for capturing are implemented in \c PhotoCaptureControls.qml and
+VideoCaptureControls.qml. They each are based on a \l FocusScope that defines
+common buttons dimensions and margins that are used by the control buttons and
+then declares the buttons.
+
+This generates a column on the right hand side of the screen which includes,
+listed top to bottom, the following controls:
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ \list
+ \li A \c Capture or \c Record button, which initiates capturing.
+ \li A \c{capture properties} button that displays the icon of the current
+ white balance mode selected and when pressed uses a pop-up to displays
+ the following option's icons:
+ \list
+ \li Flash mode (if available)
+ \li White balance modes
+ \li Exposure compensation
+ \endlist
+ \li A \c View button, once something has been captured.
+ \li A button which displays the currently selected capture device and
+ when pressed provides a list of available devices to switch to, using a
+ pop-up.
+ \li A \c{Switch To} button that displays the alternate capture mode
+ (video or photo) depending on the current active selection and switches
+ the mode when pressed.
+ \li A \c Quit button, that exits the application.
+ \endlist
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage CaptureControls.png
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage VideoCaptureControls.png
+ \enddiv
+\enddiv
+
+\section1 Image capturing
+
+The button that triggers this is defined in CameraButton.qml:
+but its interaction with the camera is in the controls types, lets look at
+PhotoCaptureControls:
+
+\quotefromfile declarative-camera/PhotoCaptureControls.qml
+\skipto CameraButton {
+\printto CameraPropertyButton {
+
+\section1 Zoom control
+
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ Implemented in \c ZoomControl.qml the ZoomControl type is based on an Item
+ and creates a bar that represents the zoom level, which can also be dragged.
+ It uses an exponential calculation method to determine the zoom factor given
+ the position of the \c grove.
+
+ The bar is only visible if the initialZoom is greater than 1. This means
+ the currently active camera has a zoom function.
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage ZoomControl.png
+ \enddiv
+\enddiv
+
+\quotefromfile declarative-camera/ZoomControl.qml
+\skipto Item {
+\printuntil font.pixelSize: 18
+
+In PhotoCaptureControls.qml and VideoCaptureControls.qml the signal \c zoomTo
+will set the selected camera's \l{Camera::}{zoomFactor} property to the
+calculated \c target value, as well as updating the ZoomControl bar.
+
+\quotefromfile declarative-camera/VideoCaptureControls.qml
+\skipto ZoomControl {
+\printto FlashControl {
+
+\section1 Flash and torch control
+
+\image FlashControls.png
+
+Defined in \c FlashControl.qml this enables flash mode selection and torch
+functionality to be toggled via a Switch. As with the zoom control, the switches
+are only visible on top of the preview window if the active device supports
+these functions.
+
+Here we check if the functions are supported:
+
+\quotefromfile declarative-camera/FlashControl.qml
+\skipto property Camera cameraDevice
+\printline Camera
+\printline FlashOn
+\printline TorchOn
+
+Here we implement the \c flashModeControl switch, which also directly controls
+the Camera device.
+
+\skipto Switch {
+\printuntil /^ }/
+
+Torch control is implemented in a similar way.
*/
diff --git a/examples/multimedia/declarative-camera/permission-denied.qml b/examples/multimedia/declarative-camera/permission-denied.qml
new file mode 100644
index 000000000..19eb58ead
--- /dev/null
+++ b/examples/multimedia/declarative-camera/permission-denied.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+
+Rectangle {
+ color: "black"
+ width: 800
+ height: 600
+
+ Text {
+ anchors.fill: parent
+ text: qsTr("Grant the camera permission and restart the app")
+ color: "white"
+ font.pointSize: 20
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/examples/multimedia/declarative-camera/qmlcamera.cpp b/examples/multimedia/declarative-camera/qmlcamera.cpp
index edffe6bb0..9844fd53b 100644
--- a/examples/multimedia/declarative-camera/qmlcamera.cpp
+++ b/examples/multimedia/declarative-camera/qmlcamera.cpp
@@ -1,68 +1,39 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
-#include <QQuickView>
#include <QQmlEngine>
+#include <QQuickView>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- QGuiApplication app(argc,argv);
+ QGuiApplication app(argc, argv);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- // Qt.quit() called in embedded .qml by default only emits
- // quit() signal, so do this (optionally use Qt.exit()).
- QObject::connect(view.engine(), &QQmlEngine::quit,
- qApp, &QGuiApplication::quit);
- view.setSource(QUrl("qrc:///declarative-camera.qml"));
- view.resize(800, 480);
- view.show();
+
+ auto setupView = [&view](const QUrl &viewSource) {
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), &QQmlEngine::quit, qApp, &QGuiApplication::quit);
+ view.setSource(viewSource);
+ view.show();
+ };
+
+#if QT_CONFIG(permissions)
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&setupView](const QPermission &permission) {
+ if (permission.status() == Qt::PermissionStatus::Denied)
+ setupView(QUrl("qrc:///permission-denied.qml"));
+ else
+ setupView(QUrl("qrc:///declarative-camera.qml"));
+ });
+#else
+ setupView();
+#endif
+
return app.exec();
}
diff --git a/examples/multimedia/devices/CMakeLists.txt b/examples/multimedia/devices/CMakeLists.txt
deleted file mode 100644
index 3e19c12ec..000000000
--- a/examples/multimedia/devices/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(devices LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/devices")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia)
-
-qt_add_executable(devices
- main.cpp
-)
-
-set_target_properties(devices PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(devices PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Multimedia
-)
-
-install(TARGETS devices
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/multimedia/devices/main.cpp b/examples/multimedia/devices/main.cpp
deleted file mode 100644
index 79c1afb25..000000000
--- a/examples/multimedia/devices/main.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTextStream>
-#include <QString>
-#include <QAudioFormat>
-
-#include <QAudioDevice>
-#include <QCameraDevice>
-#include <qmediadevices.h>
-
-#include <stdio.h>
-
-QString formatToString(QAudioFormat::SampleFormat sampleFormat)
-{
- switch (sampleFormat) {
- case QAudioFormat::UInt8:
- return "UInt8";
- case QAudioFormat::Int16:
- return "Int16";
- case QAudioFormat::Int32:
- return "Int32";
- case QAudioFormat::Float:
- return "Float";
- default:
- return "Unknown";
- }
-}
-
-QString positionToString(QCameraDevice::Position position)
-{
- switch (position) {
- case QCameraDevice::BackFace:
- return "BackFace";
- case QCameraDevice::FrontFace:
- return "FrontFace";
- default:
- return "Unspecified";
- }
-}
-
-void printAudioDeviceInfo(QTextStream &out, const QAudioDevice &deviceInfo)
-{
- const auto isDefault = deviceInfo.isDefault() ? "Yes" : "No";
- const auto preferredFormat = deviceInfo.preferredFormat();
- const auto supportedFormats = deviceInfo.supportedSampleFormats();
- out.setFieldWidth(30);
- out.setFieldAlignment(QTextStream::AlignLeft);
- out << "Name: " << deviceInfo.description() << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Id: " << QString::fromLatin1(deviceInfo.id()) << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Default: " << isDefault << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Preferred Format: " << formatToString(preferredFormat.sampleFormat()) << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Preferred Rate: " << preferredFormat.sampleRate() << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Preferred Channels: " << preferredFormat.channelCount() << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Supported Formats: ";
- for (auto &format: supportedFormats)
- out << qSetFieldWidth(0) << formatToString(format) << " ";
- out << Qt::endl;
- out.setFieldWidth(30);
- out << "Supported Rates: " << qSetFieldWidth(0) << deviceInfo.minimumSampleRate() << " - "
- << deviceInfo.maximumSampleRate() << Qt::endl;
- out.setFieldWidth(30);
- out << "Supported Channels: " << qSetFieldWidth(0) << deviceInfo.minimumChannelCount() << " - "
- << deviceInfo.maximumChannelCount() << Qt::endl;
-
- out << Qt::endl;
-}
-
-void printVideoDeviceInfo(QTextStream &out, const QCameraDevice &cameraDevice)
-{
- const auto isDefault = cameraDevice.isDefault() ? "Yes" : "No";
- const auto position = cameraDevice.position();
- const auto photoResolutions = cameraDevice.photoResolutions();
- const auto videoFormats = cameraDevice.videoFormats();
-
- out.setFieldWidth(30);
- out.setFieldAlignment(QTextStream::AlignLeft);
- out << "Name: " << cameraDevice.description() << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Id: " << QString::fromLatin1(cameraDevice.id()) << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Default: " << isDefault << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Position: " << positionToString(position) << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Photo Resolutions: ";
- for (auto &resolution: photoResolutions) {
- QString s = QString("%1x%2").arg(resolution.width()).arg(resolution.height());
- out << qSetFieldWidth(0) << s << ", ";
- }
- out.setFieldWidth(10);
- out << Qt::endl << Qt::endl;
- out << "Supported Video Formats: " << qSetFieldWidth(0) << Qt::endl;
- for (auto &format: videoFormats) {
- out.setFieldWidth(30);
- QString s = QString("%1x%2").arg(format.resolution().width()).arg(format.resolution().height());
- out << "Resolution: " << s << qSetFieldWidth(0) << Qt::endl;
- out.setFieldWidth(30);
- out << "Frame Rate: " << qSetFieldWidth(0) << "Min:" << format.minFrameRate() << " Max:" << format.maxFrameRate() << Qt::endl;
- }
-
- out << Qt::endl;
-
-}
-
-
-int main(int argc, char *argv[])
-{
- Q_UNUSED(argc);
- Q_UNUSED(argv);
- QTextStream out(stdout);
-
- const auto audioInputDevices = QMediaDevices::audioInputs();
- const auto audioOutputDevices = QMediaDevices::audioOutputs();
- const auto videoInputDevices = QMediaDevices::videoInputs();
-
- out << "Audio devices detected: " << Qt::endl;
- out << Qt::endl << "Input" << Qt::endl;
- for (auto &deviceInfo: audioInputDevices)
- printAudioDeviceInfo(out, deviceInfo);
- out << Qt::endl << "Output" << Qt::endl;
- for (auto &deviceInfo: audioOutputDevices)
- printAudioDeviceInfo(out, deviceInfo);
-
- out << Qt::endl << "Video devices detected: " << Qt::endl;
- for (auto &cameraDevice : videoInputDevices)
- printVideoDeviceInfo(out, cameraDevice);
-
- return 0;
-}
diff --git a/examples/multimedia/multimedia.pro b/examples/multimedia/multimedia.pro
index b34d8f95e..765aa69a7 100644
--- a/examples/multimedia/multimedia.pro
+++ b/examples/multimedia/multimedia.pro
@@ -1,15 +1,18 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += multimedia-private
-SUBDIRS += audiodecoder
-
# These examples all need widgets for now (using creator templates that use widgets)
qtHaveModule(widgets) {
SUBDIRS += \
- spectrum \
- audiorecorder \
audiodevices \
- audiooutput
+ audiooutput \
+ audiorecorder \
+ camera \
+ player \
+ spectrum \
+ videographicsitem \
+ videowidget \
+ screencapture
}
qtHaveModule(quick) {
diff --git a/examples/multimediawidgets/player/CMakeLists.txt b/examples/multimedia/player/CMakeLists.txt
index 7c0304eaf..93a0037a7 100644
--- a/examples/multimediawidgets/player/CMakeLists.txt
+++ b/examples/multimedia/player/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(player LANGUAGES CXX)
@@ -7,7 +10,7 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/player")
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/player")
find_package(Qt6 REQUIRED COMPONENTS MultimediaWidgets Network)
@@ -17,8 +20,9 @@ qt_add_executable(player
playercontrols.cpp playercontrols.h
playlistmodel.cpp playlistmodel.h
videowidget.cpp videowidget.h
- qmediaplaylist.cpp qmediaplaylist.h qmediaplaylist_p.h
- qplaylistfileparser.cpp qplaylistfileparser_p.h
+ qmediaplaylist.cpp qmediaplaylist.h
+ qmediaplaylist_p.cpp qmediaplaylist_p.h
+ qplaylistfileparser.cpp qplaylistfileparser.h
)
set_target_properties(player PROPERTIES
diff --git a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg b/examples/multimedia/player/doc/images/mediaplayerex.jpg
index e875bd134..e875bd134 100644
--- a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg
+++ b/examples/multimedia/player/doc/images/mediaplayerex.jpg
Binary files differ
diff --git a/examples/multimediawidgets/player/doc/src/player.qdoc b/examples/multimedia/player/doc/src/player.qdoc
index dad969375..4c4b26969 100644
--- a/examples/multimediawidgets/player/doc/src/player.qdoc
+++ b/examples/multimedia/player/doc/src/player.qdoc
@@ -1,35 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimediawidgets/player
+ \example player
\title Media Player Example
\ingroup multimedia_examples
\ingroup video_examples
+ \examplecategory {Multimedia}
\brief Playing audio and video.
\meta {tag} {widgets}
diff --git a/examples/multimedia/player/main.cpp b/examples/multimedia/player/main.cpp
new file mode 100644
index 000000000..3f9993570
--- /dev/null
+++ b/examples/multimedia/player/main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "player.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QUrl>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Player Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt MultiMedia Player Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL(s) to open.");
+ parser.process(app);
+
+ Player player;
+
+ if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
+ QList<QUrl> urls;
+ for (auto &a : parser.positionalArguments())
+ urls.append(QUrl::fromUserInput(a, QDir::currentPath()));
+ player.addToPlaylist(urls);
+ }
+
+ player.show();
+ return app.exec();
+}
diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimedia/player/player.cpp
index 25722673d..3f2b9c98f 100644
--- a/examples/multimediawidgets/player/player.cpp
+++ b/examples/multimedia/player/player.cpp
@@ -1,93 +1,60 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "player.h"
-
#include "playercontrols.h"
#include "playlistmodel.h"
#include "qmediaplaylist.h"
#include "videowidget.h"
-#include <QMediaMetaData>
-#include <QMediaDevices>
+#include <QApplication>
#include <QAudioDevice>
#include <QAudioOutput>
+#include <QBoxLayout>
+#include <QComboBox>
+#include <QDir>
+#include <QFileDialog>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListView>
+#include <QMediaDevices>
#include <QMediaFormat>
-#include <QtWidgets>
-
-Player::Player(QWidget *parent)
- : QWidget(parent)
+#include <QMediaMetaData>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QStatusBar>
+#include <QVBoxLayout>
+
+Player::Player(QWidget *parent) : QWidget(parent)
{
-//! [create-objs]
+ //! [create-objs]
m_player = new QMediaPlayer(this);
m_audioOutput = new QAudioOutput(this);
m_player->setAudioOutput(m_audioOutput);
-//! [create-objs]
+ //! [create-objs]
connect(m_player, &QMediaPlayer::durationChanged, this, &Player::durationChanged);
connect(m_player, &QMediaPlayer::positionChanged, this, &Player::positionChanged);
- connect(m_player, QOverload<>::of(&QMediaPlayer::metaDataChanged), this, &Player::metaDataChanged);
+ connect(m_player, QOverload<>::of(&QMediaPlayer::metaDataChanged), this,
+ &Player::metaDataChanged);
connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &Player::statusChanged);
connect(m_player, &QMediaPlayer::bufferProgressChanged, this, &Player::bufferingProgress);
connect(m_player, &QMediaPlayer::hasVideoChanged, this, &Player::videoAvailableChanged);
connect(m_player, &QMediaPlayer::errorChanged, this, &Player::displayErrorMessage);
connect(m_player, &QMediaPlayer::tracksChanged, this, &Player::tracksChanged);
-//! [2]
+ //! [2]
m_videoWidget = new VideoWidget(this);
m_videoWidget->resize(1280, 720);
m_player->setVideoOutput(m_videoWidget);
m_playlistModel = new PlaylistModel(this);
m_playlist = m_playlistModel->playlist();
-//! [2]
- connect(m_playlist, &QMediaPlaylist::currentIndexChanged, this, &Player::playlistPositionChanged);
+ //! [2]
+ connect(m_playlist, &QMediaPlaylist::currentIndexChanged, this,
+ &Player::playlistPositionChanged);
// player layout
QBoxLayout *layout = new QVBoxLayout(this);
@@ -141,7 +108,10 @@ Player::Player(QWidget *parent)
connect(controls, &PlayerControls::changeRate, m_player, &QMediaPlayer::setPlaybackRate);
connect(controls, &PlayerControls::stop, m_videoWidget, QOverload<>::of(&QVideoWidget::update));
- connect(m_player, &QMediaPlayer::playbackStateChanged, controls, &PlayerControls::setState);
+ connect(m_player, &QMediaPlayer::playbackStateChanged, controls,
+ [controls](QMediaPlayer::PlaybackState arg) {
+ controls->setState(arg);
+ });
connect(m_audioOutput, &QAudioOutput::volumeChanged, controls, &PlayerControls::setVolume);
connect(m_audioOutput, &QAudioOutput::mutedChanged, controls, &PlayerControls::setMuted);
@@ -154,12 +124,16 @@ Player::Player(QWidget *parent)
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
m_audioOutputCombo = new QComboBox(this);
- m_audioOutputCombo->addItem(QString::fromUtf8("Default"), QVariant::fromValue(QAudioDevice()));
- for (auto &deviceInfo: QMediaDevices::audioOutputs())
- m_audioOutputCombo->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+ controlLayout->addWidget(m_audioOutputCombo);
+
+ updateAudioDevices();
+
connect(m_audioOutputCombo, QOverload<int>::of(&QComboBox::activated), this,
&Player::audioOutputChanged);
- controlLayout->addWidget(m_audioOutputCombo);
+
+ QObject::connect(&m_mediaDevices, &QMediaDevices::audioOutputsChanged, this, [this] {
+ updateAudioDevices();
+ });
#endif
layout->addLayout(controlLayout);
@@ -227,7 +201,7 @@ Player::Player(QWidget *parent)
if (!isPlayerAvailable()) {
QMessageBox::warning(this, tr("Service not available"),
- tr("The QMediaPlayer object does not have a valid service.\n"\
+ tr("The QMediaPlayer object does not have a valid service.\n"
"Please check the media service plugins are installed."));
controls->setEnabled(false);
@@ -250,7 +224,8 @@ void Player::open()
QFileDialog fileDialog(this);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setWindowTitle(tr("Open Files"));
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
if (fileDialog.exec() == QDialog::Accepted)
addToPlaylist(fileDialog.selectedUrls());
}
@@ -260,13 +235,14 @@ static bool isPlaylist(const QUrl &url) // Check for ".m3u" playlists.
if (!url.isLocalFile())
return false;
const QFileInfo fileInfo(url.toLocalFile());
- return fileInfo.exists() && !fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive);
+ return fileInfo.exists()
+ && !fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive);
}
void Player::addToPlaylist(const QList<QUrl> &urls)
{
const int previousMediaCount = m_playlist->mediaCount();
- for (auto &url: urls) {
+ for (auto &url : urls) {
if (isPlaylist(url))
m_playlist->load(url);
else
@@ -297,41 +273,53 @@ void Player::positionChanged(qint64 progress)
void Player::metaDataChanged()
{
auto metaData = m_player->metaData();
- setTrackInfo(QString("%1 - %2")
- .arg(metaData.value(QMediaMetaData::AlbumArtist).toString())
- .arg(metaData.value(QMediaMetaData::Title).toString()));
+ setTrackInfo(QStringLiteral("%1 - %2")
+ .arg(metaData.value(QMediaMetaData::AlbumArtist).toString())
+ .arg(metaData.value(QMediaMetaData::Title).toString()));
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
for (int i = 0; i < QMediaMetaData::NumMetaData; i++) {
- if (QLineEdit* field = qobject_cast<QLineEdit*>(m_metaDataFields[i]))
+ if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[i]))
field->clear();
- else if (QLabel* label = qobject_cast<QLabel*>(m_metaDataFields[i]))
+ else if (QLabel *label = qobject_cast<QLabel *>(m_metaDataFields[i]))
label->clear();
m_metaDataFields[i]->setDisabled(true);
m_metaDataLabels[i]->setDisabled(true);
}
- for (auto &key : metaData.keys()) {
+ for (auto &&[key, value] : metaData.asKeyValueRange()) {
int i = int(key);
if (key == QMediaMetaData::CoverArtImage) {
- QVariant v = metaData.value(key);
- if (QLabel *cover = qobject_cast<QLabel*>(m_metaDataFields[key])) {
- QImage coverImage = v.value<QImage>();
+ if (QLabel *cover = qobject_cast<QLabel *>(m_metaDataFields[key])) {
+ QImage coverImage = value.value<QImage>();
cover->setPixmap(QPixmap::fromImage(coverImage));
}
} else if (key == QMediaMetaData::ThumbnailImage) {
- QVariant v = metaData.value(key);
- if (QLabel *thumbnail = qobject_cast<QLabel*>(m_metaDataFields[key])) {
- QImage thumbnailImage = v.value<QImage>();
+ if (QLabel *thumbnail = qobject_cast<QLabel *>(m_metaDataFields[key])) {
+ QImage thumbnailImage = value.value<QImage>();
thumbnail->setPixmap(QPixmap::fromImage(thumbnailImage));
}
- } else if (QLineEdit *field = qobject_cast<QLineEdit*>(m_metaDataFields[key])) {
+ } else if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[key])) {
QString stringValue = metaData.stringValue(key);
field->setText(stringValue);
}
m_metaDataFields[i]->setDisabled(false);
m_metaDataLabels[i]->setDisabled(false);
}
+
+ const QList<QMediaMetaData> tracks = m_player->videoTracks();
+ const int currentVideoTrack = m_player->activeVideoTrack();
+ if (currentVideoTrack >= 0 && currentVideoTrack < tracks.size()) {
+ const QMediaMetaData track = tracks.value(currentVideoTrack);
+ for (const QMediaMetaData::Key &key : track.keys()) {
+ if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[key])) {
+ QString stringValue = track.stringValue(key);
+ field->setText(stringValue);
+ }
+ m_metaDataFields[key]->setDisabled(true);
+ m_metaDataLabels[key]->setDisabled(true);
+ }
+ }
#endif
}
@@ -343,14 +331,14 @@ QString Player::trackName(const QMediaMetaData &metaData, int index)
if (title.isEmpty()) {
if (lang == QLocale::Language::AnyLanguage)
- name = tr("Track %1").arg(index+1);
+ name = tr("Track %1").arg(index + 1);
else
name = QLocale::languageToString(lang);
} else {
if (lang == QLocale::Language::AnyLanguage)
name = title;
else
- name = QString("%1 - [%2]").arg(title).arg(QLocale::languageToString(lang));
+ name = QStringLiteral("%1 - [%2]").arg(title).arg(QLocale::languageToString(lang));
}
return name;
}
@@ -362,18 +350,18 @@ void Player::tracksChanged()
m_subtitleTracks->clear();
const auto audioTracks = m_player->audioTracks();
- m_audioTracks->addItem(QString::fromUtf8("No audio"), -1);
+ m_audioTracks->addItem(QStringLiteral("No audio"), -1);
for (int i = 0; i < audioTracks.size(); ++i)
m_audioTracks->addItem(trackName(audioTracks.at(i), i), i);
m_audioTracks->setCurrentIndex(m_player->activeAudioTrack() + 1);
const auto videoTracks = m_player->videoTracks();
- m_videoTracks->addItem(QString::fromUtf8("No video"), -1);
+ m_videoTracks->addItem(QStringLiteral("No video"), -1);
for (int i = 0; i < videoTracks.size(); ++i)
m_videoTracks->addItem(trackName(videoTracks.at(i), i), i);
m_videoTracks->setCurrentIndex(m_player->activeVideoTrack() + 1);
- m_subtitleTracks->addItem(QString::fromUtf8("No subtitles"), -1);
+ m_subtitleTracks->addItem(QStringLiteral("No subtitles"), -1);
const auto subtitleTracks = m_player->subtitleTracks();
for (int i = 0; i < subtitleTracks.size(); ++i)
m_subtitleTracks->addItem(trackName(subtitleTracks.at(i), i), i);
@@ -425,10 +413,10 @@ void Player::statusChanged(QMediaPlayer::MediaStatus status)
break;
case QMediaPlayer::BufferingMedia:
case QMediaPlayer::BufferedMedia:
- setStatusInfo(tr("Buffering %1%").arg(qRound(m_player->bufferProgress()*100.)));
+ setStatusInfo(tr("Buffering %1%").arg(qRound(m_player->bufferProgress() * 100.)));
break;
case QMediaPlayer::StalledMedia:
- setStatusInfo(tr("Stalled %1%").arg(qRound(m_player->bufferProgress()*100.)));
+ setStatusInfo(tr("Stalled %1%").arg(qRound(m_player->bufferProgress() * 100.)));
break;
case QMediaPlayer::EndOfMedia:
QApplication::alert(this);
@@ -443,9 +431,8 @@ void Player::statusChanged(QMediaPlayer::MediaStatus status)
void Player::handleCursor(QMediaPlayer::MediaStatus status)
{
#ifndef QT_NO_CURSOR
- if (status == QMediaPlayer::LoadingMedia ||
- status == QMediaPlayer::BufferingMedia ||
- status == QMediaPlayer::StalledMedia)
+ if (status == QMediaPlayer::LoadingMedia || status == QMediaPlayer::BufferingMedia
+ || status == QMediaPlayer::StalledMedia)
setCursor(QCursor(Qt::BusyCursor));
else
unsetCursor();
@@ -455,20 +442,24 @@ void Player::handleCursor(QMediaPlayer::MediaStatus status)
void Player::bufferingProgress(float progress)
{
if (m_player->mediaStatus() == QMediaPlayer::StalledMedia)
- setStatusInfo(tr("Stalled %1%").arg(qRound(progress*100.)));
+ setStatusInfo(tr("Stalled %1%").arg(qRound(progress * 100.)));
else
- setStatusInfo(tr("Buffering %1%").arg(qRound(progress*100.)));
+ setStatusInfo(tr("Buffering %1%").arg(qRound(progress * 100.)));
}
void Player::videoAvailableChanged(bool available)
{
if (!available) {
- disconnect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen);
- disconnect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked);
+ disconnect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget,
+ &QVideoWidget::setFullScreen);
+ disconnect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton,
+ &QPushButton::setChecked);
m_videoWidget->setFullScreen(false);
} else {
- connect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen);
- connect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked);
+ connect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget,
+ &QVideoWidget::setFullScreen);
+ connect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton,
+ &QPushButton::setChecked);
if (m_fullScreenButton->isChecked())
m_videoWidget->setFullScreen(true);
@@ -502,7 +493,7 @@ void Player::setTrackInfo(const QString &info)
m_statusLabel->setText(m_statusInfo);
} else {
if (!m_statusInfo.isEmpty())
- setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
+ setWindowTitle(QStringLiteral("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
else
setWindowTitle(m_trackInfo);
}
@@ -517,7 +508,7 @@ void Player::setStatusInfo(const QString &info)
m_statusLabel->setText(m_statusInfo);
} else {
if (!m_statusInfo.isEmpty())
- setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
+ setWindowTitle(QStringLiteral("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
else
setWindowTitle(m_trackInfo);
}
@@ -534,10 +525,10 @@ void Player::updateDurationInfo(qint64 currentInfo)
{
QString tStr;
if (currentInfo || m_duration) {
- QTime currentTime((currentInfo / 3600) % 60, (currentInfo / 60) % 60,
- currentInfo % 60, (currentInfo * 1000) % 1000);
- QTime totalTime((m_duration / 3600) % 60, (m_duration / 60) % 60,
- m_duration % 60, (m_duration * 1000) % 1000);
+ QTime currentTime((currentInfo / 3600) % 60, (currentInfo / 60) % 60, currentInfo % 60,
+ (currentInfo * 1000) % 1000);
+ QTime totalTime((m_duration / 3600) % 60, (m_duration / 60) % 60, m_duration % 60,
+ (m_duration * 1000) % 1000);
QString format = "mm:ss";
if (m_duration > 3600)
format = "hh:mm:ss";
@@ -546,8 +537,19 @@ void Player::updateDurationInfo(qint64 currentInfo)
m_labelDuration->setText(tStr);
}
+void Player::updateAudioDevices()
+{
+ m_audioOutputCombo->clear();
+
+ m_audioOutputCombo->addItem(QStringLiteral("Default"), QVariant::fromValue(QAudioDevice()));
+ for (auto &deviceInfo : QMediaDevices::audioOutputs())
+ m_audioOutputCombo->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+}
+
void Player::audioOutputChanged(int index)
{
auto device = m_audioOutputCombo->itemData(index).value<QAudioDevice>();
m_player->audioOutput()->setDevice(device);
}
+
+#include "moc_player.cpp"
diff --git a/examples/multimedia/player/player.h b/examples/multimedia/player/player.h
new file mode 100644
index 000000000..f20995fcf
--- /dev/null
+++ b/examples/multimedia/player/player.h
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYER_H
+#define PLAYER_H
+
+#include "qmediaplaylist.h"
+
+#include <QMediaMetaData>
+#include <QMediaPlayer>
+#include <QMediaDevices>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractItemView;
+class QLabel;
+class QMediaPlayer;
+class QModelIndex;
+class QPushButton;
+class QComboBox;
+class QSlider;
+class QStatusBar;
+class QVideoWidget;
+QT_END_NAMESPACE
+
+class PlaylistModel;
+
+class Player : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Player(QWidget *parent = nullptr);
+ ~Player() = default;
+
+ bool isPlayerAvailable() const;
+
+ void addToPlaylist(const QList<QUrl> &urls);
+
+signals:
+ void fullScreenChanged(bool fullScreen);
+
+private slots:
+ void open();
+ void durationChanged(qint64 duration);
+ void positionChanged(qint64 progress);
+ void metaDataChanged();
+ void tracksChanged();
+
+ void previousClicked();
+
+ void seek(int mseconds);
+ void jump(const QModelIndex &index);
+ void playlistPositionChanged(int);
+
+ void statusChanged(QMediaPlayer::MediaStatus status);
+ void bufferingProgress(float progress);
+ void videoAvailableChanged(bool available);
+
+ void selectAudioStream();
+ void selectVideoStream();
+ void selectSubtitleStream();
+
+ void displayErrorMessage();
+
+ void audioOutputChanged(int);
+
+private:
+ void setTrackInfo(const QString &info);
+ void setStatusInfo(const QString &info);
+ void handleCursor(QMediaPlayer::MediaStatus status);
+ void updateDurationInfo(qint64 currentInfo);
+
+ void updateAudioDevices();
+
+ QString trackName(const QMediaMetaData &metaData, int index);
+
+ QMediaPlayer *m_player = nullptr;
+ QAudioOutput *m_audioOutput = nullptr;
+ QMediaPlaylist *m_playlist = nullptr;
+ QVideoWidget *m_videoWidget = nullptr;
+ QSlider *m_slider = nullptr;
+ QLabel *m_labelDuration = nullptr;
+ QPushButton *m_fullScreenButton = nullptr;
+ QComboBox *m_audioOutputCombo = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QStatusBar *m_statusBar = nullptr;
+
+ QComboBox *m_audioTracks = nullptr;
+ QComboBox *m_videoTracks = nullptr;
+ QComboBox *m_subtitleTracks = nullptr;
+
+ PlaylistModel *m_playlistModel = nullptr;
+ QAbstractItemView *m_playlistView = nullptr;
+ QString m_trackInfo;
+ QString m_statusInfo;
+ qint64 m_duration;
+
+ QMediaDevices m_mediaDevices;
+
+ QWidget *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
+ QLabel *m_metaDataLabels[QMediaMetaData::NumMetaData] = {};
+};
+
+#endif // PLAYER_H
diff --git a/examples/multimediawidgets/player/player.pro b/examples/multimedia/player/player.pro
index 950fe8e0d..6d9383692 100644
--- a/examples/multimediawidgets/player/player.pro
+++ b/examples/multimedia/player/player.pro
@@ -13,7 +13,7 @@ HEADERS = \
videowidget.h \
qmediaplaylist.h \
qmediaplaylist_p.h \
- qplaylistfileparser_p.h
+ qplaylistfileparser.h
SOURCES = main.cpp \
player.cpp \
@@ -21,7 +21,8 @@ SOURCES = main.cpp \
playlistmodel.cpp \
videowidget.cpp \
qmediaplaylist.cpp \
+ qmediaplaylist_p.cpp \
qplaylistfileparser.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/player
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/player
INSTALLS += target
diff --git a/examples/multimedia/player/playercontrols.cpp b/examples/multimedia/player/playercontrols.cpp
new file mode 100644
index 000000000..9a6c81dd2
--- /dev/null
+++ b/examples/multimedia/player/playercontrols.cpp
@@ -0,0 +1,185 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "playercontrols.h"
+
+#include <QAudio>
+#include <QBoxLayout>
+#include <QComboBox>
+#include <QSlider>
+#include <QStyle>
+#include <QToolButton>
+
+PlayerControls::PlayerControls(QWidget *parent) : QWidget(parent)
+{
+ m_playButton = new QToolButton(this);
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+
+ connect(m_playButton, &QAbstractButton::clicked, this, &PlayerControls::playClicked);
+
+ m_pauseButton = new QToolButton(this);
+ m_pauseButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
+ connect(m_pauseButton, &QAbstractButton::clicked, this, &PlayerControls::pauseClicked);
+
+ m_stopButton = new QToolButton(this);
+ m_stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
+ connect(m_stopButton, &QAbstractButton::clicked, this, &PlayerControls::stop);
+
+ m_nextButton = new QToolButton(this);
+ m_nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
+
+ connect(m_nextButton, &QAbstractButton::clicked, this, &PlayerControls::next);
+
+ m_previousButton = new QToolButton(this);
+ m_previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
+
+ connect(m_previousButton, &QAbstractButton::clicked, this, &PlayerControls::previous);
+
+ m_muteButton = new QToolButton(this);
+ m_muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume));
+
+ connect(m_muteButton, &QAbstractButton::clicked, this, &PlayerControls::muteClicked);
+
+ m_volumeSlider = new QSlider(Qt::Horizontal, this);
+ m_volumeSlider->setRange(0, 100);
+ QSizePolicy sp = m_volumeSlider->sizePolicy();
+ sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
+ m_volumeSlider->setSizePolicy(sp);
+
+ connect(m_volumeSlider, &QSlider::valueChanged, this,
+ &PlayerControls::onVolumeSliderValueChanged);
+
+ m_rateBox = new QComboBox(this);
+ m_rateBox->addItem("0.5x", QVariant(0.5));
+ m_rateBox->addItem("1.0x", QVariant(1.0));
+ m_rateBox->addItem("2.0x", QVariant(2.0));
+ m_rateBox->setCurrentIndex(1);
+
+ connect(m_rateBox, QOverload<int>::of(&QComboBox::activated), this,
+ &PlayerControls::updateRate);
+
+ setState(QMediaPlayer::StoppedState, /*force=*/true);
+
+ QBoxLayout *layout = new QHBoxLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(m_stopButton);
+ layout->addWidget(m_previousButton);
+ layout->addWidget(m_pauseButton);
+ layout->addWidget(m_playButton);
+ layout->addWidget(m_nextButton);
+ layout->addWidget(m_muteButton);
+ layout->addWidget(m_volumeSlider);
+ layout->addWidget(m_rateBox);
+ setLayout(layout);
+}
+
+QMediaPlayer::PlaybackState PlayerControls::state() const
+{
+ return m_playerState;
+}
+
+void PlayerControls::setState(QMediaPlayer::PlaybackState state, bool force)
+{
+ if (state != m_playerState || force) {
+ m_playerState = state;
+
+ QColor baseColor = palette().color(QPalette::Base);
+ QString inactiveStyleSheet = QStringLiteral("background-color: %1").arg(baseColor.name());
+ QString defaultStyleSheet = QStringLiteral("");
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ m_stopButton->setStyleSheet(inactiveStyleSheet);
+ m_playButton->setStyleSheet(defaultStyleSheet);
+ m_pauseButton->setStyleSheet(defaultStyleSheet);
+ break;
+ case QMediaPlayer::PlayingState:
+ m_stopButton->setStyleSheet(defaultStyleSheet);
+ m_playButton->setStyleSheet(inactiveStyleSheet);
+ m_pauseButton->setStyleSheet(defaultStyleSheet);
+ break;
+ case QMediaPlayer::PausedState:
+ m_stopButton->setStyleSheet(defaultStyleSheet);
+ m_playButton->setStyleSheet(defaultStyleSheet);
+ m_pauseButton->setStyleSheet(inactiveStyleSheet);
+ break;
+ }
+ }
+}
+
+float PlayerControls::volume() const
+{
+ qreal linearVolume =
+ QAudio::convertVolume(m_volumeSlider->value() / qreal(100),
+ QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale);
+
+ return linearVolume;
+}
+
+void PlayerControls::setVolume(float volume)
+{
+ qreal logarithmicVolume = QAudio::convertVolume(volume, QAudio::LinearVolumeScale,
+ QAudio::LogarithmicVolumeScale);
+
+ m_volumeSlider->setValue(qRound(logarithmicVolume * 100));
+}
+
+bool PlayerControls::isMuted() const
+{
+ return m_playerMuted;
+}
+
+void PlayerControls::setMuted(bool muted)
+{
+ if (muted != m_playerMuted) {
+ m_playerMuted = muted;
+
+ m_muteButton->setIcon(style()->standardIcon(muted ? QStyle::SP_MediaVolumeMuted
+ : QStyle::SP_MediaVolume));
+ }
+}
+
+void PlayerControls::playClicked()
+{
+ emit play();
+}
+
+void PlayerControls::pauseClicked()
+{
+ emit pause();
+}
+
+void PlayerControls::muteClicked()
+{
+ emit changeMuting(!m_playerMuted);
+}
+
+qreal PlayerControls::playbackRate() const
+{
+ return m_rateBox->itemData(m_rateBox->currentIndex()).toDouble();
+}
+
+void PlayerControls::setPlaybackRate(float rate)
+{
+ for (int i = 0; i < m_rateBox->count(); ++i) {
+ if (qFuzzyCompare(rate, float(m_rateBox->itemData(i).toDouble()))) {
+ m_rateBox->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ m_rateBox->addItem(QStringLiteral("%1x").arg(rate), QVariant(rate));
+ m_rateBox->setCurrentIndex(m_rateBox->count() - 1);
+}
+
+void PlayerControls::updateRate()
+{
+ emit changeRate(playbackRate());
+}
+
+void PlayerControls::onVolumeSliderValueChanged()
+{
+ emit changeVolume(volume());
+}
+
+#include "moc_playercontrols.cpp"
diff --git a/examples/multimedia/player/playercontrols.h b/examples/multimedia/player/playercontrols.h
new file mode 100644
index 000000000..322b4ca24
--- /dev/null
+++ b/examples/multimedia/player/playercontrols.h
@@ -0,0 +1,64 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYERCONTROLS_H
+#define PLAYERCONTROLS_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QAbstractSlider;
+class QComboBox;
+QT_END_NAMESPACE
+
+class PlayerControls : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit PlayerControls(QWidget *parent = nullptr);
+
+ QMediaPlayer::PlaybackState state() const;
+ float volume() const;
+ bool isMuted() const;
+ qreal playbackRate() const;
+
+public slots:
+ void setState(QMediaPlayer::PlaybackState state, bool force = false);
+ void setVolume(float volume);
+ void setMuted(bool muted);
+ void setPlaybackRate(float rate);
+
+signals:
+ void play();
+ void pause();
+ void stop();
+ void next();
+ void previous();
+ void changeVolume(float volume);
+ void changeMuting(bool muting);
+ void changeRate(qreal rate);
+
+private slots:
+ void playClicked();
+ void pauseClicked();
+ void muteClicked();
+ void updateRate();
+ void onVolumeSliderValueChanged();
+
+private:
+ QMediaPlayer::PlaybackState m_playerState = QMediaPlayer::StoppedState;
+ bool m_playerMuted = false;
+ QAbstractButton *m_playButton = nullptr;
+ QAbstractButton *m_pauseButton = nullptr;
+ QAbstractButton *m_stopButton = nullptr;
+ QAbstractButton *m_nextButton = nullptr;
+ QAbstractButton *m_previousButton = nullptr;
+ QAbstractButton *m_muteButton = nullptr;
+ QAbstractSlider *m_volumeSlider = nullptr;
+ QComboBox *m_rateBox = nullptr;
+};
+
+#endif // PLAYERCONTROLS_H
diff --git a/examples/multimedia/player/playlistmodel.cpp b/examples/multimedia/player/playlistmodel.cpp
new file mode 100644
index 000000000..7ae76bcac
--- /dev/null
+++ b/examples/multimedia/player/playlistmodel.cpp
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "playlistmodel.h"
+#include "qmediaplaylist.h"
+
+#include <QFileInfo>
+#include <QUrl>
+
+PlaylistModel::PlaylistModel(QObject *parent) : QAbstractItemModel(parent)
+{
+ m_playlist.reset(new QMediaPlaylist);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this,
+ &PlaylistModel::beginInsertItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this,
+ &PlaylistModel::endInsertItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this,
+ &PlaylistModel::beginRemoveItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems);
+}
+
+PlaylistModel::~PlaylistModel() = default;
+
+int PlaylistModel::rowCount(const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0;
+}
+
+int PlaylistModel::columnCount(const QModelIndex &parent) const
+{
+ return !parent.isValid() ? ColumnCount : 0;
+}
+
+QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid() && row >= 0 && row < m_playlist->mediaCount()
+ && column >= 0 && column < ColumnCount
+ ? createIndex(row, column)
+ : QModelIndex();
+}
+
+QModelIndex PlaylistModel::parent(const QModelIndex &child) const
+{
+ Q_UNUSED(child);
+
+ return QModelIndex();
+}
+
+QVariant PlaylistModel::data(const QModelIndex &index, int role) const
+{
+ if (index.isValid() && role == Qt::DisplayRole) {
+ QVariant value = m_data[index];
+ if (!value.isValid() && index.column() == Title) {
+ QUrl location = m_playlist->media(index.row());
+ return QFileInfo(location.path()).fileName();
+ }
+
+ return value;
+ }
+ return QVariant();
+}
+
+QMediaPlaylist *PlaylistModel::playlist() const
+{
+ return m_playlist.data();
+}
+
+bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_UNUSED(role);
+ m_data[index] = value;
+ emit dataChanged(index, index);
+ return true;
+}
+
+void PlaylistModel::beginInsertItems(int start, int end)
+{
+ m_data.clear();
+ beginInsertRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endInsertItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::beginRemoveItems(int start, int end)
+{
+ m_data.clear();
+ beginRemoveRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endRemoveItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::changeItems(int start, int end)
+{
+ m_data.clear();
+ emit dataChanged(index(start, 0), index(end, ColumnCount));
+}
+
+#include "moc_playlistmodel.cpp"
diff --git a/examples/multimedia/player/playlistmodel.h b/examples/multimedia/player/playlistmodel.h
new file mode 100644
index 000000000..0c510f6e0
--- /dev/null
+++ b/examples/multimedia/player/playlistmodel.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYLISTMODEL_H
+#define PLAYLISTMODEL_H
+
+#include <QAbstractItemModel>
+#include <QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+class QMediaPlaylist;
+QT_END_NAMESPACE
+
+class PlaylistModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ enum Column { Title = 0, ColumnCount };
+
+ explicit PlaylistModel(QObject *parent = nullptr);
+ ~PlaylistModel();
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+ QMediaPlaylist *playlist() const;
+
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::DisplayRole) override;
+
+private slots:
+ void beginInsertItems(int start, int end);
+ void endInsertItems();
+ void beginRemoveItems(int start, int end);
+ void endRemoveItems();
+ void changeItems(int start, int end);
+
+private:
+ QScopedPointer<QMediaPlaylist> m_playlist;
+ QMap<QModelIndex, QVariant> m_data;
+};
+
+#endif // PLAYLISTMODEL_H
diff --git a/examples/multimediawidgets/player/qmediaplaylist.cpp b/examples/multimedia/player/qmediaplaylist.cpp
index d2fbe3753..739dd1cb2 100644
--- a/examples/multimediawidgets/player/qmediaplaylist.cpp
+++ b/examples/multimedia/player/qmediaplaylist.cpp
@@ -1,52 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "qmediaplaylist.h"
#include "qmediaplaylist_p.h"
-#include "qplaylistfileparser_p.h"
+#include "qplaylistfileparser.h"
-#include <QtCore/qlist.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qcoreapplication.h>
+#include <QCoreApplication>
+#include <QFile>
+#include <QList>
#include <QRandomGenerator>
+#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -54,16 +17,13 @@ class QM3uPlaylistWriter
{
public:
QM3uPlaylistWriter(QIODevice *device)
- :m_device(device), m_textStream(new QTextStream(m_device))
+ : m_device(device), m_textStream(new QTextStream(m_device))
{
}
- ~QM3uPlaylistWriter()
- {
- delete m_textStream;
- }
+ ~QM3uPlaylistWriter() { delete m_textStream; }
- bool writeItem(const QUrl& item)
+ bool writeItem(const QUrl &item)
{
*m_textStream << item.toString() << Qt::endl;
return true;
@@ -74,7 +34,6 @@ private:
QTextStream *m_textStream;
};
-
int QMediaPlaylistPrivate::nextPosition(int steps) const
{
if (playlist.count() == 0)
@@ -89,7 +48,7 @@ int QMediaPlaylistPrivate::nextPosition(int steps) const
return currentPos;
case QMediaPlaylist::Sequential:
if (next >= playlist.size())
- next = -1;
+ next = 0;
break;
case QMediaPlaylist::Loop:
next %= playlist.count();
@@ -116,7 +75,7 @@ int QMediaPlaylistPrivate::prevPosition(int steps) const
return currentPos;
case QMediaPlaylist::Sequential:
if (next < 0)
- next = -1;
+ next = playlist.size() - 1;
break;
case QMediaPlaylist::Loop:
next %= playlist.size();
@@ -153,7 +112,6 @@ int QMediaPlaylistPrivate::prevPosition(int steps) const
\sa QUrl
*/
-
/*!
\enum QMediaPlaylist::PlaybackMode
@@ -163,23 +121,21 @@ int QMediaPlaylistPrivate::prevPosition(int steps) const
\value CurrentItemInLoop The current item is played repeatedly in a loop.
- \value Sequential Playback starts from the current and moves through each successive item until the last is reached and then stops.
- The next item is a null item when the last one is currently playing.
+ \value Sequential Playback starts from the current and moves through each successive
+ item until the last is reached and then stops. The next item is a null item when the last one is
+ currently playing.
- \value Loop Playback restarts at the first item after the last has finished playing.
+ \value Loop Playback restarts at the first item after the last has finished
+ playing.
\value Random Play items in random order.
*/
-
-
/*!
Create a new playlist object with the given \a parent.
*/
-QMediaPlaylist::QMediaPlaylist(QObject *parent)
- : QObject(parent)
- , d_ptr(new QMediaPlaylistPrivate)
+QMediaPlaylist::QMediaPlaylist(QObject *parent) : QObject(parent), d_ptr(new QMediaPlaylistPrivate)
{
Q_D(QMediaPlaylist);
@@ -266,7 +222,6 @@ int QMediaPlaylist::previousIndex(int steps) const
return d_func()->prevPosition(steps);
}
-
/*!
Returns the number of items in the playlist.
@@ -380,8 +335,7 @@ bool QMediaPlaylist::insertMedia(int pos, const QList<QUrl> &items)
bool QMediaPlaylist::moveMedia(int from, int to)
{
Q_D(QMediaPlaylist);
- if (from < 0 || from > d->playlist.count() ||
- to < 0 || to > d->playlist.count())
+ if (from < 0 || from > d->playlist.count() || to < 0 || to > d->playlist.count())
return false;
d->playlist.move(from, to);
@@ -551,7 +505,8 @@ void QMediaPlaylist::shuffle()
current = d->playlist.takeAt(d->currentPos);
while (!d->playlist.isEmpty())
- playlist.append(d->playlist.takeAt(QRandomGenerator::global()->bounded(int(d->playlist.size()))));
+ playlist.append(
+ d->playlist.takeAt(QRandomGenerator::global()->bounded(int(d->playlist.size()))));
if (d->currentPos != -1)
playlist.insert(d->currentPos, current);
@@ -559,7 +514,6 @@ void QMediaPlaylist::shuffle()
emit mediaChanged(0, d->playlist.count());
}
-
/*!
Advance to the next media content in playlist.
*/
diff --git a/examples/multimediawidgets/player/qmediaplaylist.h b/examples/multimedia/player/qmediaplaylist.h
index 163ef93fe..358f8ca60 100644
--- a/examples/multimediawidgets/player/qmediaplaylist.h
+++ b/examples/multimedia/player/qmediaplaylist.h
@@ -1,50 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef QMEDIAPLAYLIST_H
#define QMEDIAPLAYLIST_H
-#include <QtCore/qobject.h>
-
-#include <QtMultimedia/qtmultimediaglobal.h>
-#include <QtMultimedia/qmediaenumdebug.h>
+#include <QObject>
+#include <qmediaenumdebug.h>
QT_BEGIN_NAMESPACE
@@ -52,7 +14,8 @@ class QMediaPlaylistPrivate;
class QMediaPlaylist : public QObject
{
Q_OBJECT
- Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged)
+ Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode
+ NOTIFY playbackModeChanged)
Q_PROPERTY(QUrl currentMedia READ currentMedia NOTIFY currentMediaChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
@@ -97,7 +60,7 @@ public:
Error error() const;
QString errorString() const;
-public Q_SLOTS:
+public slots:
void shuffle();
void next();
@@ -105,10 +68,10 @@ public Q_SLOTS:
void setCurrentIndex(int index);
-Q_SIGNALS:
+signals:
void currentIndexChanged(int index);
void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
- void currentMediaChanged(const QUrl&);
+ void currentMediaChanged(const QUrl &);
void mediaAboutToBeInserted(int start, int end);
void mediaInserted(int start, int end);
@@ -129,4 +92,4 @@ QT_END_NAMESPACE
Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode)
Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error)
-#endif // QMEDIAPLAYLIST_H
+#endif // QMEDIAPLAYLIST_H
diff --git a/examples/multimedia/player/qmediaplaylist_p.cpp b/examples/multimedia/player/qmediaplaylist_p.cpp
new file mode 100644
index 000000000..13e164484
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist_p.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "qmediaplaylist_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QMediaPlaylistPrivate::QMediaPlaylistPrivate() : error(QMediaPlaylist::NoError) { }
+
+QMediaPlaylistPrivate::~QMediaPlaylistPrivate()
+{
+ delete parser;
+}
+
+void QMediaPlaylistPrivate::loadFailed(QMediaPlaylist::Error error, const QString &errorString)
+{
+ this->error = error;
+ this->errorString = errorString;
+
+ emit q_ptr->loadFailed();
+}
+
+void QMediaPlaylistPrivate::loadFinished()
+{
+ q_ptr->addMedia(parser->playlist);
+
+ emit q_ptr->loaded();
+}
+
+bool QMediaPlaylistPrivate::checkFormat(const char *format) const
+{
+ QLatin1String f(format);
+ QPlaylistFileParser::FileType type =
+ format ? QPlaylistFileParser::UNKNOWN : QPlaylistFileParser::M3U8;
+ if (format) {
+ if (f == QLatin1String("m3u") || f == QLatin1String("text/uri-list")
+ || f == QLatin1String("audio/x-mpegurl") || f == QLatin1String("audio/mpegurl"))
+ type = QPlaylistFileParser::M3U;
+ else if (f == QLatin1String("m3u8") || f == QLatin1String("application/x-mpegURL")
+ || f == QLatin1String("application/vnd.apple.mpegurl"))
+ type = QPlaylistFileParser::M3U8;
+ }
+
+ if (type == QPlaylistFileParser::UNKNOWN || type == QPlaylistFileParser::PLS) {
+ error = QMediaPlaylist::FormatNotSupportedError;
+ errorString = QMediaPlaylist::tr("This file format is not supported.");
+ return false;
+ }
+ return true;
+}
+
+void QMediaPlaylistPrivate::ensureParser()
+{
+ if (parser)
+ return;
+
+ parser = new QPlaylistFileParser(q_ptr);
+ QObject::connect(parser, &QPlaylistFileParser::finished, q_ptr, [this]() { loadFinished(); });
+ QObject::connect(parser, &QPlaylistFileParser::error, q_ptr,
+ [this](QMediaPlaylist::Error err, const QString &errorMsg) {
+ loadFailed(err, errorMsg);
+ });
+}
+
+QT_END_NAMESPACE
diff --git a/examples/multimedia/player/qmediaplaylist_p.h b/examples/multimedia/player/qmediaplaylist_p.h
new file mode 100644
index 000000000..df43776fc
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist_p.h
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef QMEDIAPLAYLIST_P_H
+#define QMEDIAPLAYLIST_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmediaplaylist.h"
+#include "qplaylistfileparser.h"
+
+#include <QUrl>
+
+#include <QDebug>
+
+#ifdef Q_MOC_RUN
+# pragma Q_MOC_EXPAND_MACROS
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlaylistControl;
+
+class QMediaPlaylistPrivate
+{
+ Q_DECLARE_PUBLIC(QMediaPlaylist)
+public:
+ QMediaPlaylistPrivate();
+
+ virtual ~QMediaPlaylistPrivate();
+
+ void loadFailed(QMediaPlaylist::Error error, const QString &errorString);
+
+ void loadFinished();
+
+ bool checkFormat(const char *format) const;
+
+ void ensureParser();
+
+ int nextPosition(int steps) const;
+ int prevPosition(int steps) const;
+
+ QList<QUrl> playlist;
+
+ int currentPos = -1;
+ QMediaPlaylist::PlaybackMode playbackMode = QMediaPlaylist::Sequential;
+
+ QPlaylistFileParser *parser = nullptr;
+ mutable QMediaPlaylist::Error error;
+ mutable QString errorString;
+
+ QMediaPlaylist *q_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMEDIAPLAYLIST_P_H
diff --git a/examples/multimediawidgets/player/qplaylistfileparser.cpp b/examples/multimedia/player/qplaylistfileparser.cpp
index d684a9853..3f5104761 100644
--- a/examples/multimediawidgets/player/qplaylistfileparser.cpp
+++ b/examples/multimedia/player/qplaylistfileparser.cpp
@@ -1,51 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplaylistfileparser_p.h"
-#include <qfileinfo.h>
-#include <QtCore/QDebug>
-#include <QtCore/qiodevice.h>
-#include <QtCore/qpointer.h>
-#include <QtNetwork/QNetworkReply>
-#include <QtNetwork/QNetworkRequest>
-#include "qmediaplayer.h"
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#include "qmediametadata.h"
+#include "qmediaplayer.h"
+#include "qplaylistfileparser.h"
+
+#include <QDebug>
+#include <QFileInfo>
+#include <QIODevice>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QPointer>
QT_BEGIN_NAMESPACE
@@ -54,14 +19,12 @@ namespace {
class ParserBase
{
public:
- explicit ParserBase(QPlaylistFileParser *parent)
- : m_parent(parent)
- , m_aborted(false)
+ explicit ParserBase(QPlaylistFileParser *parent) : m_parent(parent), m_aborted(false)
{
Q_ASSERT(m_parent);
}
- bool parseLine(int lineIndex, const QString& line, const QUrl& root)
+ bool parseLine(int lineIndex, const QString &line, const QUrl &root)
{
if (m_aborted)
return false;
@@ -74,7 +37,7 @@ public:
virtual ~ParserBase() = default;
protected:
- virtual bool parseLineImpl(int lineIndex, const QString& line, const QUrl& root) = 0;
+ virtual bool parseLineImpl(int lineIndex, const QString &line, const QUrl &root) = 0;
static QUrl expandToFullPath(const QUrl &root, const QString &line)
{
@@ -88,7 +51,8 @@ protected:
if (url.scheme().isEmpty()) {
// Resolve it relative to root
if (root.isLocalFile())
- return QUrl::fromUserInput(line, root.adjusted(QUrl::RemoveFilename).toLocalFile(), QUrl::AssumeLocalFile);
+ return QUrl::fromUserInput(line, root.adjusted(QUrl::RemoveFilename).toLocalFile(),
+ QUrl::AssumeLocalFile);
return root.resolved(url);
}
if (url.scheme().length() == 1)
@@ -98,8 +62,7 @@ protected:
return url;
}
- void newItemFound(const QVariant& content) { Q_EMIT m_parent->newItem(content); }
-
+ void newItemFound(const QVariant &content) { Q_EMIT m_parent->newItem(content); }
QPlaylistFileParser *m_parent;
bool m_aborted;
@@ -108,11 +71,7 @@ protected:
class M3UParser : public ParserBase
{
public:
- explicit M3UParser(QPlaylistFileParser *q)
- : ParserBase(q)
- , m_extendedFormat(false)
- {
- }
+ explicit M3UParser(QPlaylistFileParser *q) : ParserBase(q), m_extendedFormat(false) { }
/*
*
@@ -131,31 +90,41 @@ public:
C:\Documents and Settings\I\My Music\Greatest Hits\Example.ogg
*/
- bool parseLineImpl(int lineIndex, const QString& line, const QUrl& root) override
+ bool parseLineImpl(int lineIndex, const QString &line, const QUrl &root) override
{
- if (line[0] == u'#' ) {
+ if (line[0] == u'#') {
if (m_extendedFormat) {
if (line.startsWith(QLatin1String("#EXTINF:"))) {
m_extraInfo.clear();
int artistStart = line.indexOf(QLatin1String(","), 8);
bool ok = false;
- QStringView lineView { line };
- int length = lineView.mid(8, artistStart < 8 ? -1 : artistStart - 8).trimmed().toInt(&ok);
+ QStringView lineView{ line };
+ int length = lineView.mid(8, artistStart < 8 ? -1 : artistStart - 8)
+ .trimmed()
+ .toInt(&ok);
if (ok && length > 0) {
- //convert from second to milisecond
+ // convert from second to milisecond
m_extraInfo[QMediaMetaData::Duration] = QVariant(length * 1000);
}
if (artistStart > 0) {
int titleStart = getSplitIndex(line, artistStart);
if (titleStart > artistStart) {
- m_extraInfo[QMediaMetaData::Author] = lineView.mid(artistStart + 1,
- titleStart - artistStart - 1).trimmed().toString().
- replace(QLatin1String("--"), QLatin1String("-"));
- m_extraInfo[QMediaMetaData::Title] = lineView.mid(titleStart + 1).trimmed().toString().
- replace(QLatin1String("--"), QLatin1String("-"));
+ m_extraInfo[QMediaMetaData::Author] =
+ lineView.mid(artistStart + 1, titleStart - artistStart - 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
+ m_extraInfo[QMediaMetaData::Title] =
+ lineView.mid(titleStart + 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
} else {
- m_extraInfo[QMediaMetaData::Title] = lineView.mid(artistStart + 1).trimmed().toString().
- replace(QLatin1String("--"), QLatin1String("-"));
+ m_extraInfo[QMediaMetaData::Title] =
+ lineView.mid(artistStart + 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
}
}
}
@@ -173,11 +142,11 @@ public:
return true;
}
- int getSplitIndex(const QString& line, int startPos)
+ int getSplitIndex(const QString &line, int startPos)
{
if (startPos < 0)
startPos = 0;
- const QChar* buf = line.data();
+ const QChar *buf = line.data();
for (int i = startPos; i < line.length(); ++i) {
if (buf[i] == u'-') {
if (i == line.length() - 1)
@@ -191,56 +160,53 @@ public:
}
private:
- QMediaMetaData m_extraInfo;
- bool m_extendedFormat;
+ QMediaMetaData m_extraInfo;
+ bool m_extendedFormat;
};
class PLSParser : public ParserBase
{
public:
- explicit PLSParser(QPlaylistFileParser *q)
- : ParserBase(q)
- {
- }
+ explicit PLSParser(QPlaylistFileParser *q) : ParserBase(q) { }
-/*
- *
-The format is essentially that of an INI file structured as follows:
+ /*
+ *
+ The format is essentially that of an INI file structured as follows:
-Header
+ Header
- * [playlist] : This tag indicates that it is a Playlist File
+ * [playlist] : This tag indicates that it is a Playlist File
-Track Entry
-Assuming track entry #X
+ Track Entry
+ Assuming track entry #X
- * FileX : Variable defining location of stream.
- * TitleX : Defines track title.
- * LengthX : Length in seconds of track. Value of -1 indicates indefinite.
+ * FileX : Variable defining location of stream.
+ * TitleX : Defines track title.
+ * LengthX : Length in seconds of track. Value of -1 indicates indefinite.
-Footer
+ Footer
- * NumberOfEntries : This variable indicates the number of tracks.
- * Version : Playlist version. Currently only a value of 2 is valid.
+ * NumberOfEntries : This variable indicates the number of tracks.
+ * Version : Playlist version. Currently only a value of 2 is valid.
-[playlist]
+ [playlist]
-File1=Alternative\everclear - SMFTA.mp3
+ File1=Alternative\everclear - SMFTA.mp3
-Title1=Everclear - So Much For The Afterglow
+ Title1=Everclear - So Much For The Afterglow
-Length1=233
+ Length1=233
-File2=http://www.site.com:8000/listen.pls
+ File2=http://www.site.com:8000/listen.pls
-Title2=My Cool Stream
+ Title2=My Cool Stream
-Length5=-1
+ Length5=-1
-NumberOfEntries=2
+ NumberOfEntries=2
-Version=2
-*/
+ Version=2
+ */
bool parseLineImpl(int, const QString &line, const QUrl &root) override
{
// We ignore everything but 'File' entries, since that's the only thing we care about.
@@ -258,7 +224,8 @@ Version=2
return true;
}
- QString getValue(QStringView line) {
+ QString getValue(QStringView line)
+ {
int start = line.indexOf(u'=');
if (start < 0)
return QString();
@@ -274,13 +241,13 @@ class QPlaylistFileParserPrivate
Q_DECLARE_PUBLIC(QPlaylistFileParser)
public:
QPlaylistFileParserPrivate(QPlaylistFileParser *q)
- : q_ptr(q)
- , m_stream(nullptr)
- , m_type(QPlaylistFileParser::UNKNOWN)
- , m_scanIndex(0)
- , m_lineIndex(-1)
- , m_utf8(false)
- , m_aborted(false)
+ : q_ptr(q),
+ m_stream(nullptr),
+ m_type(QPlaylistFileParser::UNKNOWN),
+ m_scanIndex(0),
+ m_lineIndex(-1),
+ m_utf8(false),
+ m_aborted(false)
{
}
@@ -291,8 +258,8 @@ public:
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> m_source;
QScopedPointer<ParserBase> m_currentParser;
- QByteArray m_buffer;
- QUrl m_root;
+ QByteArray m_buffer;
+ QUrl m_root;
QNetworkAccessManager m_mgr;
QString m_mimeType;
QPlaylistFileParser *q_ptr;
@@ -304,7 +271,12 @@ public:
QUrl m_media;
QString m_mimeType;
[[nodiscard]] bool isValid() const { return m_stream || !m_media.isEmpty(); }
- void reset() { m_stream = nullptr; m_media = QUrl(); m_mimeType = QString(); }
+ void reset()
+ {
+ m_stream = nullptr;
+ m_media = QUrl();
+ m_mimeType = QString();
+ }
} m_pendingJob;
int m_scanIndex;
int m_lineIndex;
@@ -315,8 +287,8 @@ private:
bool processLine(int startIndex, int length);
};
-#define LINE_LIMIT 4096
-#define READ_LIMIT 64
+#define LINE_LIMIT 4096
+#define READ_LIMIT 64
bool QPlaylistFileParserPrivate::processLine(int startIndex, int length)
{
@@ -329,7 +301,9 @@ bool QPlaylistFileParserPrivate::processLine(int startIndex, int length)
QString mimeType;
if (m_source)
mimeType = m_source->header(QNetworkRequest::ContentTypeHeader).toString();
- m_type = QPlaylistFileParser::findPlaylistType(suffix, !mimeType.isEmpty() ? mimeType : m_mimeType, m_buffer.constData(), quint32(m_buffer.size()));
+ m_type = QPlaylistFileParser::findPlaylistType(
+ suffix, !mimeType.isEmpty() ? mimeType : m_mimeType, m_buffer.constData(),
+ quint32(m_buffer.size()));
switch (m_type) {
case QPlaylistFileParser::UNKNOWN:
@@ -370,8 +344,9 @@ void QPlaylistFileParserPrivate::handleData()
{
Q_Q(QPlaylistFileParser);
while (m_stream->bytesAvailable() && !m_aborted) {
- int expectedBytes = qMin(READ_LIMIT, int(qMin(m_stream->bytesAvailable(),
- qint64(LINE_LIMIT - m_buffer.size()))));
+ int expectedBytes =
+ qMin(READ_LIMIT,
+ int(qMin(m_stream->bytesAvailable(), qint64(LINE_LIMIT - m_buffer.size()))));
m_buffer.push_back(m_stream->read(expectedBytes));
int processedBytes = 0;
while (m_scanIndex < m_buffer.length() && !m_aborted) {
@@ -384,7 +359,7 @@ void QPlaylistFileParserPrivate::handleData()
}
processedBytes = m_scanIndex + 1;
if (!m_stream) {
- //some error happened, so exit parsing
+ // some error happened, so exit parsing
return;
}
}
@@ -395,13 +370,14 @@ void QPlaylistFileParserPrivate::handleData()
break;
if (m_buffer.length() - processedBytes >= LINE_LIMIT) {
- emit q->error(QMediaPlaylist::FormatError, QMediaPlaylist::tr("invalid line in playlist file"));
+ emit q->error(QMediaPlaylist::FormatError,
+ QMediaPlaylist::tr("invalid line in playlist file"));
q->abort();
break;
}
if (!m_stream->bytesAvailable() && (!m_source || !m_source->isFinished())) {
- //last line
+ // last line
processLine(processedBytes, -1);
break;
}
@@ -424,20 +400,20 @@ void QPlaylistFileParserPrivate::handleData()
}
QPlaylistFileParser::QPlaylistFileParser(QObject *parent)
- : QObject(parent)
- , d_ptr(new QPlaylistFileParserPrivate(this))
+ : QObject(parent), d_ptr(new QPlaylistFileParserPrivate(this))
{
-
}
QPlaylistFileParser::~QPlaylistFileParser() = default;
QPlaylistFileParser::FileType QPlaylistFileParser::findByMimeType(const QString &mime)
{
- if (mime == QLatin1String("text/uri-list") || mime == QLatin1String("audio/x-mpegurl") || mime == QLatin1String("audio/mpegurl"))
+ if (mime == QLatin1String("text/uri-list") || mime == QLatin1String("audio/x-mpegurl")
+ || mime == QLatin1String("audio/mpegurl"))
return QPlaylistFileParser::M3U;
- if (mime == QLatin1String("application/x-mpegURL") || mime == QLatin1String("application/vnd.apple.mpegurl"))
+ if (mime == QLatin1String("application/x-mpegURL")
+ || mime == QLatin1String("application/vnd.apple.mpegurl"))
return QPlaylistFileParser::M3U8;
if (mime == QLatin1String("audio/x-scpls"))
@@ -476,10 +452,9 @@ QPlaylistFileParser::FileType QPlaylistFileParser::findByDataHeader(const char *
return QPlaylistFileParser::UNKNOWN;
}
-QPlaylistFileParser::FileType QPlaylistFileParser::findPlaylistType(const QString& suffix,
- const QString& mime,
- const char *data,
- quint32 size)
+QPlaylistFileParser::FileType QPlaylistFileParser::findPlaylistType(const QString &suffix,
+ const QString &mime,
+ const char *data, quint32 size)
{
FileType dataHeaderType = findByDataHeader(data, size);
@@ -536,13 +511,14 @@ void QPlaylistFileParser::start(QIODevice *stream, const QString &mimeType)
d->handleData();
}
-void QPlaylistFileParser::start(const QUrl& request, const QString &mimeType)
+void QPlaylistFileParser::start(const QUrl &request, const QString &mimeType)
{
Q_D(QPlaylistFileParser);
const QUrl &url = request.url();
if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
- emit error(QMediaPlaylist::AccessDeniedError, QString(QMediaPlaylist::tr("%1 does not exist")).arg(url.toString()));
+ emit error(QMediaPlaylist::AccessDeniedError,
+ QString(QMediaPlaylist::tr("%1 does not exist")).arg(url.toString()));
return;
}
@@ -559,7 +535,8 @@ void QPlaylistFileParser::start(const QUrl& request, const QString &mimeType)
d->m_stream = d->m_source.get();
connect(d->m_source.data(), SIGNAL(readyRead()), this, SLOT(handleData()));
connect(d->m_source.data(), SIGNAL(finished()), this, SLOT(handleData()));
- connect(d->m_source.data(), SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(handleError()));
+ connect(d->m_source.data(), SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this,
+ SLOT(handleError()));
if (url.isLocalFile())
d->handleData();
@@ -590,7 +567,8 @@ void QPlaylistFileParserPrivate::handleParserFinished()
Q_Q(QPlaylistFileParser);
const bool isParserValid = !m_currentParser.isNull();
if (!isParserValid && !m_aborted)
- emit q->error(QMediaPlaylist::FormatNotSupportedError, QMediaPlaylist::tr("Empty file provided"));
+ emit q->error(QMediaPlaylist::FormatNotSupportedError,
+ QMediaPlaylist::tr("Empty file provided"));
if (isParserValid && !m_aborted) {
m_currentParser.reset();
@@ -639,3 +617,5 @@ void QPlaylistFileParser::handleError()
}
QT_END_NAMESPACE
+
+#include "moc_qplaylistfileparser.cpp"
diff --git a/examples/multimedia/player/qplaylistfileparser.h b/examples/multimedia/player/qplaylistfileparser.h
new file mode 100644
index 000000000..0d83289c4
--- /dev/null
+++ b/examples/multimedia/player/qplaylistfileparser.h
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYLISTFILEPARSER_P_H
+#define PLAYLISTFILEPARSER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmediaplaylist.h"
+#include "qtmultimediaglobal.h"
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QIODevice;
+class QUrl;
+class QNetworkRequest;
+
+class QPlaylistFileParserPrivate;
+
+class QPlaylistFileParser : public QObject
+{
+ Q_OBJECT
+public:
+ QPlaylistFileParser(QObject *parent = nullptr);
+ ~QPlaylistFileParser();
+
+ enum FileType {
+ UNKNOWN,
+ M3U,
+ M3U8, // UTF-8 version of M3U
+ PLS
+ };
+
+ void start(const QUrl &media, QIODevice *stream = nullptr, const QString &mimeType = QString());
+ void start(const QUrl &request, const QString &mimeType = QString());
+ void start(QIODevice *stream, const QString &mimeType = QString());
+ void abort();
+
+ QList<QUrl> playlist;
+
+signals:
+ void newItem(const QVariant &content);
+ void finished();
+ void error(QMediaPlaylist::Error err, const QString &errorMsg);
+
+private slots:
+ void handleData();
+ void handleError();
+
+private:
+ static FileType findByMimeType(const QString &mime);
+ static FileType findBySuffixType(const QString &suffix);
+ static FileType findByDataHeader(const char *data, quint32 size);
+ static FileType findPlaylistType(QIODevice *device, const QString &mime);
+ static FileType findPlaylistType(const QString &suffix, const QString &mime,
+ const char *data = nullptr, quint32 size = 0);
+
+ Q_DISABLE_COPY(QPlaylistFileParser)
+ Q_DECLARE_PRIVATE(QPlaylistFileParser)
+ QScopedPointer<QPlaylistFileParserPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // PLAYLISTFILEPARSER_P_H
diff --git a/examples/multimedia/player/videowidget.cpp b/examples/multimedia/player/videowidget.cpp
new file mode 100644
index 000000000..c09d90f37
--- /dev/null
+++ b/examples/multimedia/player/videowidget.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videowidget.h"
+
+#include <QKeyEvent>
+#include <QMouseEvent>
+
+VideoWidget::VideoWidget(QWidget *parent) : QVideoWidget(parent)
+{
+ setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+
+ QPalette p = palette();
+ p.setColor(QPalette::Window, Qt::black);
+ setPalette(p);
+
+#ifndef Q_OS_ANDROID // QTBUG-95723
+ setAttribute(Qt::WA_OpaquePaintEvent);
+#endif
+}
+
+void VideoWidget::keyPressEvent(QKeyEvent *event)
+{
+ if ((event->key() == Qt::Key_Escape || event->key() == Qt::Key_Back) && isFullScreen()) {
+ setFullScreen(false);
+ event->accept();
+ } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
+ setFullScreen(!isFullScreen());
+ event->accept();
+ } else {
+ QVideoWidget::keyPressEvent(event);
+ }
+}
+
+void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ setFullScreen(!isFullScreen());
+ event->accept();
+}
+
+void VideoWidget::mousePressEvent(QMouseEvent *event)
+{
+ QVideoWidget::mousePressEvent(event);
+}
+
+#include "moc_videowidget.cpp"
diff --git a/examples/multimedia/player/videowidget.h b/examples/multimedia/player/videowidget.h
new file mode 100644
index 000000000..3505a3fb8
--- /dev/null
+++ b/examples/multimedia/player/videowidget.h
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOWIDGET_H
+#define VIDEOWIDGET_H
+
+#include <QVideoWidget>
+
+class VideoWidget : public QVideoWidget
+{
+ Q_OBJECT
+
+public:
+ explicit VideoWidget(QWidget *parent = nullptr);
+
+protected:
+ void keyPressEvent(QKeyEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+};
+
+#endif // VIDEOWIDGET_H
diff --git a/examples/multimedia/screencapture/CMakeLists.txt b/examples/multimedia/screencapture/CMakeLists.txt
new file mode 100644
index 000000000..69ebf8d27
--- /dev/null
+++ b/examples/multimedia/screencapture/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(screencapture VERSION 0.1 LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
+find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS MultimediaWidgets Widgets)
+
+set(PROJECT_SOURCES
+ screencapture.pro
+ main.cpp
+ screencapturepreview.cpp
+ screencapturepreview.h
+ screenlistmodel.h
+ screenlistmodel.cpp
+ windowlistmodel.h
+ windowlistmodel.cpp
+)
+
+qt_add_executable(screencapture
+ MANUAL_FINALIZATION
+ ${PROJECT_SOURCES}
+ )
+
+target_link_libraries(screencapture PRIVATE
+ Qt${QT_VERSION_MAJOR}::Core
+ Qt${QT_VERSION_MAJOR}::Gui
+ Qt${QT_VERSION_MAJOR}::Widgets
+ Qt${QT_VERSION_MAJOR}::Multimedia
+ Qt${QT_VERSION_MAJOR}::MultimediaWidgets)
+
+set_target_properties(screencapture PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+ MACOSX_BUNDLE TRUE
+ WIN32_EXECUTABLE TRUE
+)
+
+install(TARGETS screencapture
+ BUNDLE DESTINATION .
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+qt_finalize_executable(screencapture)
diff --git a/examples/multimedia/screencapture/Info.plist.in b/examples/multimedia/screencapture/Info.plist.in
new file mode 100644
index 000000000..02c09f852
--- /dev/null
+++ b/examples/multimedia/screencapture/Info.plist.in
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/screencapture/doc/images/screencapture.jpg b/examples/multimedia/screencapture/doc/images/screencapture.jpg
new file mode 100644
index 000000000..fb61fcd73
--- /dev/null
+++ b/examples/multimedia/screencapture/doc/images/screencapture.jpg
Binary files differ
diff --git a/examples/multimedia/screencapture/doc/src/screencapture.qdoc b/examples/multimedia/screencapture/doc/src/screencapture.qdoc
new file mode 100644
index 000000000..405c59dbd
--- /dev/null
+++ b/examples/multimedia/screencapture/doc/src/screencapture.qdoc
@@ -0,0 +1,48 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example screencapture
+ \title Screen Capture Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Capturing a screen or window.
+ \meta {tag} {widgets}
+
+ \e{Screen Capture} demonstrates how to capture a screen or window using
+ QScreenCapture and QWindowCapture. The example shows a list of screens and
+ windows and displays a live preview of the selected item using a
+ QMediaCaptureSession and a QVideoWidget. Capturing can be started and stopped
+ with a \l{QPushButton}{button}.
+
+ \image screencapture.jpg
+
+ \include examples-run.qdocinc
+
+ \section1 Application Structure
+
+ The example consists of three custom classes. The UI and all screen capture
+ functionality is implemented in the class ScreenCapturePreview. The classes
+ ScreenListModel and WindowListModel only serve as models behind the two
+ QListView widgets. The main function creates a ScreenCapturePreview object,
+ which in turn creates instances of QScreenCapture and QWindowCapture,
+ and a QMediaCaptureSession and QVideoWidget, in addition to all the UI widgets.
+
+ The screen and window models are populated with the return values of
+ \l QGuiApplication::screens() and \l QWindowCapture::capturableWindows(),
+ respectively.
+
+ When a list item is selected, it is connected to the QScreenCapture object
+ with \l{QScreenCapture::}{setScreen()}, or to the QWindowCapture object
+ with \l{QWindowCapture::}{setWindow()}. The capture object is connected to
+ the QMediaCaptureSession object with \l{QMediaCaptureSession::}{setScreenCapture()}
+ and \l{QMediaCaptureSession::}{setWindowCapture()}, respectively.
+ The capture session in turn is connected to the QVideoWidget object with
+ \l{QMediaCaptureSession::}{setVideoOutput()}. Thus, the capture output is
+ previewed in the video widget on the right hand side of the UI.
+
+ The start/stop button calls \l QScreenCapture::start() and \l QScreenCapture::stop(),
+ or \l QWindowCapture::start() and \l QWindowCapture::stop().
+
+ A QMessageBox pops up if the \l{QScreenCapture::}{errorOccurred} signal is emitted.
+*/
diff --git a/examples/multimedia/screencapture/main.cpp b/examples/multimedia/screencapture/main.cpp
new file mode 100644
index 000000000..6ed104f3e
--- /dev/null
+++ b/examples/multimedia/screencapture/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screencapturepreview.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ScreenCapturePreview screenCapturePreview;
+ screenCapturePreview.show();
+ return app.exec();
+}
diff --git a/examples/multimedia/screencapture/screencapture.pro b/examples/multimedia/screencapture/screencapture.pro
new file mode 100644
index 000000000..d18f556ee
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapture.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = screencapture
+
+QT += multimedia multimediawidgets
+
+HEADERS = \
+ screencapturepreview.h \
+ screenlistmodel.h \
+ windowlistmodel.h
+
+SOURCES = \
+ main.cpp \
+ screencapturepreview.cpp \
+ screenlistmodel.cpp \
+ windowlistmodel.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/screencapture
+INSTALLS += target
diff --git a/examples/multimedia/screencapture/screencapturepreview.cpp b/examples/multimedia/screencapture/screencapturepreview.cpp
new file mode 100644
index 000000000..6eda008a8
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapturepreview.cpp
@@ -0,0 +1,179 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screencapturepreview.h"
+#include "screenlistmodel.h"
+#include "windowlistmodel.h"
+
+#include <QMediaCaptureSession>
+#include <QScreenCapture>
+#include <QVideoWidget>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QAction>
+
+ScreenCapturePreview::ScreenCapturePreview(QWidget *parent)
+ : QWidget(parent),
+ screenListView(new QListView(this)),
+ windowListView(new QListView(this)),
+ screenCapture(new QScreenCapture(this)),
+ windowCapture(new QWindowCapture(this)),
+ mediaCaptureSession(new QMediaCaptureSession(this)),
+ videoWidget(new QVideoWidget(this)),
+ gridLayout(new QGridLayout(this)),
+ startStopButton(new QPushButton(this)),
+ screenLabel(new QLabel(tr("Select screen to capture:"), this)),
+ windowLabel(new QLabel(tr("Select window to capture:"), this)),
+ videoWidgetLabel(new QLabel(tr("Capture output:"), this))
+{
+ // Get lists of screens and windows:
+ screenListModel = new ScreenListModel(this);
+ windowListModel = new WindowListModel(this);
+
+ // Setup QScreenCapture with initial source:
+
+ mediaCaptureSession->setScreenCapture(screenCapture);
+ mediaCaptureSession->setWindowCapture(windowCapture);
+ mediaCaptureSession->setVideoOutput(videoWidget);
+
+ // Setup UI:
+
+ screenListView->setModel(screenListModel);
+ windowListView->setModel(windowListModel);
+
+ auto updateAction = new QAction(tr("Update Windows List"), this);
+ connect(updateAction, &QAction::triggered, windowListModel, &WindowListModel::populate);
+ windowListView->addAction(updateAction);
+ windowListView->setContextMenuPolicy(Qt::ActionsContextMenu);
+
+ gridLayout->addWidget(screenLabel, 0, 0);
+ gridLayout->addWidget(screenListView, 1, 0);
+ gridLayout->addWidget(windowLabel, 2, 0);
+ gridLayout->addWidget(windowListView, 3, 0);
+ gridLayout->addWidget(startStopButton, 4, 0);
+ gridLayout->addWidget(videoWidgetLabel, 0, 1);
+ gridLayout->addWidget(videoWidget, 1, 1, 4, 1);
+
+ gridLayout->setColumnStretch(1, 1);
+ gridLayout->setRowStretch(1, 1);
+ gridLayout->setColumnMinimumWidth(0, 400);
+ gridLayout->setColumnMinimumWidth(1, 400);
+ gridLayout->setRowMinimumHeight(3, 1);
+
+ connect(screenListView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ &ScreenCapturePreview::onCurrentScreenSelectionChanged);
+ connect(windowListView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ &ScreenCapturePreview::onCurrentWindowSelectionChanged);
+ connect(startStopButton, &QPushButton::clicked, this,
+ &ScreenCapturePreview::onStartStopButtonClicked);
+ connect(screenCapture, &QScreenCapture::errorChanged, this,
+ &ScreenCapturePreview::onScreenCaptureErrorChanged, Qt::QueuedConnection);
+ connect(windowCapture, &QWindowCapture::errorChanged, this,
+ &ScreenCapturePreview::onWindowCaptureErrorChanged, Qt::QueuedConnection);
+
+ updateActive(SourceType::Screen, true);
+}
+
+ScreenCapturePreview::~ScreenCapturePreview() = default;
+
+void ScreenCapturePreview::onCurrentScreenSelectionChanged(QItemSelection selection)
+{
+ if (auto indexes = selection.indexes(); !indexes.empty()) {
+ screenCapture->setScreen(screenListModel->screen(indexes.front()));
+ updateActive(SourceType::Screen, isActive());
+
+ windowListView->clearSelection();
+ } else {
+ screenCapture->setScreen(nullptr);
+ }
+}
+
+void ScreenCapturePreview::onCurrentWindowSelectionChanged(QItemSelection selection)
+{
+ if (auto indexes = selection.indexes(); !indexes.empty()) {
+ auto window = windowListModel->window(indexes.front());
+ if (!window.isValid()) {
+ const auto questionResult = QMessageBox::question(
+ this, tr("Invalid window"),
+ tr("The window is no longer valid. Update the list of windows?"));
+ if (questionResult == QMessageBox::Yes) {
+ updateActive(SourceType::Window, false);
+
+ windowListView->clearSelection();
+ windowListModel->populate();
+ return;
+ }
+ }
+
+ windowCapture->setWindow(window);
+ updateActive(SourceType::Window, isActive());
+
+ screenListView->clearSelection();
+ } else {
+ windowCapture->setWindow({});
+ }
+}
+
+void ScreenCapturePreview::onWindowCaptureErrorChanged()
+{
+ if (windowCapture->error() == QWindowCapture::NoError)
+ return;
+
+ QMessageBox::warning(this, tr("QWindowCapture: Error occurred"), windowCapture->errorString());
+}
+
+void ScreenCapturePreview::onScreenCaptureErrorChanged()
+{
+ if (screenCapture->error() == QScreenCapture::NoError)
+ return;
+
+ QMessageBox::warning(this, tr("QScreenCapture: Error occurred"), screenCapture->errorString());
+}
+
+void ScreenCapturePreview::onStartStopButtonClicked()
+{
+ updateActive(sourceType, !isActive());
+}
+
+void ScreenCapturePreview::updateStartStopButtonText()
+{
+ switch (sourceType) {
+ case SourceType::Window:
+ startStopButton->setText(isActive() ? tr("Stop window capture")
+ : tr("Start window capture"));
+ break;
+ case SourceType::Screen:
+ startStopButton->setText(isActive() ? tr("Stop screen capture")
+ : tr("Start screen capture"));
+ break;
+ }
+}
+
+void ScreenCapturePreview::updateActive(SourceType sourceType, bool active)
+{
+ this->sourceType = sourceType;
+
+ screenCapture->setActive(active && sourceType == SourceType::Screen);
+ windowCapture->setActive(active && sourceType == SourceType::Window);
+
+ updateStartStopButtonText();
+}
+
+bool ScreenCapturePreview::isActive() const
+{
+ switch (sourceType) {
+ case SourceType::Window:
+ return windowCapture->isActive();
+ case SourceType::Screen:
+ return screenCapture->isActive();
+ default:
+ return false;
+ }
+}
+
+#include "moc_screencapturepreview.cpp"
diff --git a/examples/multimedia/screencapture/screencapturepreview.h b/examples/multimedia/screencapture/screencapturepreview.h
new file mode 100644
index 000000000..7f0e46491
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapturepreview.h
@@ -0,0 +1,67 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SCREENCAPTUREPREVIEW_H
+#define SCREENCAPTUREPREVIEW_H
+
+#include <QScreenCapture>
+#include <QWindowCapture>
+#include <QWidget>
+#include <QItemSelection>
+
+class ScreenListModel;
+class WindowListModel;
+
+QT_BEGIN_NAMESPACE
+class QListView;
+class QMediaCaptureSession;
+class QVideoWidget;
+class QGridLayout;
+class QHBoxLayout;
+class QLineEdit;
+class QPushButton;
+class QLabel;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class ScreenCapturePreview : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ScreenCapturePreview(QWidget *parent = nullptr);
+ ~ScreenCapturePreview() override;
+
+private slots:
+ void onCurrentScreenSelectionChanged(QItemSelection index);
+ void onCurrentWindowSelectionChanged(QItemSelection index);
+ void onWindowCaptureErrorChanged();
+ void onScreenCaptureErrorChanged();
+ void onStartStopButtonClicked();
+
+private:
+ enum class SourceType { Screen, Window };
+
+ void updateActive(SourceType sourceType, bool active);
+ void updateStartStopButtonText();
+ bool isActive() const;
+
+private:
+ ScreenListModel *screenListModel = nullptr;
+ WindowListModel *windowListModel = nullptr;
+ QListView *screenListView = nullptr;
+ QListView *windowListView = nullptr;
+ QScreenCapture *screenCapture = nullptr;
+ QWindowCapture *windowCapture = nullptr;
+ QMediaCaptureSession *mediaCaptureSession = nullptr;
+ QVideoWidget *videoWidget = nullptr;
+ QGridLayout *gridLayout = nullptr;
+ QPushButton *startStopButton = nullptr;
+ QLabel *screenLabel = nullptr;
+ QLabel *windowLabel = nullptr;
+ QLabel *videoWidgetLabel = nullptr;
+ SourceType sourceType = SourceType::Screen;
+};
+
+#endif // SCREENCAPTUREPREVIEW_H
diff --git a/examples/multimedia/screencapture/screenlistmodel.cpp b/examples/multimedia/screencapture/screenlistmodel.cpp
new file mode 100644
index 000000000..0b46560cc
--- /dev/null
+++ b/examples/multimedia/screencapture/screenlistmodel.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screenlistmodel.h"
+
+#include <QGuiApplication>
+#include <QScreen>
+
+#include <QTextStream>
+
+ScreenListModel::ScreenListModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+ auto *app = qApp;
+ connect(app, &QGuiApplication::screenAdded, this, &ScreenListModel::screensChanged);
+ connect(app, &QGuiApplication::screenRemoved, this, &ScreenListModel::screensChanged);
+ connect(app, &QGuiApplication::primaryScreenChanged, this, &ScreenListModel::screensChanged);
+}
+
+int ScreenListModel::rowCount(const QModelIndex &) const
+{
+ return QGuiApplication::screens().size();
+}
+
+QVariant ScreenListModel::data(const QModelIndex &index, int role) const
+{
+ const auto screenList = QGuiApplication::screens();
+ Q_ASSERT(index.isValid());
+ Q_ASSERT(index.row() <= screenList.size());
+
+ if (role == Qt::DisplayRole) {
+ auto *screen = screenList.at(index.row());
+ QString description;
+ QTextStream str(&description);
+ str << '"' << screen->name() << "\" " << screen->size().width() << 'x'
+ << screen->size().height() << ", " << screen->logicalDotsPerInch() << "DPI";
+ return description;
+ }
+
+ return {};
+}
+
+QScreen *ScreenListModel::screen(const QModelIndex &index) const
+{
+ return QGuiApplication::screens().value(index.row());
+}
+
+void ScreenListModel::screensChanged()
+{
+ beginResetModel();
+ endResetModel();
+}
+
+#include "moc_screenlistmodel.cpp"
diff --git a/examples/multimedia/screencapture/screenlistmodel.h b/examples/multimedia/screencapture/screenlistmodel.h
new file mode 100644
index 000000000..3bfa30b8f
--- /dev/null
+++ b/examples/multimedia/screencapture/screenlistmodel.h
@@ -0,0 +1,30 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SCREENLISTMODEL_H
+#define SCREENLISTMODEL_H
+
+#include <QAbstractListModel>
+
+QT_BEGIN_NAMESPACE
+class QScreen;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class ScreenListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ explicit ScreenListModel(QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QScreen *screen(const QModelIndex &index) const;
+
+private Q_SLOTS:
+ void screensChanged();
+};
+
+#endif // SCREENLISTMODEL_H
diff --git a/examples/multimedia/screencapture/windowlistmodel.cpp b/examples/multimedia/screencapture/windowlistmodel.cpp
new file mode 100644
index 000000000..45b8ceabd
--- /dev/null
+++ b/examples/multimedia/screencapture/windowlistmodel.cpp
@@ -0,0 +1,42 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "windowlistmodel.h"
+#include <QWindowCapture>
+
+WindowListModel::WindowListModel(QObject *parent)
+ : QAbstractListModel(parent), windowList(QWindowCapture::capturableWindows())
+{
+}
+
+int WindowListModel::rowCount(const QModelIndex &) const
+{
+ return windowList.size();
+}
+
+QVariant WindowListModel::data(const QModelIndex &index, int role) const
+{
+ Q_ASSERT(index.isValid());
+ Q_ASSERT(index.row() <= windowList.size());
+
+ if (role == Qt::DisplayRole) {
+ auto window = windowList.at(index.row());
+ return window.description();
+ }
+
+ return {};
+}
+
+QCapturableWindow WindowListModel::window(const QModelIndex &index) const
+{
+ return windowList.at(index.row());
+}
+
+void WindowListModel::populate()
+{
+ beginResetModel();
+ windowList = QWindowCapture::capturableWindows();
+ endResetModel();
+}
+
+#include "moc_windowlistmodel.cpp"
diff --git a/examples/multimedia/screencapture/windowlistmodel.h b/examples/multimedia/screencapture/windowlistmodel.h
new file mode 100644
index 000000000..caccbb0de
--- /dev/null
+++ b/examples/multimedia/screencapture/windowlistmodel.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WINDOWLISTMODEL_H
+#define WINDOWLISTMODEL_H
+
+#include <QAbstractListModel>
+#include <QCapturableWindow>
+
+QT_USE_NAMESPACE
+
+class WindowListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ explicit WindowListModel(QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+ QCapturableWindow window(const QModelIndex &index) const;
+
+public Q_SLOTS:
+ void populate();
+
+private:
+ QList<QCapturableWindow> windowList;
+};
+
+#endif // WINDOWLISTMODEL_H
diff --git a/examples/multimedia/shared/shared.pri b/examples/multimedia/shared/shared.pri
index 61fbc79f1..16239013d 100644
--- a/examples/multimedia/shared/shared.pri
+++ b/examples/multimedia/shared/shared.pri
@@ -17,7 +17,7 @@ ios {
" <key>CFBundleExecutable</key>" \
" <string>$$TARGET</string>" \
" <key>CFBundleIdentifier</key>" \
- " <string>com.digia.$${LITERAL_DOLLAR}{PRODUCT_NAME:rfc1034identifier}</string>" \
+ " <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>" \
" <key>CFBundleDisplayName</key>" \
" <string>$$PRODUCT_NAME</string>" \
" <key>CFBundleName</key>" \
@@ -68,7 +68,7 @@ macos {
" <key>CFBundleExecutable</key>" \
" <string>$$TARGET</string>" \
" <key>CFBundleIdentifier</key>" \
- " <string>com.digia.$${LITERAL_DOLLAR}{PRODUCT_NAME:rfc1034identifier}</string>" \
+ " <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>" \
" <key>CFBundleDisplayName</key>" \
" <string>$$PRODUCT_NAME</string>" \
" <key>CFBundleName</key>" \
diff --git a/examples/multimedia/spatialaudio/doc/src/spatialaudio.qdoc b/examples/multimedia/spatialaudio/doc/src/spatialaudio.qdoc
deleted file mode 100644
index c6452a071..000000000
--- a/examples/multimedia/spatialaudio/doc/src/spatialaudio.qdoc
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2022 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*!
-
-\example multimedia/spatialaudio
-\title Spatial Audio Example
-\ingroup multimedia_examples
-\ingroup spatialaudio_examples
-\meta {tag} {widgets}
-\brief Shows some of the capabilities of the spatial audio engine in Qt.
-
-The Spatial Audio Example demonstrates how you can use \l{Qt Multimedia} to
-place sound sources in 3D space and how positioning of the sound source and
-room properties affect the listening experience.
-
-The example lets you specify a sound file to be played back at a certain
-position in 3D space relative to the listener. Using sliders you can change
-the distance and the azimuth and elevation angles to the source. You can also
-change dimensions of a virtual room, the intensity of the room reflections
-and reverb.
-
-Various other properties can also be modified such as the dimensions of a virtual
-room and the intensity of the room reflections and reverb.
-
-\image spatialaudio-example.png
-
-*/
diff --git a/examples/multimedia/spatialaudio/main.cpp b/examples/multimedia/spatialaudio/main.cpp
deleted file mode 100644
index 4fcd5fe8f..000000000
--- a/examples/multimedia/spatialaudio/main.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2022 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtWidgets/QtWidgets>
-#include <QtMultimedia/QtMultimedia>
-
-class AudioWidget : public QWidget
-{
-public:
- AudioWidget()
- : QWidget()
- {
- setWindowTitle(tr("Spatial Audio test application"));
-
- setMinimumSize(400, 300);
- auto *grid = new QGridLayout(this);
- fileEdit = new QLineEdit;
- fileDialogButton = new QPushButton(tr("Open Filedialog"));
- grid->addWidget(fileEdit, 0, 0);
- grid->addWidget(fileDialogButton, 0, 1);
-
- azimuth = new QSlider(Qt::Horizontal);
- azimuth->setRange(-180, 180);
- grid->addWidget(new QLabel(tr("Azimuth (-180 - 180 degree):")), 1, 0);
- grid->addWidget(azimuth, 1, 1);
- elevation = new QSlider(Qt::Horizontal);
- elevation->setRange(-90, 90);
- grid->addWidget(new QLabel(tr("Elevation (-90 - 90 degree)")), 2, 0);
- grid->addWidget(elevation, 2, 1);
- distance = new QSlider(Qt::Horizontal);
- distance->setRange(0, 1000);
- distance->setValue(100);
- grid->addWidget(new QLabel(tr("Distance (0 - 10 meter):")), 3, 0);
- grid->addWidget(distance, 3, 1);
- occlusion = new QSlider(Qt::Horizontal);
- occlusion->setRange(0, 400);
- grid->addWidget(new QLabel(tr("Occlusion (0 - 4):")), 4, 0);
- grid->addWidget(occlusion, 4, 1);
-
- roomDimension = new QSlider(Qt::Horizontal);
- roomDimension->setRange(0, 10000);
- roomDimension->setValue(500);
- grid->addWidget(new QLabel(tr("Room dimension (0 - 100 meter):")), 5, 0);
- grid->addWidget(roomDimension, 5, 1);
-
- reverbGain = new QSlider(Qt::Horizontal);
- reverbGain->setRange(0, 500);
- reverbGain->setValue(100);
- grid->addWidget(new QLabel(tr("Reverb gain (0-5):")), 6, 0);
- grid->addWidget(reverbGain, 6, 1);
-
- reflectionGain = new QSlider(Qt::Horizontal);
- reflectionGain->setRange(0, 500);
- reflectionGain->setValue(100);
- grid->addWidget(new QLabel(tr("Reflection gain (0-5):")), 7, 0);
- grid->addWidget(reflectionGain, 7, 1);
-
- useHeadphone = new QCheckBox(tr("Use headphone spatialization"));
- grid->addWidget(useHeadphone, 8, 1, 1, 2);
-
- connect(fileEdit, &QLineEdit::textChanged, this, &AudioWidget::fileChanged);
- connect(fileDialogButton, &QPushButton::clicked, this, &AudioWidget::openFileDialog);
-
- connect(azimuth, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
- connect(elevation, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
- connect(distance, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
- connect(occlusion, &QSlider::valueChanged, this, &AudioWidget::newOcclusion);
-
- connect(roomDimension, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
- connect(reverbGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
- connect(reflectionGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
-
- connect(useHeadphone, &QCheckBox::stateChanged, this, &AudioWidget::useHeadphoneChanged);
-
- room = new QSpatialAudioRoom(&engine);
- room->setDimensions(QVector3D(5, 5, 5));
- room->setWallMaterial(QSpatialAudioRoom::BackWall, QSpatialAudioRoom::BrickBare);
- room->setWallMaterial(QSpatialAudioRoom::FrontWall, QSpatialAudioRoom::BrickBare);
- room->setWallMaterial(QSpatialAudioRoom::LeftWall, QSpatialAudioRoom::BrickBare);
- room->setWallMaterial(QSpatialAudioRoom::RightWall, QSpatialAudioRoom::BrickBare);
- room->setWallMaterial(QSpatialAudioRoom::Floor, QSpatialAudioRoom::Marble);
- room->setWallMaterial(QSpatialAudioRoom::Ceiling, QSpatialAudioRoom::WoodCeiling);
- room->setReverbGain(1);
- room->setReflectionGain(1);
-
- listener = new QSpatialAudioListener(&engine);
- listener->setPosition({});
- listener->setRotation({});
- engine.start();
-
- sound = new QSpatialAudioSoundSource(&engine);
- updatePosition();
- }
- void setFile(const QString &file) { fileEdit->setText(file); }
-private slots:
- void updatePosition()
- {
- float az = azimuth->value()/180.*M_PI;
- float el = elevation->value()/180.*M_PI;
- float d = distance->value();
-
- float x = d*sin(az)*cos(el);
- float y = d*cos(az)*cos(el);
- float z = d*sin(el);
- sound->setPosition({x, y, z});
- }
- void newOcclusion()
- {
- sound->setOcclusionIntensity(occlusion->value()/100.);
- }
- void useHeadphoneChanged(int state)
- {
- engine.setOutputMode(state ? QSpatialAudioEngine::Headphone : QSpatialAudioEngine::Normal);
- }
- void fileChanged(const QString &file)
- {
- sound->setSource(QUrl::fromLocalFile(file));
- sound->setSize(5);
- }
- void openFileDialog()
- {
- auto file = QFileDialog::getOpenFileName(this);
- fileEdit->setText(file);
- }
- void updateRoom()
- {
- float d = roomDimension->value();
- room->setDimensions(QVector3D(d, d, 400));
- room->setReflectionGain(float(reflectionGain->value())/100);
- room->setReverbGain(float(reverbGain->value())/100);
- }
-
- QLineEdit *fileEdit = nullptr;
- QPushButton *fileDialogButton = nullptr;
- QSlider *azimuth = nullptr;
- QSlider *elevation = nullptr;
- QSlider *distance = nullptr;
- QSlider *occlusion = nullptr;
- QSlider *roomDimension = nullptr;
- QSlider *reverbGain = nullptr;
- QSlider *reflectionGain = nullptr;
- QCheckBox *useHeadphone = nullptr;
-
- QSpatialAudioEngine engine;
- QSpatialAudioListener *listener = nullptr;
- QSpatialAudioSoundSource *sound = nullptr;
- QSpatialAudioRoom *room = nullptr;
-};
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- AudioWidget *w = new AudioWidget;
- w->show();
- if (argc > 1) {
- auto file = QString::fromUtf8(argv[1]);
- w->setFile(file);
- }
-
- return app.exec();
-}
diff --git a/examples/multimedia/spectrum/CMakeLists.txt b/examples/multimedia/spectrum/CMakeLists.txt
index aea65446d..faabe9c27 100644
--- a/examples/multimedia/spectrum/CMakeLists.txt
+++ b/examples/multimedia/spectrum/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(spectrum LANGUAGES CXX)
@@ -33,6 +36,7 @@ qt_add_executable(spectrum
set_target_properties(spectrum PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
)
target_compile_definitions(spectrum PRIVATE
diff --git a/examples/multimedia/spectrum/Info.plist.in b/examples/multimedia/spectrum/Info.plist.in
new file mode 100644
index 000000000..d0b9ddd11
--- /dev/null
+++ b/examples/multimedia/spectrum/Info.plist.in
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>Qt ${MACOSX_BUNDLE_BUNDLE_NAME} Example</string>
+ <key>CFBundleIdentifier</key>
+ <string>Qt ${MACOSX_BUNDLE_GUI_IDENTIFIER} Example</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+</dict>
+</plist>
diff --git a/examples/multimedia/spectrum/app.pro b/examples/multimedia/spectrum/app.pro
index 584206ab2..9688940bb 100644
--- a/examples/multimedia/spectrum/app.pro
+++ b/examples/multimedia/spectrum/app.pro
@@ -41,7 +41,8 @@ INCLUDEPATH += $${fftreal_dir}
RESOURCES = spectrum.qrc
LIBS += -L./$${spectrum_build_dir}
-LIBS += -lfftreal
+android:LIBS += -lfftreal_$$QT_ARCH
+else:LIBS += -lfftreal
target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum
INSTALLS += target
diff --git a/examples/multimedia/spectrum/doc/src/spectrum.qdoc b/examples/multimedia/spectrum/doc/src/spectrum.qdoc
index 6db616219..25e0760a4 100644
--- a/examples/multimedia/spectrum/doc/src/spectrum.qdoc
+++ b/examples/multimedia/spectrum/doc/src/spectrum.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/spectrum
+ \example spectrum
\title Spectrum Example
\ingroup multimedia_examples
+ \examplecategory {Multimedia}
\brief Analyzing a raw audio stream using the FFTReal library.
\e Spectrum demonstrates how the \l{Qt Multimedia} module can be used to
diff --git a/examples/multimedia/spectrum/engine.cpp b/examples/multimedia/spectrum/engine.cpp
index bbbe08a67..cb7aeadcb 100644
--- a/examples/multimedia/spectrum/engine.cpp
+++ b/examples/multimedia/spectrum/engine.cpp
@@ -1,61 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "engine.h"
#include "tonegenerator.h"
#include "utils.h"
-#include <math.h>
-
-#include <QAudioSource>
#include <QAudioSink>
+#include <QAudioSource>
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
@@ -63,48 +14,51 @@
#include <QSet>
#include <QThread>
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
+#include <math.h>
+
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
-const qint64 BufferDurationUs = 10 * 1000000;
+const qint64 BufferDurationUs = 10 * 1000000;
// Size of the level calculation window in microseconds
-const int LevelWindowUs = 0.1 * 1000000;
+const int LevelWindowUs = 0.1 * 1000000;
//-----------------------------------------------------------------------------
// Constructor and destructor
//-----------------------------------------------------------------------------
Engine::Engine(QObject *parent)
- : QObject(parent)
- , m_mode(QAudioDevice::Input)
- , m_state(QAudio::StoppedState)
- , m_devices(new QMediaDevices(this))
- , m_generateTone(false)
- , m_file(nullptr)
- , m_analysisFile(nullptr)
- , m_availableAudioInputDevices(m_devices->audioInputs())
- , m_audioInputDevice(m_devices->defaultAudioInput())
- , m_audioInput(nullptr)
- , m_audioInputIODevice(nullptr)
- , m_recordPosition(0)
- , m_availableAudioOutputDevices(m_devices->audioOutputs())
- , m_audioOutputDevice(m_devices->defaultAudioOutput())
- , m_audioOutput(nullptr)
- , m_playPosition(0)
- , m_bufferPosition(0)
- , m_bufferLength(0)
- , m_dataLength(0)
- , m_levelBufferLength(0)
- , m_rmsLevel(0.0)
- , m_peakLevel(0.0)
- , m_spectrumBufferLength(0)
- , m_spectrumPosition(0)
- , m_count(0)
-{
- connect(&m_spectrumAnalyser, QOverload<const FrequencySpectrum&>::of(&SpectrumAnalyser::spectrumChanged),
- this, QOverload<const FrequencySpectrum&>::of(&Engine::spectrumChanged));
+ : QObject(parent),
+ m_mode(QAudioDevice::Input),
+ m_state(QAudio::StoppedState),
+ m_devices(new QMediaDevices(this)),
+ m_generateTone(false),
+ m_file(nullptr),
+ m_analysisFile(nullptr),
+ m_audioInput(nullptr),
+ m_audioInputIODevice(nullptr),
+ m_recordPosition(0),
+ m_audioOutput(nullptr),
+ m_playPosition(0),
+ m_bufferPosition(0),
+ m_bufferLength(0),
+ m_dataLength(0),
+ m_levelBufferLength(0),
+ m_rmsLevel(0.0),
+ m_peakLevel(0.0),
+ m_spectrumBufferLength(0),
+ m_spectrumPosition(0),
+ m_count(0)
+{
+ connect(&m_spectrumAnalyser,
+ QOverload<const FrequencySpectrum &>::of(&SpectrumAnalyser::spectrumChanged), this,
+ QOverload<const FrequencySpectrum &>::of(&Engine::spectrumChanged));
// This code might misinterpret things like "-something -category". But
// it's unlikely that that needs to be supported so we'll let it go.
@@ -114,6 +68,8 @@ Engine::Engine(QObject *parent)
break;
}
+ initAudioDevices();
+
initialize();
#ifdef DUMP_DATA
@@ -127,7 +83,6 @@ Engine::Engine(QObject *parent)
m_notifyTimer = new QTimer(this);
m_notifyTimer->setInterval(1000);
connect(m_notifyTimer, &QTimer::timeout, this, &Engine::audioNotify);
-
}
Engine::~Engine() = default;
@@ -143,7 +98,7 @@ bool Engine::loadFile(const QString &fileName)
Q_ASSERT(!m_generateTone);
Q_ASSERT(!m_file);
Q_ASSERT(!fileName.isEmpty());
- QIODevice* file = new QFile(fileName);
+ QIODevice *file = new QFile(fileName);
if (file->open(QIODevice::ReadOnly)) {
m_file = new QWaveDecoder(file, this);
if (m_file->open(QIODevice::ReadOnly)) {
@@ -151,10 +106,9 @@ bool Engine::loadFile(const QString &fileName)
result = initialize();
} else {
emit errorMessage(tr("Audio format not supported"),
- formatToString(m_file->audioFormat()));
+ formatToString(m_file->audioFormat()));
}
- }
- else
+ } else
emit errorMessage(tr("Could not open WAV decoder for file"), fileName);
} else {
emit errorMessage(tr("Could not open file"), fileName);
@@ -176,9 +130,8 @@ bool Engine::generateTone(const Tone &tone)
m_generateTone = true;
m_tone = tone;
ENGINE_DEBUG << "Engine::generateTone"
- << "startFreq" << m_tone.startFreq
- << "endFreq" << m_tone.endFreq
- << "amp" << m_tone.amplitude;
+ << "startFreq" << m_tone.startFreq << "endFreq" << m_tone.endFreq << "amp"
+ << m_tone.amplitude;
return initialize();
}
@@ -191,8 +144,7 @@ bool Engine::generateSweptTone(qreal amplitude)
m_tone.endFreq = 0;
m_tone.amplitude = amplitude;
ENGINE_DEBUG << "Engine::generateSweptTone"
- << "startFreq" << m_tone.startFreq
- << "amp" << m_tone.amplitude;
+ << "startFreq" << m_tone.startFreq << "amp" << m_tone.amplitude;
return initialize();
}
@@ -217,7 +169,6 @@ void Engine::setWindowFunction(WindowFunction type)
m_spectrumAnalyser.setWindowFunction(type);
}
-
//-----------------------------------------------------------------------------
// Public slots
//-----------------------------------------------------------------------------
@@ -225,26 +176,23 @@ void Engine::setWindowFunction(WindowFunction type)
void Engine::startRecording()
{
if (m_audioInput) {
- if (QAudioDevice::Input == m_mode &&
- QAudio::SuspendedState == m_state) {
+ if (QAudioDevice::Input == m_mode && QAudio::SuspendedState == m_state) {
m_audioInput->resume();
} else {
m_spectrumAnalyser.cancelCalculation();
- spectrumChanged(0, 0, FrequencySpectrum());
+ emit spectrumChanged(0, 0, FrequencySpectrum());
m_buffer.fill(0);
setRecordPosition(0, true);
stopPlayback();
m_mode = QAudioDevice::Input;
- connect(m_audioInput, &QAudioSource::stateChanged,
- this, &Engine::audioStateChanged);
+ connect(m_audioInput, &QAudioSource::stateChanged, this, &Engine::audioStateChanged);
m_count = 0;
m_dataLength = 0;
emit dataLengthChanged(0);
m_audioInputIODevice = m_audioInput->start();
- connect(m_audioInputIODevice, &QIODevice::readyRead,
- this, &Engine::audioDataReady);
+ connect(m_audioInputIODevice, &QIODevice::readyRead, this, &Engine::audioDataReady);
}
m_notifyTimer->start();
}
@@ -256,8 +204,7 @@ void Engine::startPlayback()
initialize();
if (m_audioOutput) {
- if (QAudioDevice::Output == m_mode &&
- QAudio::SuspendedState == m_state) {
+ if (QAudioDevice::Output == m_mode && QAudio::SuspendedState == m_state) {
#ifdef Q_OS_WIN
// The Windows backend seems to internally go back into ActiveState
// while still returning SuspendedState, so to ensure that it doesn't
@@ -267,12 +214,11 @@ void Engine::startPlayback()
m_audioOutput->resume();
} else {
m_spectrumAnalyser.cancelCalculation();
- spectrumChanged(0, 0, FrequencySpectrum());
+ emit spectrumChanged(0, 0, FrequencySpectrum());
setPlayPosition(0, true);
stopRecording();
m_mode = QAudioDevice::Output;
- connect(m_audioOutput, &QAudioSink::stateChanged,
- this, &Engine::audioStateChanged);
+ connect(m_audioOutput, &QAudioSink::stateChanged, this, &Engine::audioStateChanged);
m_count = 0;
if (m_file) {
@@ -293,8 +239,7 @@ void Engine::startPlayback()
void Engine::suspend()
{
- if (QAudio::ActiveState == m_state ||
- QAudio::IdleState == m_state) {
+ if (QAudio::ActiveState == m_state || QAudio::IdleState == m_state) {
switch (m_mode) {
case QAudioDevice::Input:
m_audioInput->suspend();
@@ -325,75 +270,99 @@ void Engine::setAudioOutputDevice(const QAudioDevice &device)
}
}
-
//-----------------------------------------------------------------------------
// Private slots
//-----------------------------------------------------------------------------
+void Engine::initAudioDevices()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &Engine::initAudioDevices);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+ m_availableAudioInputDevices = m_devices->audioInputs();
+ m_audioInputDevice = m_devices->defaultAudioInput();
+ m_availableAudioOutputDevices = m_devices->audioOutputs();
+ m_audioOutputDevice = m_devices->defaultAudioOutput();
+}
+
void Engine::audioNotify()
{
switch (m_mode) {
case QAudioDevice::Input: {
- const qint64 recordPosition = qMin(m_bufferLength, m_format.bytesForDuration(m_audioInput->processedUSecs()));
- setRecordPosition(recordPosition);
- const qint64 levelPosition = m_dataLength - m_levelBufferLength;
- if (levelPosition >= 0)
- calculateLevel(levelPosition, m_levelBufferLength);
- if (m_dataLength >= m_spectrumBufferLength) {
- const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength;
- calculateSpectrum(spectrumPosition);
- }
- emit bufferChanged(0, m_dataLength, m_buffer);
+ const qint64 recordPosition =
+ qMin(m_bufferLength, m_format.bytesForDuration(m_audioInput->processedUSecs()));
+ setRecordPosition(recordPosition);
+ const qint64 levelPosition = m_dataLength - m_levelBufferLength;
+ if (levelPosition >= 0)
+ calculateLevel(levelPosition, m_levelBufferLength);
+ if (m_dataLength >= m_spectrumBufferLength) {
+ const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength;
+ calculateSpectrum(spectrumPosition);
}
- break;
+ emit bufferChanged(0, m_dataLength, m_buffer);
+ } break;
case QAudioDevice::Output: {
- const qint64 playPosition = m_format.bytesForDuration(m_audioOutput->processedUSecs());
- setPlayPosition(qMin(bufferLength(), playPosition));
- const qint64 levelPosition = playPosition - m_levelBufferLength;
- const qint64 spectrumPosition = playPosition - m_spectrumBufferLength;
- if (m_file) {
- if (levelPosition > m_bufferPosition ||
- spectrumPosition > m_bufferPosition ||
- qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) {
- m_bufferPosition = 0;
- m_dataLength = 0;
- // Data needs to be read into m_buffer in order to be analysed
- const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition));
- const qint64 readEnd = qMin(m_analysisFile->getDevice()->size(), qMax(levelPosition + m_levelBufferLength, spectrumPosition + m_spectrumBufferLength));
- const qint64 readLen = readEnd - readPos + m_format.bytesForDuration(WaveformWindowDuration);
- qDebug() << "Engine::audioNotify [1]"
- << "analysisFileSize" << m_analysisFile->getDevice()->size()
- << "readPos" << readPos
- << "readLen" << readLen;
- if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) {
- m_buffer.resize(readLen);
- m_bufferPosition = readPos;
- m_dataLength = m_analysisFile->read(m_buffer.data(), readLen);
- qDebug() << "Engine::audioNotify [2]" << "bufferPosition" << m_bufferPosition << "dataLength" << m_dataLength;
- } else {
- qDebug() << "Engine::audioNotify [2]" << "file seek error";
- }
- emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer);
+ const qint64 playPosition = m_format.bytesForDuration(m_audioOutput->processedUSecs());
+ setPlayPosition(qMin(bufferLength(), playPosition));
+ const qint64 levelPosition = playPosition - m_levelBufferLength;
+ const qint64 spectrumPosition = playPosition - m_spectrumBufferLength;
+ if (m_file) {
+ if (levelPosition > m_bufferPosition || spectrumPosition > m_bufferPosition
+ || qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) {
+ m_bufferPosition = 0;
+ m_dataLength = 0;
+ // Data needs to be read into m_buffer in order to be analysed
+ const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition));
+ const qint64 readEnd = qMin(m_analysisFile->getDevice()->size(),
+ qMax(levelPosition + m_levelBufferLength,
+ spectrumPosition + m_spectrumBufferLength));
+ const qint64 readLen =
+ readEnd - readPos + m_format.bytesForDuration(WaveformWindowDuration);
+ qDebug() << "Engine::audioNotify [1]"
+ << "analysisFileSize" << m_analysisFile->getDevice()->size() << "readPos"
+ << readPos << "readLen" << readLen;
+ if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) {
+ m_buffer.resize(readLen);
+ m_bufferPosition = readPos;
+ m_dataLength = m_analysisFile->read(m_buffer.data(), readLen);
+ qDebug() << "Engine::audioNotify [2]"
+ << "bufferPosition" << m_bufferPosition << "dataLength"
+ << m_dataLength;
+ } else {
+ qDebug() << "Engine::audioNotify [2]"
+ << "file seek error";
}
- } else {
- if (playPosition >= m_dataLength)
- stopPlayback();
+ emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer);
}
- if (levelPosition >= 0 && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength)
- calculateLevel(levelPosition, m_levelBufferLength);
- if (spectrumPosition >= 0 && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength)
- calculateSpectrum(spectrumPosition);
+ } else {
+ if (playPosition >= m_dataLength)
+ stopPlayback();
}
+ if (levelPosition >= 0
+ && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength)
+ calculateLevel(levelPosition, m_levelBufferLength);
+ if (spectrumPosition >= 0
+ && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength)
+ calculateSpectrum(spectrumPosition);
+ } break;
+ default:
break;
- default:
- break;
}
}
void Engine::audioStateChanged(QAudio::State state)
{
- ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state
- << "to" << state;
+ ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state << "to" << state;
if (QAudio::IdleState == state && m_file && m_file->pos() == m_file->getDevice()->size()) {
stopPlayback();
@@ -428,9 +397,8 @@ void Engine::audioDataReady()
const qint64 bytesSpace = m_buffer.size() - m_dataLength;
const qint64 bytesToRead = qMin(bytesReady, bytesSpace);
- const qint64 bytesRead = m_audioInputIODevice->read(
- m_buffer.data() + m_dataLength,
- bytesToRead);
+ const qint64 bytesRead =
+ m_audioInputIODevice->read(m_buffer.data() + m_dataLength, bytesToRead);
if (bytesRead) {
m_dataLength += bytesRead;
@@ -443,11 +411,11 @@ void Engine::audioDataReady()
void Engine::spectrumChanged(const FrequencySpectrum &spectrum)
{
- ENGINE_DEBUG << "Engine::spectrumChanged" << "pos" << m_spectrumPosition;
+ ENGINE_DEBUG << "Engine::spectrumChanged"
+ << "pos" << m_spectrumPosition;
emit spectrumChanged(m_spectrumPosition, m_spectrumBufferLength, spectrum);
}
-
//-----------------------------------------------------------------------------
// Private functions
//-----------------------------------------------------------------------------
@@ -526,17 +494,19 @@ bool Engine::initialize()
}
} else {
if (m_file)
- emit errorMessage(tr("Audio format not supported"),
- formatToString(m_format));
+ emit errorMessage(tr("Audio format not supported"), formatToString(m_format));
else if (m_generateTone)
emit errorMessage(tr("No suitable format found"), "");
else
emit errorMessage(tr("No common input / output format found"), "");
}
- ENGINE_DEBUG << "Engine::initialize" << "m_bufferLength" << m_bufferLength;
- ENGINE_DEBUG << "Engine::initialize" << "m_dataLength" << m_dataLength;
- ENGINE_DEBUG << "Engine::initialize" << "format" << m_format;
+ ENGINE_DEBUG << "Engine::initialize"
+ << "m_bufferLength" << m_bufferLength;
+ ENGINE_DEBUG << "Engine::initialize"
+ << "m_dataLength" << m_dataLength;
+ ENGINE_DEBUG << "Engine::initialize"
+ << "format" << m_format;
return result;
}
@@ -655,7 +625,7 @@ void Engine::calculateLevel(qint64 position, qint64 length)
const char *ptr = m_buffer.constData() + position - m_bufferPosition;
const char *const end = ptr + length;
while (ptr < end) {
- const qint16 value = *reinterpret_cast<const qint16*>(ptr);
+ const qint16 value = *reinterpret_cast<const qint16 *>(ptr);
const qreal fracValue = pcmToReal(value);
peakLevel = qMax(peakLevel, fracValue);
sum += fracValue * fracValue;
@@ -668,8 +638,9 @@ void Engine::calculateLevel(qint64 position, qint64 length)
rmsLevel = qMin(qreal(1.0), rmsLevel);
setLevel(rmsLevel, peakLevel, numSamples);
- ENGINE_DEBUG << "Engine::calculateLevel" << "pos" << position << "len" << length
- << "rms" << rmsLevel << "peak" << peakLevel;
+ ENGINE_DEBUG << "Engine::calculateLevel"
+ << "pos" << position << "len" << length << "rms" << rmsLevel << "peak"
+ << peakLevel;
#endif
}
@@ -683,13 +654,13 @@ void Engine::calculateSpectrum(qint64 position)
// QThread::currentThread is marked 'for internal use only', but
// we're only using it for debug output here, so it's probably OK :)
- ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread()
- << "count" << m_count << "pos" << position << "len" << m_spectrumBufferLength
+ ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread() << "count" << m_count
+ << "pos" << position << "len" << m_spectrumBufferLength
<< "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady();
if (m_spectrumAnalyser.isReady()) {
- m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position - m_bufferPosition,
- m_spectrumBufferLength);
+ m_spectrumBuffer = QByteArray::fromRawData(
+ m_buffer.constData() + position - m_bufferPosition, m_spectrumBufferLength);
m_spectrumPosition = position;
m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
}
@@ -728,11 +699,11 @@ void Engine::emitError(QAudio::Error error)
break;
case QAudio::UnderrunError:
errorString = tr("UnderrunError: Audio data is not being fed"
- "to the audio device at a fast enough rate.");
+ "to the audio device at a fast enough rate.");
break;
case QAudio::FatalError:
errorString = tr("FatalError: A non-recoverable error has occurred,"
- "the audio device is not usable at this time.");
+ "the audio device is not usable at this time.");
break;
}
@@ -762,9 +733,9 @@ void Engine::dumpData()
QFile txtFile(txtFileName);
txtFile.open(QFile::WriteOnly | QFile::Text);
QTextStream stream(&txtFile);
- const qint16 *ptr = reinterpret_cast<const qint16*>(m_buffer.constData());
+ const qint16 *ptr = reinterpret_cast<const qint16 *>(m_buffer.constData());
const int numSamples = m_dataLength / (2 * m_format.channels());
- for (int i=0; i<numSamples; ++i) {
+ for (int i = 0; i < numSamples; ++i) {
stream << i << "\t" << *ptr << "\n";
ptr += m_format.channels();
}
@@ -775,3 +746,5 @@ void Engine::dumpData()
pcmFile.write(m_buffer.constData(), m_dataLength);
}
#endif // DUMP_AUDIO
+
+#include "moc_engine.cpp"
diff --git a/examples/multimedia/spectrum/engine.h b/examples/multimedia/spectrum/engine.h
index 7f7028bab..9e8ba51d0 100644
--- a/examples/multimedia/spectrum/engine.h
+++ b/examples/multimedia/spectrum/engine.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ENGINE_H
#define ENGINE_H
@@ -60,17 +13,17 @@
#include <QByteArray>
#include <QDir>
#include <QList>
-#include <QObject>
#include <QMediaDevices>
-#include <QWaveDecoder>
+#include <QObject>
#include <QTimer>
+#include <QWaveDecoder>
#ifdef DUMP_CAPTURED_AUDIO
-#define DUMP_DATA
+# define DUMP_DATA
#endif
#ifdef DUMP_SPECTRUM
-#define DUMP_DATA
+# define DUMP_DATA
#endif
class FrequencySpectrum;
@@ -90,14 +43,18 @@ class Engine : public QObject
Q_OBJECT
public:
- explicit Engine(QObject *parent = 0);
+ explicit Engine(QObject *parent = nullptr);
~Engine();
const QList<QAudioDevice> &availableAudioInputDevices() const
- { return m_availableAudioInputDevices; }
+ {
+ return m_availableAudioInputDevices;
+ }
const QList<QAudioDevice> &availableAudioOutputDevices() const
- { return m_availableAudioOutputDevices; }
+ {
+ return m_availableAudioOutputDevices;
+ }
QAudioDevice::Mode mode() const { return m_mode; }
QAudio::State state() const { return m_state; }
@@ -106,7 +63,7 @@ public:
* \return Current audio format
* \note May be QAudioFormat() if engine is not initialized
*/
- const QAudioFormat& format() const { return m_format; }
+ const QAudioFormat &format() const { return m_format; }
/**
* Stop any ongoing recording or playback, and reset to ground state.
@@ -246,6 +203,7 @@ signals:
void bufferChanged(qint64 position, qint64 length, const QByteArray &buffer);
private slots:
+ void initAudioDevices();
void audioNotify();
void audioStateChanged(QAudio::State state);
void audioDataReady();
@@ -269,7 +227,10 @@ private:
#ifdef DUMP_DATA
void createOutputDir();
- QString outputPath() const { return m_outputDir.path(); }
+ QString outputPath() const
+ {
+ return m_outputDir.path();
+ }
#endif
#ifdef DUMP_CAPTURED_AUDIO
@@ -277,53 +238,52 @@ private:
#endif
private:
- QAudioDevice::Mode m_mode;
- QAudio::State m_state;
- QMediaDevices *m_devices;
+ QAudioDevice::Mode m_mode;
+ QAudio::State m_state;
+ QMediaDevices *m_devices;
- bool m_generateTone;
- SweptTone m_tone;
+ bool m_generateTone;
+ SweptTone m_tone;
- QWaveDecoder* m_file;
+ QWaveDecoder *m_file;
// We need a second file handle via which to read data into m_buffer
// for analysis
- QWaveDecoder* m_analysisFile;
+ QWaveDecoder *m_analysisFile;
- QAudioFormat m_format;
+ QAudioFormat m_format;
- const QList<QAudioDevice> m_availableAudioInputDevices;
- QAudioDevice m_audioInputDevice;
- QAudioSource* m_audioInput;
- QIODevice* m_audioInputIODevice;
- qint64 m_recordPosition;
+ QList<QAudioDevice> m_availableAudioInputDevices;
+ QAudioDevice m_audioInputDevice;
+ QAudioSource *m_audioInput;
+ QIODevice *m_audioInputIODevice;
+ qint64 m_recordPosition;
- const QList<QAudioDevice> m_availableAudioOutputDevices;
- QAudioDevice m_audioOutputDevice;
- QAudioSink* m_audioOutput;
- qint64 m_playPosition;
- QBuffer m_audioOutputIODevice;
+ QList<QAudioDevice> m_availableAudioOutputDevices;
+ QAudioDevice m_audioOutputDevice;
+ QAudioSink *m_audioOutput;
+ qint64 m_playPosition;
+ QBuffer m_audioOutputIODevice;
- QByteArray m_buffer;
- qint64 m_bufferPosition;
- qint64 m_bufferLength;
- qint64 m_dataLength;
+ QByteArray m_buffer;
+ qint64 m_bufferPosition;
+ qint64 m_bufferLength;
+ qint64 m_dataLength;
- int m_levelBufferLength;
- qreal m_rmsLevel;
- qreal m_peakLevel;
+ int m_levelBufferLength;
+ qreal m_rmsLevel;
+ qreal m_peakLevel;
- int m_spectrumBufferLength;
- QByteArray m_spectrumBuffer;
- SpectrumAnalyser m_spectrumAnalyser;
- qint64 m_spectrumPosition;
+ int m_spectrumBufferLength;
+ QByteArray m_spectrumBuffer;
+ SpectrumAnalyser m_spectrumAnalyser;
+ qint64 m_spectrumPosition;
- int m_count;
+ int m_count;
QTimer *m_notifyTimer = nullptr;
#ifdef DUMP_DATA
- QDir m_outputDir;
+ QDir m_outputDir;
#endif
-
};
#endif // ENGINE_H
diff --git a/examples/multimedia/spectrum/frequencyspectrum.cpp b/examples/multimedia/spectrum/frequencyspectrum.cpp
index abec65d23..f271a04aa 100644
--- a/examples/multimedia/spectrum/frequencyspectrum.cpp
+++ b/examples/multimedia/spectrum/frequencyspectrum.cpp
@@ -1,65 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "frequencyspectrum.h"
-FrequencySpectrum::FrequencySpectrum(int numPoints)
- : m_elements(numPoints)
-{
-
-}
+FrequencySpectrum::FrequencySpectrum(int numPoints) : m_elements(numPoints) { }
void FrequencySpectrum::reset()
{
iterator i = begin();
- for ( ; i != end(); ++i)
+ for (; i != end(); ++i)
*i = Element();
}
diff --git a/examples/multimedia/spectrum/frequencyspectrum.h b/examples/multimedia/spectrum/frequencyspectrum.h
index 4b13cbb99..9f3771571 100644
--- a/examples/multimedia/spectrum/frequencyspectrum.h
+++ b/examples/multimedia/spectrum/frequencyspectrum.h
@@ -1,70 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FREQUENCYSPECTRUM_H
#define FREQUENCYSPECTRUM_H
-#include <QtCore/QList>
+#include <QList>
/**
* Represents a frequency spectrum as a series of elements, each of which
* consists of a frequency, an amplitude and a phase.
*/
-class FrequencySpectrum {
+class FrequencySpectrum
+{
public:
FrequencySpectrum(int numPoints = 0);
- struct Element {
- Element()
- : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false)
- { }
+ struct Element
+ {
+ Element() : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false) { }
/**
* Frequency in Hertz
@@ -93,8 +46,8 @@ public:
void reset();
int count() const;
- Element& operator[](int index);
- const Element& operator[](int index) const;
+ Element &operator[](int index);
+ const Element &operator[](int index) const;
iterator begin();
iterator end();
const_iterator begin() const;
diff --git a/examples/multimedia/spectrum/levelmeter.cpp b/examples/multimedia/spectrum/levelmeter.cpp
index f3bd619cd..2c889c34d 100644
--- a/examples/multimedia/spectrum/levelmeter.cpp
+++ b/examples/multimedia/spectrum/levelmeter.cpp
@@ -1,84 +1,34 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "levelmeter.h"
-#include <math.h>
-
+#include <QDebug>
#include <QPainter>
#include <QTimer>
-#include <QDebug>
+#include <math.h>
// Constants
const int RedrawInterval = 100; // ms
const qreal PeakDecayRate = 0.001;
const int PeakHoldLevelDuration = 2000; // ms
-
LevelMeter::LevelMeter(QWidget *parent)
- : QWidget(parent)
- , m_rmsLevel(0.0)
- , m_peakLevel(0.0)
- , m_decayedPeakLevel(0.0)
- , m_peakDecayRate(PeakDecayRate)
- , m_peakHoldLevel(0.0)
- , m_redrawTimer(new QTimer(this))
- , m_rmsColor(Qt::red)
- , m_peakColor(255, 200, 200, 255)
+ : QWidget(parent),
+ m_rmsLevel(0.0),
+ m_peakLevel(0.0),
+ m_decayedPeakLevel(0.0),
+ m_peakDecayRate(PeakDecayRate),
+ m_peakHoldLevel(0.0),
+ m_redrawTimer(new QTimer(this)),
+ m_rmsColor(Qt::red),
+ m_peakColor(255, 200, 200, 255)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
setMinimumWidth(30);
- connect(m_redrawTimer, &QTimer::timeout,
- this, &LevelMeter::redrawTimerExpired);
+ connect(m_redrawTimer, &QTimer::timeout, this, &LevelMeter::redrawTimerExpired);
m_redrawTimer->start(RedrawInterval);
}
@@ -94,7 +44,8 @@ void LevelMeter::reset()
void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
{
// Smooth the RMS signal
- const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number
+ const qreal smooth =
+ pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number
m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth));
if (peakLevel > m_decayedPeakLevel) {
@@ -148,3 +99,5 @@ void LevelMeter::paintEvent(QPaintEvent *event)
bar.setTop(rect().top() + (1.0 - m_rmsLevel) * rect().height());
painter.fillRect(bar, m_rmsColor);
}
+
+#include "moc_levelmeter.cpp"
diff --git a/examples/multimedia/spectrum/levelmeter.h b/examples/multimedia/spectrum/levelmeter.h
index 987f90e8f..e131bc904 100644
--- a/examples/multimedia/spectrum/levelmeter.h
+++ b/examples/multimedia/spectrum/levelmeter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef LEVELMETER_H
#define LEVELMETER_H
@@ -64,7 +17,7 @@ class LevelMeter : public QWidget
Q_OBJECT
public:
- explicit LevelMeter(QWidget *parent = 0);
+ explicit LevelMeter(QWidget *parent = nullptr);
~LevelMeter();
void paintEvent(QPaintEvent *event) override;
@@ -122,7 +75,6 @@ private:
QColor m_rmsColor;
QColor m_peakColor;
-
};
#endif // LEVELMETER_H
diff --git a/examples/multimedia/spectrum/main.cpp b/examples/multimedia/spectrum/main.cpp
index 7eeb94949..31913b2f2 100644
--- a/examples/multimedia/spectrum/main.cpp
+++ b/examples/multimedia/spectrum/main.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwidget.h"
+
#include <QApplication>
int main(int argc, char *argv[])
diff --git a/examples/multimedia/spectrum/mainwidget.cpp b/examples/multimedia/spectrum/mainwidget.cpp
index b72b01bac..214d317d9 100644
--- a/examples/multimedia/spectrum/mainwidget.cpp
+++ b/examples/multimedia/spectrum/mainwidget.cpp
@@ -1,102 +1,55 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include "mainwidget.h"
#include "engine.h"
#include "levelmeter.h"
-#include "mainwidget.h"
-#include "waveform.h"
#include "progressbar.h"
#include "settingsdialog.h"
#include "spectrograph.h"
#include "tonegeneratordialog.h"
#include "utils.h"
+#include "waveform.h"
+#include <QFileDialog>
+#include <QHBoxLayout>
#include <QLabel>
+#include <QMenu>
+#include <QMessageBox>
#include <QPushButton>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
#include <QStyle>
-#include <QMenu>
-#include <QFileDialog>
#include <QTimerEvent>
-#include <QMessageBox>
+#include <QVBoxLayout>
const int NullTimerId = -1;
MainWidget::MainWidget(QWidget *parent)
- : QWidget(parent)
- , m_mode(NoMode)
- , m_engine(new Engine(this))
+ : QWidget(parent),
+ m_mode(NoMode),
+ m_engine(new Engine(this))
#ifndef DISABLE_WAVEFORM
- , m_waveform(new Waveform(this))
+ ,
+ m_waveform(new Waveform(this))
#endif
- , m_progressBar(new ProgressBar(this))
- , m_spectrograph(new Spectrograph(this))
- , m_levelMeter(new LevelMeter(this))
- , m_modeButton(new QPushButton(this))
- , m_recordButton(new QPushButton(this))
- , m_pauseButton(new QPushButton(this))
- , m_playButton(new QPushButton(this))
- , m_settingsButton(new QPushButton(this))
- , m_infoMessage(new QLabel(tr("Select a mode to begin"), this))
- , m_infoMessageTimerId(NullTimerId)
- , m_settingsDialog(new SettingsDialog(
- m_engine->availableAudioInputDevices(),
- m_engine->availableAudioOutputDevices(),
- this))
- , m_toneGeneratorDialog(new ToneGeneratorDialog(this))
- , m_modeMenu(new QMenu(this))
- , m_loadFileAction(nullptr)
- , m_generateToneAction(nullptr)
- , m_recordAction(nullptr)
- , m_errorOccurred(false)
+ ,
+ m_progressBar(new ProgressBar(this)),
+ m_spectrograph(new Spectrograph(this)),
+ m_levelMeter(new LevelMeter(this)),
+ m_modeButton(new QPushButton(this)),
+ m_recordButton(new QPushButton(this)),
+ m_pauseButton(new QPushButton(this)),
+ m_playButton(new QPushButton(this)),
+ m_settingsButton(new QPushButton(this)),
+ m_infoMessage(new QLabel(tr("Select a mode to begin"), this)),
+ m_infoMessageTimerId(NullTimerId),
+ m_settingsDialog(new SettingsDialog(m_engine->availableAudioInputDevices(),
+ m_engine->availableAudioOutputDevices(), this)),
+ m_toneGeneratorDialog(new ToneGeneratorDialog(this)),
+ m_modeMenu(new QMenu(this)),
+ m_loadFileAction(nullptr),
+ m_generateToneAction(nullptr),
+ m_recordAction(nullptr),
+ m_errorOccurred(false)
{
m_spectrograph->setParams(SpectrumNumBands, SpectrumLowFreq, SpectrumHighFreq);
@@ -106,7 +59,6 @@ MainWidget::MainWidget(QWidget *parent)
MainWidget::~MainWidget() = default;
-
//-----------------------------------------------------------------------------
// Public slots
//-----------------------------------------------------------------------------
@@ -117,8 +69,7 @@ void MainWidget::stateChanged(QAudioDevice::Mode mode, QAudio::State state)
updateButtonStates();
- if (QAudio::ActiveState != state &&
- QAudio::SuspendedState != state) {
+ if (QAudio::ActiveState != state && QAudio::SuspendedState != state) {
m_levelMeter->reset();
m_spectrograph->reset();
}
@@ -126,18 +77,16 @@ void MainWidget::stateChanged(QAudioDevice::Mode mode, QAudio::State state)
void MainWidget::formatChanged(const QAudioFormat &format)
{
- infoMessage(formatToString(format), NullMessageTimeout);
+ infoMessage(formatToString(format), NullMessageTimeout);
#ifndef DISABLE_WAVEFORM
if (QAudioFormat() != format) {
- m_waveform->initialize(format, WaveformTileLength,
- WaveformWindowDuration);
+ m_waveform->initialize(format, WaveformTileLength, WaveformWindowDuration);
}
#endif
}
-void MainWidget::spectrumChanged(qint64 position, qint64 length,
- const FrequencySpectrum &spectrum)
+void MainWidget::spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum)
{
m_progressBar->windowChanged(position, length);
m_spectrograph->spectrumChanged(spectrum);
@@ -186,7 +135,6 @@ void MainWidget::bufferLengthChanged(qint64 length)
m_progressBar->bufferLengthChanged(length);
}
-
//-----------------------------------------------------------------------------
// Private slots
//-----------------------------------------------------------------------------
@@ -195,7 +143,8 @@ void MainWidget::showFileDialog()
{
m_errorOccurred = false;
const QString dir;
- const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav");
+ const QStringList fileNames =
+ QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav");
if (fileNames.count()) {
reset();
setMode(LoadFileMode);
@@ -247,7 +196,6 @@ void MainWidget::initializeRecord()
updateButtonStates();
}
-
//-----------------------------------------------------------------------------
// Private functions
//-----------------------------------------------------------------------------
@@ -272,9 +220,9 @@ void MainWidget::createUi()
m_waveform->setLayout(waveformLayout.release());
windowLayout->addWidget(m_waveform);
#else
-#ifndef DISABLE_WAVEFORM
+# ifndef DISABLE_WAVEFORM
windowLayout->addWidget(m_waveform);
-#endif // DISABLE_WAVEFORM
+# endif // DISABLE_WAVEFORM
windowLayout->addWidget(m_progressBar);
#endif // SUPERIMPOSE_PROGRESS_ON_WAVEFORM
@@ -338,62 +286,49 @@ void MainWidget::createUi()
void MainWidget::connectUi()
{
- connect(m_recordButton, &QPushButton::clicked,
- m_engine, &Engine::startRecording);
+ connect(m_recordButton, &QPushButton::clicked, m_engine, &Engine::startRecording);
- connect(m_pauseButton, &QPushButton::clicked,
- m_engine, &Engine::suspend);
+ connect(m_pauseButton, &QPushButton::clicked, m_engine, &Engine::suspend);
- connect(m_playButton, &QPushButton::clicked,
- m_engine, &Engine::startPlayback);
+ connect(m_playButton, &QPushButton::clicked, m_engine, &Engine::startPlayback);
- connect(m_settingsButton, &QPushButton::clicked,
- this, &MainWidget::showSettingsDialog);
+ connect(m_settingsButton, &QPushButton::clicked, this, &MainWidget::showSettingsDialog);
- connect(m_engine, &Engine::stateChanged,
- this, &MainWidget::stateChanged);
+ connect(m_engine, &Engine::stateChanged, this, &MainWidget::stateChanged);
- connect(m_engine, &Engine::formatChanged,
- this, &MainWidget::formatChanged);
+ connect(m_engine, &Engine::formatChanged, this, &MainWidget::formatChanged);
m_progressBar->bufferLengthChanged(m_engine->bufferLength());
- connect(m_engine, &Engine::bufferLengthChanged,
- this, &MainWidget::bufferLengthChanged);
+ connect(m_engine, &Engine::bufferLengthChanged, this, &MainWidget::bufferLengthChanged);
- connect(m_engine, &Engine::dataLengthChanged,
- this, &MainWidget::updateButtonStates);
+ connect(m_engine, &Engine::dataLengthChanged, this, &MainWidget::updateButtonStates);
- connect(m_engine, &Engine::recordPositionChanged,
- m_progressBar, &ProgressBar::recordPositionChanged);
+ connect(m_engine, &Engine::recordPositionChanged, m_progressBar,
+ &ProgressBar::recordPositionChanged);
- connect(m_engine, &Engine::playPositionChanged,
- m_progressBar, &ProgressBar::playPositionChanged);
+ connect(m_engine, &Engine::playPositionChanged, m_progressBar,
+ &ProgressBar::playPositionChanged);
- connect(m_engine, &Engine::recordPositionChanged,
- this, &MainWidget::audioPositionChanged);
+ connect(m_engine, &Engine::recordPositionChanged, this, &MainWidget::audioPositionChanged);
- connect(m_engine, &Engine::playPositionChanged,
- this, &MainWidget::audioPositionChanged);
+ connect(m_engine, &Engine::playPositionChanged, this, &MainWidget::audioPositionChanged);
- connect(m_engine, &Engine::levelChanged,
- m_levelMeter, &LevelMeter::levelChanged);
+ connect(m_engine, &Engine::levelChanged, m_levelMeter, &LevelMeter::levelChanged);
- connect(m_engine, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&Engine::spectrumChanged),
- this, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&MainWidget::spectrumChanged));
+ connect(m_engine,
+ QOverload<qint64, qint64, const FrequencySpectrum &>::of(&Engine::spectrumChanged),
+ this,
+ QOverload<qint64, qint64, const FrequencySpectrum &>::of(&MainWidget::spectrumChanged));
- connect(m_engine, &Engine::infoMessage,
- this, &MainWidget::infoMessage);
+ connect(m_engine, &Engine::infoMessage, this, &MainWidget::infoMessage);
- connect(m_engine, &Engine::errorMessage,
- this, &MainWidget::errorMessage);
+ connect(m_engine, &Engine::errorMessage, this, &MainWidget::errorMessage);
- connect(m_spectrograph, &Spectrograph::infoMessage,
- this, &MainWidget::infoMessage);
+ connect(m_spectrograph, &Spectrograph::infoMessage, this, &MainWidget::infoMessage);
#ifndef DISABLE_WAVEFORM
- connect(m_engine, &Engine::bufferChanged,
- m_waveform, &Waveform::bufferChanged);
+ connect(m_engine, &Engine::bufferChanged, m_waveform, &Waveform::bufferChanged);
#endif
}
@@ -416,20 +351,20 @@ void MainWidget::createMenus()
void MainWidget::updateButtonStates()
{
- const bool recordEnabled = ((QAudioDevice::Output == m_engine->mode() ||
- (QAudio::ActiveState != m_engine->state() &&
- QAudio::IdleState != m_engine->state())) &&
- RecordMode == m_mode);
+ const bool recordEnabled = ((QAudioDevice::Output == m_engine->mode()
+ || (QAudio::ActiveState != m_engine->state()
+ && QAudio::IdleState != m_engine->state()))
+ && RecordMode == m_mode);
m_recordButton->setEnabled(m_errorOccurred ? false : recordEnabled);
- const bool pauseEnabled = (QAudio::ActiveState == m_engine->state() ||
- QAudio::IdleState == m_engine->state());
+ const bool pauseEnabled =
+ (QAudio::ActiveState == m_engine->state() || QAudio::IdleState == m_engine->state());
m_pauseButton->setEnabled(m_errorOccurred ? false : pauseEnabled);
const bool playEnabled = (/*m_engine->dataLength() &&*/
- (QAudioDevice::Output != m_engine->mode() ||
- (QAudio::ActiveState != m_engine->state() &&
- QAudio::IdleState != m_engine->state())));
+ (QAudioDevice::Output != m_engine->mode()
+ || (QAudio::ActiveState != m_engine->state()
+ && QAudio::IdleState != m_engine->state())));
m_playButton->setEnabled(m_errorOccurred ? false : playEnabled);
}
@@ -461,3 +396,5 @@ void MainWidget::updateModeMenu()
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
m_recordAction->setChecked(RecordMode == m_mode);
}
+
+#include "moc_mainwidget.cpp"
diff --git a/examples/multimedia/spectrum/mainwidget.h b/examples/multimedia/spectrum/mainwidget.h
index 0eae08af0..789e312f5 100644
--- a/examples/multimedia/spectrum/mainwidget.h
+++ b/examples/multimedia/spectrum/mainwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
@@ -81,7 +34,7 @@ class MainWidget : public QWidget
Q_OBJECT
public:
- explicit MainWidget(QWidget *parent = 0);
+ explicit MainWidget(QWidget *parent = nullptr);
~MainWidget();
// QObject
@@ -90,8 +43,7 @@ public:
public slots:
void stateChanged(QAudioDevice::Mode mode, QAudio::State state);
void formatChanged(const QAudioFormat &format);
- void spectrumChanged(qint64 position, qint64 length,
- const FrequencySpectrum &spectrum);
+ void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum);
void infoMessage(const QString &message, int timeoutMs);
void errorMessage(const QString &heading, const QString &detail);
void audioPositionChanged(qint64 position);
@@ -111,49 +63,43 @@ private:
void connectUi();
void reset();
- enum Mode {
- NoMode,
- RecordMode,
- GenerateToneMode,
- LoadFileMode
- };
+ enum Mode { NoMode, RecordMode, GenerateToneMode, LoadFileMode };
void setMode(Mode mode);
private:
- Mode m_mode;
+ Mode m_mode;
- Engine* m_engine;
+ Engine *m_engine;
#ifndef DISABLE_WAVEFORM
- Waveform* m_waveform;
+ Waveform *m_waveform;
#endif
- ProgressBar* m_progressBar;
- Spectrograph* m_spectrograph;
- LevelMeter* m_levelMeter;
-
- QPushButton* m_modeButton;
- QPushButton* m_recordButton;
- QIcon m_recordIcon;
- QPushButton* m_pauseButton;
- QIcon m_pauseIcon;
- QPushButton* m_playButton;
- QIcon m_playIcon;
- QPushButton* m_settingsButton;
- QIcon m_settingsIcon;
-
- QLabel* m_infoMessage;
- int m_infoMessageTimerId;
-
- SettingsDialog* m_settingsDialog;
- ToneGeneratorDialog* m_toneGeneratorDialog;
-
- QMenu* m_modeMenu;
- QAction* m_loadFileAction;
- QAction* m_generateToneAction;
- QAction* m_recordAction;
- bool m_errorOccurred;
-
+ ProgressBar *m_progressBar;
+ Spectrograph *m_spectrograph;
+ LevelMeter *m_levelMeter;
+
+ QPushButton *m_modeButton;
+ QPushButton *m_recordButton;
+ QIcon m_recordIcon;
+ QPushButton *m_pauseButton;
+ QIcon m_pauseIcon;
+ QPushButton *m_playButton;
+ QIcon m_playIcon;
+ QPushButton *m_settingsButton;
+ QIcon m_settingsIcon;
+
+ QLabel *m_infoMessage;
+ int m_infoMessageTimerId;
+
+ SettingsDialog *m_settingsDialog;
+ ToneGeneratorDialog *m_toneGeneratorDialog;
+
+ QMenu *m_modeMenu;
+ QAction *m_loadFileAction;
+ QAction *m_generateToneAction;
+ QAction *m_recordAction;
+ bool m_errorOccurred;
};
#endif // MAINWIDGET_H
diff --git a/examples/multimedia/spectrum/progressbar.cpp b/examples/multimedia/spectrum/progressbar.cpp
index 4ac34b866..1806097e2 100644
--- a/examples/multimedia/spectrum/progressbar.cpp
+++ b/examples/multimedia/spectrum/progressbar.cpp
@@ -1,64 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "progressbar.h"
-#include "spectrum.h"
#include <QPainter>
ProgressBar::ProgressBar(QWidget *parent)
- : QWidget(parent)
- , m_bufferLength(0)
- , m_recordPosition(0)
- , m_playPosition(0)
- , m_windowPosition(0)
- , m_windowLength(0)
+ : QWidget(parent),
+ m_bufferLength(0),
+ m_recordPosition(0),
+ m_playPosition(0),
+ m_windowPosition(0),
+ m_windowLength(0)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setMinimumHeight(30);
@@ -145,3 +97,5 @@ void ProgressBar::windowChanged(qint64 position, qint64 length)
m_windowLength = length;
repaint();
}
+
+#include "moc_progressbar.cpp"
diff --git a/examples/multimedia/spectrum/progressbar.h b/examples/multimedia/spectrum/progressbar.h
index 601900efb..8b117c7e6 100644
--- a/examples/multimedia/spectrum/progressbar.h
+++ b/examples/multimedia/spectrum/progressbar.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
@@ -62,7 +15,7 @@ class ProgressBar : public QWidget
Q_OBJECT
public:
- explicit ProgressBar(QWidget *parent = 0);
+ explicit ProgressBar(QWidget *parent = nullptr);
~ProgressBar();
void reset();
diff --git a/examples/multimedia/spectrum/settingsdialog.cpp b/examples/multimedia/spectrum/settingsdialog.cpp
index 3ec9c6956..bdd52e123 100644
--- a/examples/multimedia/spectrum/settingsdialog.cpp
+++ b/examples/multimedia/spectrum/settingsdialog.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "settingsdialog.h"
+
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
@@ -58,26 +12,22 @@
#include <QSpinBox>
#include <QVBoxLayout>
-SettingsDialog::SettingsDialog(
- const QList<QAudioDevice> &availableInputDevices,
- const QList<QAudioDevice> &availableOutputDevices,
- QWidget *parent)
- : QDialog(parent)
- , m_windowFunction(DefaultWindowFunction)
- , m_inputDeviceComboBox(new QComboBox(this))
- , m_outputDeviceComboBox(new QComboBox(this))
- , m_windowFunctionComboBox(new QComboBox(this))
+SettingsDialog::SettingsDialog(const QList<QAudioDevice> &availableInputDevices,
+ const QList<QAudioDevice> &availableOutputDevices, QWidget *parent)
+ : QDialog(parent),
+ m_windowFunction(DefaultWindowFunction),
+ m_inputDeviceComboBox(new QComboBox(this)),
+ m_outputDeviceComboBox(new QComboBox(this)),
+ m_windowFunctionComboBox(new QComboBox(this))
{
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
// Populate combo boxes
for (const QAudioDevice &device : availableInputDevices)
- m_inputDeviceComboBox->addItem(device.description(),
- QVariant::fromValue(device));
+ m_inputDeviceComboBox->addItem(device.description(), QVariant::fromValue(device));
for (const QAudioDevice &device : availableOutputDevices)
- m_outputDeviceComboBox->addItem(device.description(),
- QVariant::fromValue(device));
+ m_outputDeviceComboBox->addItem(device.description(), QVariant::fromValue(device));
m_windowFunctionComboBox->addItem(tr("None"), QVariant::fromValue(int(NoWindow)));
m_windowFunctionComboBox->addItem("Hann", QVariant::fromValue(int(HannWindow)));
@@ -110,12 +60,12 @@ SettingsDialog::SettingsDialog(
dialogLayout->addLayout(windowFunctionLayout.release());
// Connect
- connect(m_inputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::inputDeviceChanged);
- connect(m_outputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::outputDeviceChanged);
- connect(m_windowFunctionComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::windowFunctionChanged);
+ connect(m_inputDeviceComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::inputDeviceChanged);
+ connect(m_outputDeviceComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::outputDeviceChanged);
+ connect(m_windowFunctionComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::windowFunctionChanged);
// Add standard buttons to layout
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
@@ -123,10 +73,10 @@ SettingsDialog::SettingsDialog(
dialogLayout->addWidget(buttonBox);
// Connect standard buttons
- connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
- this, &SettingsDialog::accept);
- connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
- this, &SettingsDialog::reject);
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this,
+ &SettingsDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this,
+ &SettingsDialog::reject);
setLayout(dialogLayout);
}
@@ -135,8 +85,8 @@ SettingsDialog::~SettingsDialog() = default;
void SettingsDialog::windowFunctionChanged(int index)
{
- m_windowFunction = static_cast<WindowFunction>(
- m_windowFunctionComboBox->itemData(index).value<int>());
+ m_windowFunction =
+ static_cast<WindowFunction>(m_windowFunctionComboBox->itemData(index).value<int>());
}
void SettingsDialog::inputDeviceChanged(int index)
@@ -149,3 +99,4 @@ void SettingsDialog::outputDeviceChanged(int index)
m_outputDevice = m_outputDeviceComboBox->itemData(index).value<QAudioDevice>();
}
+#include "moc_settingsdialog.cpp"
diff --git a/examples/multimedia/spectrum/settingsdialog.h b/examples/multimedia/spectrum/settingsdialog.h
index e6563b6ce..ac877d975 100644
--- a/examples/multimedia/spectrum/settingsdialog.h
+++ b/examples/multimedia/spectrum/settingsdialog.h
@@ -1,59 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "spectrum.h"
-#include <QDialog>
+
#include <QAudioDevice>
+#include <QDialog>
QT_BEGIN_NAMESPACE
class QComboBox;
@@ -73,8 +27,7 @@ class SettingsDialog : public QDialog
public:
SettingsDialog(const QList<QAudioDevice> &availableInputDevices,
- const QList<QAudioDevice> &availableOutputDevices,
- QWidget *parent = 0);
+ const QList<QAudioDevice> &availableOutputDevices, QWidget *parent = nullptr);
~SettingsDialog();
WindowFunction windowFunction() const { return m_windowFunction; }
@@ -87,7 +40,7 @@ private slots:
void outputDeviceChanged(int index);
private:
- WindowFunction m_windowFunction;
+ WindowFunction m_windowFunction;
QAudioDevice m_inputDevice;
QAudioDevice m_outputDevice;
diff --git a/examples/multimedia/spectrum/spectrograph.cpp b/examples/multimedia/spectrum/spectrograph.cpp
index 2ab1127d7..96274b50b 100644
--- a/examples/multimedia/spectrum/spectrograph.cpp
+++ b/examples/multimedia/spectrum/spectrograph.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spectrograph.h"
+
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
@@ -59,17 +13,16 @@ const int NullIndex = -1;
const int BarSelectionInterval = 2000;
Spectrograph::Spectrograph(QWidget *parent)
- : QWidget(parent)
- , m_barSelected(NullIndex)
- , m_timerId(NullTimerId)
- , m_lowFreq(0.0)
- , m_highFreq(0.0)
+ : QWidget(parent),
+ m_barSelected(NullIndex),
+ m_timerId(NullTimerId),
+ m_lowFreq(0.0),
+ m_highFreq(0.0)
{
setMinimumHeight(100);
}
-Spectrograph::~Spectrograph()
-= default;
+Spectrograph::~Spectrograph() = default;
void Spectrograph::setParams(int numBars, qreal lowFreq, qreal highFreq)
{
@@ -132,8 +85,8 @@ void Spectrograph::paintEvent(QPaintEvent *event)
if (numBars) {
const int numHorizontalSections = numBars;
QLine line(rect().topLeft(), rect().bottomLeft());
- for (int i=1; i<numHorizontalSections; ++i) {
- line.translate(rect().width()/numHorizontalSections, 0);
+ for (int i = 1; i < numHorizontalSections; ++i) {
+ line.translate(rect().width() / numHorizontalSections, 0);
painter.drawLine(line);
}
}
@@ -141,8 +94,8 @@ void Spectrograph::paintEvent(QPaintEvent *event)
// Draw horizontal lines
const int numVerticalSections = 10;
QLine line(rect().topLeft(), rect().topRight());
- for (int i=1; i<numVerticalSections; ++i) {
- line.translate(0, rect().height()/numVerticalSections);
+ for (int i = 1; i < numVerticalSections; ++i) {
+ line.translate(0, rect().height() / numVerticalSections);
painter.drawLine(line);
}
@@ -161,7 +114,7 @@ void Spectrograph::paintEvent(QPaintEvent *event)
const int leftPaddingWidth = (paddingWidth + gapWidth) / 2;
const int barHeight = rect().height() - 2 * gapWidth;
- for (int i=0; i<numBars; ++i) {
+ for (int i = 0; i < numBars; ++i) {
const qreal value = m_bars[i].value;
Q_ASSERT(value >= 0.0 && value <= 1.0);
QRect bar = rect();
@@ -203,7 +156,7 @@ int Spectrograph::barIndex(qreal frequency) const
Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq);
const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count();
const int index = (frequency - m_lowFreq) / bandWidth;
- if (index <0 || index >= m_bars.count())
+ if (index < 0 || index >= m_bars.count())
Q_ASSERT(false);
return index;
}
@@ -212,7 +165,7 @@ QPair<qreal, qreal> Spectrograph::barRange(int index) const
{
Q_ASSERT(index >= 0 && index < m_bars.count());
const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count();
- return QPair<qreal, qreal>(index * bandWidth, (index+1) * bandWidth);
+ return QPair<qreal, qreal>(index * bandWidth, (index + 1) * bandWidth);
}
void Spectrograph::updateBars()
@@ -220,7 +173,7 @@ void Spectrograph::updateBars()
m_bars.fill(Bar());
FrequencySpectrum::const_iterator i = m_spectrum.begin();
const FrequencySpectrum::const_iterator end = m_spectrum.end();
- for ( ; i != end; ++i) {
+ for (; i != end; ++i) {
const FrequencySpectrum::Element e = *i;
if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) {
Bar &bar = m_bars[barIndex(e.frequency)];
@@ -231,11 +184,11 @@ void Spectrograph::updateBars()
update();
}
-void Spectrograph::selectBar(int index) {
+void Spectrograph::selectBar(int index)
+{
const QPair<qreal, qreal> frequencyRange = barRange(index);
- const QString message = QString("%1 - %2 Hz")
- .arg(frequencyRange.first)
- .arg(frequencyRange.second);
+ const QString message =
+ QStringLiteral("%1 - %2 Hz").arg(frequencyRange.first).arg(frequencyRange.second);
emit infoMessage(message, BarSelectionInterval);
if (NullTimerId != m_timerId)
@@ -246,4 +199,4 @@ void Spectrograph::selectBar(int index) {
update();
}
-
+#include "moc_spectrograph.cpp"
diff --git a/examples/multimedia/spectrum/spectrograph.h b/examples/multimedia/spectrum/spectrograph.h
index 0e7b11717..1344d3257 100644
--- a/examples/multimedia/spectrum/spectrograph.h
+++ b/examples/multimedia/spectrum/spectrograph.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPECTROGRAPH_H
#define SPECTROGRAPH_H
@@ -64,7 +17,7 @@ class Spectrograph : public QWidget
Q_OBJECT
public:
- explicit Spectrograph(QWidget *parent = 0);
+ explicit Spectrograph(QWidget *parent = nullptr);
~Spectrograph();
void setParams(int numBars, qreal lowFreq, qreal highFreq);
@@ -91,18 +44,19 @@ private:
void selectBar(int index);
private:
- struct Bar {
+ struct Bar
+ {
Bar() : value(0.0), clipped(false) { }
- qreal value;
- bool clipped;
+ qreal value;
+ bool clipped;
};
- QList<Bar> m_bars;
- int m_barSelected;
- int m_timerId;
- qreal m_lowFreq;
- qreal m_highFreq;
- FrequencySpectrum m_spectrum;
+ QList<Bar> m_bars;
+ int m_barSelected;
+ int m_timerId;
+ qreal m_lowFreq;
+ qreal m_highFreq;
+ FrequencySpectrum m_spectrum;
};
#endif // SPECTROGRAPH_H
diff --git a/examples/multimedia/spectrum/spectrum.h b/examples/multimedia/spectrum/spectrum.h
index 687ae1e33..e416e82bd 100644
--- a/examples/multimedia/spectrum/spectrum.h
+++ b/examples/multimedia/spectrum/spectrum.h
@@ -1,75 +1,29 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPECTRUM_H
#define SPECTRUM_H
-#include <qglobal.h>
-#include "utils.h"
#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
+#include "utils.h"
+
+#include <QtGlobal>
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
// Number of audio samples used to calculate the frequency spectrum
-const int SpectrumLengthSamples = PowerOfTwo<FFTLengthPowerOfTwo>::Result;
+const int SpectrumLengthSamples = PowerOfTwo<FFTLengthPowerOfTwo>::Result;
// Number of bands in the frequency spectrum
-const int SpectrumNumBands = 10;
+const int SpectrumNumBands = 10;
// Lower bound of first band in the spectrum
-const qreal SpectrumLowFreq = 0.0; // Hz
+const qreal SpectrumLowFreq = 0.0; // Hz
// Upper band of last band in the spectrum
-const qreal SpectrumHighFreq = 1000.0; // Hz
+const qreal SpectrumHighFreq = 1000.0; // Hz
// Waveform window size in microseconds
const qint64 WaveformWindowDuration = 500 * 1000;
@@ -79,63 +33,59 @@ const qint64 WaveformWindowDuration = 500 * 1000;
// available until some time after QAudio*::start() has been called, and we
// need this value in order to initialize the waveform display.
// We therefore just choose a sensible value.
-const int WaveformTileLength = 4096;
+const int WaveformTileLength = 4096;
// Fudge factor used to calculate the spectrum bar heights
const qreal SpectrumAnalyserMultiplier = 0.15;
// Disable message timeout
-const int NullMessageTimeout = -1;
-
+const int NullMessageTimeout = -1;
//-----------------------------------------------------------------------------
// Types and data structures
//-----------------------------------------------------------------------------
-enum WindowFunction {
- NoWindow,
- HannWindow
-};
+enum WindowFunction { NoWindow, HannWindow };
Q_DECLARE_METATYPE(WindowFunction)
const WindowFunction DefaultWindowFunction = HannWindow;
struct Tone
{
- Tone(qreal freq = 0.0, qreal amp = 0.0)
- : frequency(freq), amplitude(amp)
- { }
+ Tone(qreal freq = 0.0, qreal amp = 0.0) : frequency(freq), amplitude(amp) { }
// Start and end frequencies for swept tone generation
- qreal frequency;
+ qreal frequency;
// Amplitude in range [0.0, 1.0]
- qreal amplitude;
+ qreal amplitude;
};
struct SweptTone
{
SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
- : startFreq(start), endFreq(end), amplitude(amp)
- { Q_ASSERT(end >= start); }
+ : startFreq(start), endFreq(end), amplitude(amp)
+ {
+ Q_ASSERT(end >= start);
+ }
SweptTone(const Tone &tone)
- : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude)
- { }
+ : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude)
+ {
+ }
// Start and end frequencies for swept tone generation
- qreal startFreq;
- qreal endFreq;
+ qreal startFreq;
+ qreal endFreq;
// Amplitude in range [0.0, 1.0]
- qreal amplitude;
+ qreal amplitude;
};
// Handle some dependencies between macros defined in the .pro file
#ifdef DISABLE_WAVEFORM
-#undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+# undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
#endif
#endif // SPECTRUM_H
-
diff --git a/examples/multimedia/spectrum/spectrumanalyser.cpp b/examples/multimedia/spectrum/spectrumanalyser.cpp
index 4a7b06809..c309c6a73 100644
--- a/examples/multimedia/spectrum/spectrumanalyser.cpp
+++ b/examples/multimedia/spectrum/spectrumanalyser.cpp
@@ -1,75 +1,31 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spectrumanalyser.h"
-#include "utils.h"
#include "fftreal_wrapper.h"
+#include "utils.h"
-#include <qmath.h>
-#include <qmetatype.h>
#include <QAudioFormat>
+#include <QMetaType>
#include <QThread>
+#include <QtMath>
SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
- : QObject(parent)
+ : QObject(parent)
#ifndef DISABLE_FFT
- , m_fft(new FFTRealWrapper)
+ ,
+ m_fft(new FFTRealWrapper)
#endif
- , m_numSamples(SpectrumLengthSamples)
- , m_windowFunction(DefaultWindowFunction)
- , m_window(SpectrumLengthSamples, 0.0)
- , m_input(SpectrumLengthSamples, 0.0)
- , m_output(SpectrumLengthSamples, 0.0)
- , m_spectrum(SpectrumLengthSamples)
+ ,
+ m_numSamples(SpectrumLengthSamples),
+ m_windowFunction(DefaultWindowFunction),
+ m_window(SpectrumLengthSamples, 0.0),
+ m_input(SpectrumLengthSamples, 0.0),
+ m_output(SpectrumLengthSamples, 0.0),
+ m_spectrum(SpectrumLengthSamples)
#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
- , m_thread(new QThread(this))
+ ,
+ m_thread(new QThread(this))
#endif
{
#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
@@ -96,7 +52,7 @@ void SpectrumAnalyserThread::setWindowFunction(WindowFunction type)
void SpectrumAnalyserThread::calculateWindow()
{
- for (int i=0; i<m_numSamples; ++i) {
+ for (int i = 0; i < m_numSamples; ++i) {
DataType x = 0.0;
switch (m_windowFunction) {
@@ -114,17 +70,16 @@ void SpectrumAnalyserThread::calculateWindow()
}
}
-void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer,
- int inputFrequency,
- int bytesPerFrame)
+void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer, int inputFrequency,
+ int bytesPerFrame)
{
#ifndef DISABLE_FFT
Q_ASSERT(buffer.size() == m_numSamples * bytesPerFrame);
// Initialize data array
const char *ptr = buffer.constData();
- for (int i=0; i<m_numSamples; ++i) {
- const qint16 pcmSample = *reinterpret_cast<const qint16*>(ptr);
+ for (int i = 0; i < m_numSamples; ++i) {
+ const qint16 pcmSample = *reinterpret_cast<const qint16 *>(ptr);
// Scale down to range [-1.0, 1.0]
const DataType realSample = pcmToReal(pcmSample);
const DataType windowedSample = realSample * m_window[i];
@@ -136,16 +91,16 @@ void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer,
m_fft->calculateFFT(m_output.data(), m_input.data());
// Analyze output to obtain amplitude and phase for each frequency
- for (int i=2; i<=m_numSamples/2; ++i) {
+ for (int i = 2; i <= m_numSamples / 2; ++i) {
// Calculate frequency of this complex sample
m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples);
const qreal real = m_output[i];
qreal imag = 0.0;
- if (i>0 && i<m_numSamples/2)
- imag = m_output[m_numSamples/2 + i];
+ if (i > 0 && i < m_numSamples / 2)
+ imag = m_output[m_numSamples / 2 + i];
- const qreal magnitude = qSqrt(real*real + imag*imag);
+ const qreal magnitude = qSqrt(real * real + imag * imag);
qreal amplitude = SpectrumAnalyserMultiplier * qLn(magnitude);
// Bound amplitude to [0.0, 1.0]
@@ -159,21 +114,21 @@ void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer,
emit calculationComplete(m_spectrum);
}
-
//=============================================================================
// SpectrumAnalyser
//=============================================================================
SpectrumAnalyser::SpectrumAnalyser(QObject *parent)
- : QObject(parent)
- , m_thread(new SpectrumAnalyserThread(this))
- , m_state(Idle)
+ : QObject(parent),
+ m_thread(new SpectrumAnalyserThread(this)),
+ m_state(Idle)
#ifdef DUMP_SPECTRUMANALYSER
- , m_count(0)
+ ,
+ m_count(0)
#endif
{
- connect(m_thread, &SpectrumAnalyserThread::calculationComplete,
- this, &SpectrumAnalyser::calculationComplete);
+ connect(m_thread, &SpectrumAnalyserThread::calculationComplete, this,
+ &SpectrumAnalyser::calculationComplete);
}
SpectrumAnalyser::~SpectrumAnalyser() = default;
@@ -194,21 +149,18 @@ void SpectrumAnalyser::setOutputPath(const QString &outputDir)
void SpectrumAnalyser::setWindowFunction(WindowFunction type)
{
- const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction",
- Qt::AutoConnection,
- Q_ARG(WindowFunction, type));
+ const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction", Qt::AutoConnection,
+ Q_ARG(WindowFunction, type));
Q_ASSERT(b);
Q_UNUSED(b); // suppress warnings in release builds
}
-void SpectrumAnalyser::calculate(const QByteArray &buffer,
- const QAudioFormat &format)
+void SpectrumAnalyser::calculate(const QByteArray &buffer, const QAudioFormat &format)
{
// QThread::currentThread is marked 'for internal use only', but
// we're only using it for debug output here, so it's probably OK :)
- SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate"
- << QThread::currentThread()
- << "state" << m_state;
+ SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate" << QThread::currentThread() << "state"
+ << m_state;
if (isReady()) {
Q_ASSERT(format.sampleFormat() == QAudioFormat::Int16);
@@ -217,15 +169,16 @@ void SpectrumAnalyser::calculate(const QByteArray &buffer,
#ifdef DUMP_SPECTRUMANALYSER
m_count++;
- const QString pcmFileName = m_outputDir.filePath(QString("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0')));
+ const QString pcmFileName =
+ m_outputDir.filePath(QStringLiteral("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0')));
QFile pcmFile(pcmFileName);
pcmFile.open(QIODevice::WriteOnly);
const int bufferLength = m_numSamples * bytesPerFrame;
pcmFile.write(buffer, bufferLength);
m_textStream << "TimeDomain " << m_count << "\n";
- const qint16* input = reinterpret_cast<const qint16*>(buffer);
- for (int i=0; i<m_numSamples; ++i) {
+ const qint16 *input = reinterpret_cast<const qint16 *>(buffer);
+ for (int i = 0; i < m_numSamples; ++i) {
m_textStream << i << "\t" << *input << "\n";
input += format.channels();
}
@@ -238,22 +191,18 @@ void SpectrumAnalyser::calculate(const QByteArray &buffer,
// calculation will be done in the child thread.
// Once the calculation is finished, a calculationChanged signal will be
// emitted by m_thread.
- const bool b = QMetaObject::invokeMethod(m_thread, "calculateSpectrum",
- Qt::AutoConnection,
- Q_ARG(QByteArray, buffer),
- Q_ARG(int, format.sampleRate()),
- Q_ARG(int, bytesPerFrame));
+ const bool b = QMetaObject::invokeMethod(
+ m_thread, "calculateSpectrum", Qt::AutoConnection, Q_ARG(QByteArray, buffer),
+ Q_ARG(int, format.sampleRate()), Q_ARG(int, bytesPerFrame));
Q_ASSERT(b);
Q_UNUSED(b); // suppress warnings in release builds
#ifdef DUMP_SPECTRUMANALYSER
m_textStream << "FrequencySpectrum " << m_count << "\n";
FrequencySpectrum::const_iterator x = m_spectrum.begin();
- for (int i=0; i<m_numSamples; ++i, ++x)
- m_textStream << i << "\t"
- << x->frequency << "\t"
- << x->amplitude<< "\t"
- << x->phase << "\n";
+ for (int i = 0; i < m_numSamples; ++i, ++x)
+ m_textStream << i << "\t" << x->frequency << "\t" << x->amplitude << "\t" << x->phase
+ << "\n";
#endif
}
}
@@ -269,7 +218,6 @@ void SpectrumAnalyser::cancelCalculation()
m_state = Cancelled;
}
-
//-----------------------------------------------------------------------------
// Private slots
//-----------------------------------------------------------------------------
@@ -281,3 +229,5 @@ void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
emit spectrumChanged(spectrum);
m_state = Idle;
}
+
+#include "moc_spectrumanalyser.cpp"
diff --git a/examples/multimedia/spectrum/spectrumanalyser.h b/examples/multimedia/spectrum/spectrumanalyser.h
index 799143489..202e602fe 100644
--- a/examples/multimedia/spectrum/spectrumanalyser.h
+++ b/examples/multimedia/spectrum/spectrumanalyser.h
@@ -1,71 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPECTRUMANALYSER_H
#define SPECTRUMANALYSER_H
+#include "frequencyspectrum.h"
+#include "spectrum.h"
+
#include <QByteArray>
-#include <QObject>
#include <QList>
+#include <QObject>
#ifdef DUMP_SPECTRUMANALYSER
-#include <QDir>
-#include <QFile>
-#include <QTextStream>
+# include <QDir>
+# include <QFile>
+# include <QTextStream>
#endif
-#include "frequencyspectrum.h"
-#include "spectrum.h"
-
#ifndef DISABLE_FFT
-#include "FFTRealFixLenParam.h"
+# include "FFTRealFixLenParam.h"
#endif
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
@@ -89,9 +42,7 @@ public:
public slots:
void setWindowFunction(WindowFunction type);
- void calculateSpectrum(const QByteArray &buffer,
- int inputFrequency,
- int bytesPerSample);
+ void calculateSpectrum(const QByteArray &buffer, int inputFrequency, int bytesPerSample);
signals:
void calculationComplete(const FrequencySpectrum &spectrum);
@@ -101,27 +52,27 @@ private:
private:
#ifndef DISABLE_FFT
- FFTRealWrapper* m_fft;
+ FFTRealWrapper *m_fft;
#endif
- const int m_numSamples;
+ const int m_numSamples;
- WindowFunction m_windowFunction;
+ WindowFunction m_windowFunction;
#ifdef DISABLE_FFT
- typedef qreal DataType;
+ typedef qreal DataType;
#else
- typedef FFTRealFixLenParam::DataType DataType;
+ typedef FFTRealFixLenParam::DataType DataType;
#endif
- QList<DataType> m_window;
+ QList<DataType> m_window;
- QList<DataType> m_input;
- QList<DataType> m_output;
+ QList<DataType> m_input;
+ QList<DataType> m_output;
- FrequencySpectrum m_spectrum;
+ FrequencySpectrum m_spectrum;
#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
- QThread* m_thread;
+ QThread *m_thread;
#endif
};
@@ -134,7 +85,7 @@ class SpectrumAnalyser : public QObject
Q_OBJECT
public:
- SpectrumAnalyser(QObject *parent = 0);
+ SpectrumAnalyser(QObject *parent = nullptr);
~SpectrumAnalyser();
#ifdef DUMP_SPECTRUMANALYSER
@@ -183,24 +134,18 @@ private:
void calculateWindow();
private:
+ SpectrumAnalyserThread *m_thread;
- SpectrumAnalyserThread* m_thread;
+ enum State { Idle, Busy, Cancelled };
- enum State {
- Idle,
- Busy,
- Cancelled
- };
-
- State m_state;
+ State m_state;
#ifdef DUMP_SPECTRUMANALYSER
- QDir m_outputDir;
- int m_count;
- QFile m_textFile;
- QTextStream m_textStream;
+ QDir m_outputDir;
+ int m_count;
+ QFile m_textFile;
+ QTextStream m_textStream;
#endif
};
#endif // SPECTRUMANALYSER_H
-
diff --git a/examples/multimedia/spectrum/tonegenerator.cpp b/examples/multimedia/spectrum/tonegenerator.cpp
index 3e70180fd..5df1df44d 100644
--- a/examples/multimedia/spectrum/tonegenerator.cpp
+++ b/examples/multimedia/spectrum/tonegenerator.cpp
@@ -1,59 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spectrum.h"
#include "utils.h"
-#include <QByteArray>
+
#include <QAudioFormat>
-#include <qmath.h>
-#include <qendian.h>
+#include <QByteArray>
+#include <QtEndian>
+#include <QtMath>
void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
{
@@ -86,7 +40,7 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
while (length) {
const qreal x = tone.amplitude * qSin(phase);
const qint16 value = realToPcm(x);
- for (int i=0; i<format.channelCount(); ++i) {
+ for (int i = 0; i < format.channelCount(); ++i) {
qToLittleEndian<qint16>(value, ptr);
ptr += channelBytes;
length -= channelBytes;
diff --git a/examples/multimedia/spectrum/tonegenerator.h b/examples/multimedia/spectrum/tonegenerator.h
index af6efade2..2c331fb3c 100644
--- a/examples/multimedia/spectrum/tonegenerator.h
+++ b/examples/multimedia/spectrum/tonegenerator.h
@@ -1,59 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TONEGENERATOR_H
#define TONEGENERATOR_H
-#include <qglobal.h>
#include "spectrum.h"
+#include <QtGlobal>
+
QT_BEGIN_NAMESPACE
class QAudioFormat;
class QByteArray;
@@ -65,4 +19,3 @@ QT_END_NAMESPACE
void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer);
#endif // TONEGENERATOR_H
-
diff --git a/examples/multimedia/spectrum/tonegeneratordialog.cpp b/examples/multimedia/spectrum/tonegeneratordialog.cpp
index 086eba758..1c98c2b86 100644
--- a/examples/multimedia/spectrum/tonegeneratordialog.cpp
+++ b/examples/multimedia/spectrum/tonegeneratordialog.cpp
@@ -1,62 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tonegeneratordialog.h"
+
+#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
-#include <QVBoxLayout>
-#include <QCheckBox>
#include <QSlider>
#include <QSpinBox>
+#include <QVBoxLayout>
const int ToneGeneratorFreqMin = 1;
const int ToneGeneratorFreqMax = 1000;
@@ -64,15 +18,14 @@ const int ToneGeneratorFreqDefault = 440;
const int ToneGeneratorAmplitudeDefault = 75;
ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
- : QDialog(parent)
- , m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this))
- , m_frequencySweepEnabled(true)
- , m_toneGeneratorControl(new QWidget(this))
- , m_toneGeneratorFrequencyControl(new QWidget(this))
- , m_frequencySlider(new QSlider(Qt::Horizontal, this))
- , m_frequencySpinBox(new QSpinBox(this))
- , m_frequency(ToneGeneratorFreqDefault)
- , m_amplitudeSlider(new QSlider(Qt::Horizontal, this))
+ : QDialog(parent),
+ m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this)),
+ m_frequencySweepEnabled(true),
+ m_toneGeneratorControl(new QWidget(this)),
+ m_toneGeneratorFrequencyControl(new QWidget(this)),
+ m_frequencySlider(new QSlider(Qt::Horizontal, this)),
+ m_frequencySpinBox(new QSpinBox(this)),
+ m_amplitudeSlider(new QSlider(Qt::Horizontal, this))
{
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
@@ -106,12 +59,11 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
dialogLayout->addWidget(m_toneGeneratorControl);
// Connect
- connect(m_toneGeneratorSweepCheckBox, &QCheckBox::toggled,
- this, &ToneGeneratorDialog::frequencySweepEnabled);
- connect(m_frequencySlider, &QSlider::valueChanged,
- m_frequencySpinBox, &QSpinBox::setValue);
- connect(m_frequencySpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
- m_frequencySlider, &QSlider::setValue);
+ connect(m_toneGeneratorSweepCheckBox, &QCheckBox::toggled, this,
+ &ToneGeneratorDialog::frequencySweepEnabled);
+ connect(m_frequencySlider, &QSlider::valueChanged, m_frequencySpinBox, &QSpinBox::setValue);
+ connect(m_frequencySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), m_frequencySlider,
+ &QSlider::setValue);
// Add standard buttons to layout
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
@@ -119,10 +71,10 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
dialogLayout->addWidget(buttonBox);
// Connect standard buttons
- connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
- this, &ToneGeneratorDialog::accept);
- connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
- this, &ToneGeneratorDialog::reject);
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this,
+ &ToneGeneratorDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this,
+ &ToneGeneratorDialog::reject);
setLayout(dialogLayout);
}
@@ -149,3 +101,5 @@ void ToneGeneratorDialog::frequencySweepEnabled(bool enabled)
m_frequencySweepEnabled = enabled;
m_toneGeneratorFrequencyControl->setEnabled(!enabled);
}
+
+#include "moc_tonegeneratordialog.cpp"
diff --git a/examples/multimedia/spectrum/tonegeneratordialog.h b/examples/multimedia/spectrum/tonegeneratordialog.h
index 5095cbb7d..2b0aed501 100644
--- a/examples/multimedia/spectrum/tonegeneratordialog.h
+++ b/examples/multimedia/spectrum/tonegeneratordialog.h
@@ -1,57 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TONEGENERATORDIALOG_H
#define TONEGENERATORDIALOG_H
#include "spectrum.h"
+
#include <QAudioDevice>
#include <QDialog>
@@ -70,7 +24,7 @@ class ToneGeneratorDialog : public QDialog
Q_OBJECT
public:
- explicit ToneGeneratorDialog(QWidget *parent = 0);
+ explicit ToneGeneratorDialog(QWidget *parent = nullptr);
~ToneGeneratorDialog();
bool isFrequencySweepEnabled() const;
@@ -87,7 +41,6 @@ private:
QWidget *m_toneGeneratorFrequencyControl;
QSlider *m_frequencySlider;
QSpinBox *m_frequencySpinBox;
- qreal m_frequency;
QSlider *m_amplitudeSlider;
};
diff --git a/examples/multimedia/spectrum/utils.cpp b/examples/multimedia/spectrum/utils.cpp
index 2a6b2a33e..3b4146a51 100644
--- a/examples/multimedia/spectrum/utils.cpp
+++ b/examples/multimedia/spectrum/utils.cpp
@@ -1,55 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QAudioFormat>
#include "utils.h"
+#include <QAudioFormat>
qreal nyquistFrequency(const QAudioFormat &format)
{
@@ -81,7 +34,7 @@ QString formatToString(const QAudioFormat &format)
break;
}
- QString formatChannels = QString("%1 channels").arg(format.channelCount());
+ QString formatChannels = QStringLiteral("%1 channels").arg(format.channelCount());
switch (format.channelCount()) {
case 1:
formatChannels = "mono";
@@ -91,18 +44,18 @@ QString formatToString(const QAudioFormat &format)
break;
}
- result = QString("%1 Hz %2 bit %3 %4")
- .arg(format.sampleRate())
- .arg(format.bytesPerSample() * 8)
- .arg(formatType)
- .arg(formatChannels);
+ result = QStringLiteral("%1 Hz %2 bit %3 %4")
+ .arg(format.sampleRate())
+ .arg(format.bytesPerSample() * 8)
+ .arg(formatType)
+ .arg(formatChannels);
}
return result;
}
-const qint16 PCMS16MaxValue = 32767;
-const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768
+const qint16 PCMS16MaxValue = 32767;
+const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768
qreal pcmToReal(qint16 pcm)
{
diff --git a/examples/multimedia/spectrum/utils.h b/examples/multimedia/spectrum/utils.h
index d143a83f7..da0711c66 100644
--- a/examples/multimedia/spectrum/utils.h
+++ b/examples/multimedia/spectrum/utils.h
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef UTILS_H
#define UTILS_H
-#include <QtCore/qglobal.h>
#include <QDebug>
+#include <QtGlobal>
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
@@ -72,12 +25,19 @@ qint16 realToPcm(qreal real);
// Compile-time calculation of powers of two
-template<int N> class PowerOfTwo
-{ public: static const int Result = PowerOfTwo<N-1>::Result * 2; };
-
-template<> class PowerOfTwo<0>
-{ public: static const int Result = 1; };
+template<int N>
+class PowerOfTwo
+{
+public:
+ static const int Result = PowerOfTwo<N - 1>::Result * 2;
+};
+template<>
+class PowerOfTwo<0>
+{
+public:
+ static const int Result = 1;
+};
//-----------------------------------------------------------------------------
// Debug output
@@ -86,28 +46,34 @@ template<> class PowerOfTwo<0>
class NullDebug
{
public:
- template <typename T>
- NullDebug& operator<<(const T&) { return *this; }
+ template<typename T>
+ NullDebug &operator<<(const T &)
+ {
+ return *this;
+ }
};
-inline NullDebug nullDebug() { return NullDebug(); }
+inline NullDebug nullDebug()
+{
+ return NullDebug();
+}
#ifdef LOG_ENGINE
-# define ENGINE_DEBUG qDebug()
+# define ENGINE_DEBUG qDebug()
#else
-# define ENGINE_DEBUG nullDebug()
+# define ENGINE_DEBUG nullDebug()
#endif
#ifdef LOG_SPECTRUMANALYSER
-# define SPECTRUMANALYSER_DEBUG qDebug()
+# define SPECTRUMANALYSER_DEBUG qDebug()
#else
-# define SPECTRUMANALYSER_DEBUG nullDebug()
+# define SPECTRUMANALYSER_DEBUG nullDebug()
#endif
#ifdef LOG_WAVEFORM
-# define WAVEFORM_DEBUG qDebug()
+# define WAVEFORM_DEBUG qDebug()
#else
-# define WAVEFORM_DEBUG nullDebug()
+# define WAVEFORM_DEBUG nullDebug()
#endif
#endif // UTILS_H
diff --git a/examples/multimedia/spectrum/waveform.cpp b/examples/multimedia/spectrum/waveform.cpp
index 5f9563a8d..a3727a2a6 100644
--- a/examples/multimedia/spectrum/waveform.cpp
+++ b/examples/multimedia/spectrum/waveform.cpp
@@ -1,76 +1,30 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "waveform.h"
#include "utils.h"
+
+#include <QDebug>
#include <QPainter>
#include <QResizeEvent>
-#include <QDebug>
//#define PAINT_EVENT_TRACE
#ifdef PAINT_EVENT_TRACE
-# define WAVEFORM_PAINT_DEBUG qDebug()
+# define WAVEFORM_PAINT_DEBUG qDebug()
#else
-# define WAVEFORM_PAINT_DEBUG nullDebug()
+# define WAVEFORM_PAINT_DEBUG nullDebug()
#endif
Waveform::Waveform(QWidget *parent)
- : QWidget(parent)
- , m_bufferPosition(0)
- , m_bufferLength(0)
- , m_audioPosition(0)
- , m_active(false)
- , m_tileLength(0)
- , m_tileArrayStart(0)
- , m_windowPosition(0)
- , m_windowLength(0)
+ : QWidget(parent),
+ m_bufferPosition(0),
+ m_bufferLength(0),
+ m_audioPosition(0),
+ m_active(false),
+ m_tileLength(0),
+ m_tileArrayStart(0),
+ m_windowPosition(0),
+ m_windowLength(0)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setMinimumHeight(50);
@@ -89,24 +43,23 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
if (m_active) {
WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
- << "windowPosition" << m_windowPosition
- << "windowLength" << m_windowLength;
+ << "windowPosition" << m_windowPosition << "windowLength"
+ << m_windowLength;
qint64 pos = m_windowPosition;
const qint64 windowEnd = m_windowPosition + m_windowLength;
int destLeft = 0;
int destRight = 0;
while (pos < windowEnd) {
const TilePoint point = tilePoint(pos);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos" << pos
- << "tileIndex" << point.index
- << "positionOffset" << point.positionOffset
- << "pixelOffset" << point.pixelOffset;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos" << pos << "tileIndex" << point.index << "positionOffset"
+ << point.positionOffset << "pixelOffset" << point.pixelOffset;
if (point.index != NullIndex) {
const Tile &tile = m_tiles[point.index];
if (tile.painted) {
- const qint64 sectionLength = qMin((m_tileLength - point.positionOffset),
- (windowEnd - pos));
+ const qint64 sectionLength =
+ qMin((m_tileLength - point.positionOffset), (windowEnd - pos));
Q_ASSERT(sectionLength > 0);
const int sourceRight = tilePixelOffset(point.positionOffset + sectionLength);
@@ -120,9 +73,10 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
sourceRect.setLeft(point.pixelOffset);
sourceRect.setRight(sourceRight);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "tileIndex" << point.index
- << "source" << point.pixelOffset << sourceRight
- << "dest" << destLeft << destRight;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "tileIndex" << point.index << "source"
+ << point.pixelOffset << sourceRight << "dest" << destLeft
+ << destRight;
painter.drawPixmap(destRect, *tile.pixmap, sourceRect);
@@ -130,25 +84,30 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
if (point.index < m_tiles.count()) {
pos = tilePosition(point.index + 1);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos ->" << pos;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos ->" << pos;
} else {
// Reached end of tile array
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "reached end of tile array";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "reached end of tile array";
break;
}
} else {
// Passed last tile which is painted
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "tile" << point.index << "not painted";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "tile" << point.index << "not painted";
break;
}
} else {
// pos is past end of tile array
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos" << pos << "past end of tile array";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos" << pos << "past end of tile array";
break;
}
}
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "final pos" << pos << "final x" << destRight;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "final pos" << pos << "final x" << destRight;
}
}
@@ -158,11 +117,12 @@ void Waveform::resizeEvent(QResizeEvent *event)
createPixmaps(event->size());
}
-void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs)
+void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize,
+ qint64 windowDurationUs)
{
WAVEFORM_DEBUG << "Waveform::initialize"
- << "audioBufferSize" << audioBufferSize
- << "windowDurationUs" << windowDurationUs;
+ << "audioBufferSize" << audioBufferSize << "windowDurationUs"
+ << windowDurationUs;
reset();
@@ -185,9 +145,8 @@ void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qi
}
WAVEFORM_DEBUG << "Waveform::initialize"
- << "tileLength" << m_tileLength
- << "windowLength" << m_windowLength
- << "nTiles" << nTiles;
+ << "tileLength" << m_tileLength << "windowLength" << m_windowLength << "nTiles"
+ << nTiles;
m_pixmaps.fill(nullptr, nTiles);
m_tiles.resize(nTiles);
@@ -217,8 +176,7 @@ void Waveform::reset()
void Waveform::bufferChanged(qint64 position, qint64 length, const QByteArray &buffer)
{
WAVEFORM_DEBUG << "Waveform::bufferChanged"
- << "audioPosition" << m_audioPosition
- << "bufferPosition" << position
+ << "audioPosition" << m_audioPosition << "bufferPosition" << position
<< "bufferLength" << length;
m_bufferPosition = position;
m_bufferLength = length;
@@ -229,8 +187,7 @@ void Waveform::bufferChanged(qint64 position, qint64 length, const QByteArray &b
void Waveform::audioPositionChanged(qint64 position)
{
WAVEFORM_DEBUG << "Waveform::audioPositionChanged"
- << "audioPosition" << position
- << "bufferPosition" << m_bufferPosition
+ << "audioPosition" << position << "bufferPosition" << m_bufferPosition
<< "bufferLength" << m_bufferLength;
if (position >= m_bufferPosition) {
@@ -243,7 +200,7 @@ void Waveform::audioPositionChanged(qint64 position)
void Waveform::deletePixmaps()
{
- qDeleteAll(qExchange(m_pixmaps, {}));
+ qDeleteAll(std::exchange(m_pixmaps, {}));
}
void Waveform::createPixmaps(const QSize &widgetSize)
@@ -252,19 +209,18 @@ void Waveform::createPixmaps(const QSize &widgetSize)
m_pixmapSize.setWidth(qreal(widgetSize.width()) * m_tileLength / m_windowLength);
WAVEFORM_DEBUG << "Waveform::createPixmaps"
- << "widgetSize" << widgetSize
- << "pixmapSize" << m_pixmapSize;
+ << "widgetSize" << widgetSize << "pixmapSize" << m_pixmapSize;
Q_ASSERT(m_tiles.count() == m_pixmaps.count());
// (Re)create pixmaps
- for (auto & pixmap : m_pixmaps) {
+ for (auto &pixmap : m_pixmaps) {
delete pixmap;
pixmap = new QPixmap(m_pixmapSize);
}
// Update tile pixmap pointers, and mark for repainting
- for (int i=0; i<m_tiles.count(); ++i) {
+ for (int i = 0; i < m_tiles.count(); ++i) {
m_tiles[i].pixmap = m_pixmaps[i];
m_tiles[i].painted = false;
}
@@ -273,14 +229,14 @@ void Waveform::createPixmaps(const QSize &widgetSize)
void Waveform::setWindowPosition(qint64 position)
{
WAVEFORM_DEBUG << "Waveform::setWindowPosition"
- << "old" << m_windowPosition << "new" << position
- << "tileArrayStart" << m_tileArrayStart;
+ << "old" << m_windowPosition << "new" << position << "tileArrayStart"
+ << m_tileArrayStart;
const qint64 oldPosition = m_windowPosition;
m_windowPosition = position;
- if ((m_windowPosition >= oldPosition) &&
- (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) {
+ if ((m_windowPosition >= oldPosition)
+ && (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) {
// Work out how many tiles need to be shuffled
const qint64 offset = m_windowPosition - m_tileArrayStart;
const int nTiles = offset / m_tileLength;
@@ -335,7 +291,7 @@ bool Waveform::paintTiles()
WAVEFORM_DEBUG << "Waveform::paintTiles";
bool updateRequired = false;
- for (int i=0; i<m_tiles.count(); ++i) {
+ for (int i = 0; i < m_tiles.count(); ++i) {
const Tile &tile = m_tiles[i];
if (!tile.painted) {
const qint64 tileStart = m_tileArrayStart + i * m_tileLength;
@@ -358,11 +314,8 @@ void Waveform::paintTile(int index)
const qint64 tileStart = m_tileArrayStart + index * m_tileLength;
WAVEFORM_DEBUG << "Waveform::paintTile"
- << "index" << index
- << "bufferPosition" << m_bufferPosition
- << "bufferLength" << m_bufferLength
- << "start" << tileStart
- << "end" << tileStart + m_tileLength;
+ << "index" << index << "bufferPosition" << m_bufferPosition << "bufferLength"
+ << m_bufferLength << "start" << tileStart << "end" << tileStart + m_tileLength;
Q_ASSERT(m_bufferPosition <= tileStart);
Q_ASSERT(m_bufferPosition + m_bufferLength >= tileStart + m_tileLength);
@@ -370,8 +323,8 @@ void Waveform::paintTile(int index)
Tile &tile = m_tiles[index];
Q_ASSERT(!tile.painted);
- const qint16* base = reinterpret_cast<const qint16*>(m_buffer.constData());
- const qint16* buffer = base + ((tileStart - m_bufferPosition) / 2);
+ const qint16 *base = reinterpret_cast<const qint16 *>(m_buffer.constData());
+ const qint16 *buffer = base + ((tileStart - m_bufferPosition) / 2);
const int numSamples = m_tileLength / (2 * m_format.channelCount());
QPainter painter(tile.pixmap);
@@ -393,10 +346,10 @@ void Waveform::paintTile(int index)
QLine line(origin, origin);
- for (int i=0; i<numSamples; ++i) {
- const qint16* ptr = buffer + i * m_format.channelCount();
+ for (int i = 0; i < numSamples; ++i) {
+ const qint16 *ptr = buffer + i * m_format.channelCount();
- const int offset = reinterpret_cast<const char*>(ptr) - m_buffer.constData();
+ const int offset = reinterpret_cast<const char *>(ptr) - m_buffer.constData();
Q_ASSERT(offset >= 0);
Q_ASSERT(offset < m_bufferLength);
Q_UNUSED(offset);
@@ -417,7 +370,8 @@ void Waveform::paintTile(int index)
void Waveform::shuffleTiles(int n)
{
- WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "n" << n;
+ WAVEFORM_DEBUG << "Waveform::shuffleTiles"
+ << "n" << n;
while (n--) {
Tile tile = m_tiles.first();
@@ -427,17 +381,20 @@ void Waveform::shuffleTiles(int n)
m_tileArrayStart += m_tileLength;
}
- WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "tileArrayStart" << m_tileArrayStart;
+ WAVEFORM_DEBUG << "Waveform::shuffleTiles"
+ << "tileArrayStart" << m_tileArrayStart;
}
void Waveform::resetTiles(qint64 newStartPos)
{
- WAVEFORM_DEBUG << "Waveform::resetTiles" << "newStartPos" << newStartPos;
+ WAVEFORM_DEBUG << "Waveform::resetTiles"
+ << "newStartPos" << newStartPos;
QList<Tile>::iterator i = m_tiles.begin();
- for ( ; i != m_tiles.end(); ++i)
+ for (; i != m_tiles.end(); ++i)
i->painted = false;
m_tileArrayStart = newStartPos;
}
+#include "moc_waveform.cpp"
diff --git a/examples/multimedia/spectrum/waveform.h b/examples/multimedia/spectrum/waveform.h
index 8c26e99b2..86fda9962 100644
--- a/examples/multimedia/spectrum/waveform.h
+++ b/examples/multimedia/spectrum/waveform.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WAVEFORM_H
#define WAVEFORM_H
@@ -70,7 +23,7 @@ class Waveform : public QWidget
Q_OBJECT
public:
- explicit Waveform(QWidget *parent = 0);
+ explicit Waveform(QWidget *parent = nullptr);
~Waveform();
// QWidget
@@ -115,17 +68,18 @@ private:
struct TilePoint
{
TilePoint(int idx = 0, qint64 pos = 0, qint64 pix = 0)
- : index(idx), positionOffset(pos), pixelOffset(pix)
- { }
+ : index(idx), positionOffset(pos), pixelOffset(pix)
+ {
+ }
// Index of tile
- int index;
+ int index;
// Number of bytes from start of tile
- qint64 positionOffset;
+ qint64 positionOffset;
// Number of pixels from left of corresponding pixmap
- int pixelOffset;
+ int pixelOffset;
};
/*
@@ -177,36 +131,37 @@ private:
void resetTiles(qint64 newStartPos);
private:
- qint64 m_bufferPosition;
- qint64 m_bufferLength;
- QByteArray m_buffer;
+ qint64 m_bufferPosition;
+ qint64 m_bufferLength;
+ QByteArray m_buffer;
- qint64 m_audioPosition;
- QAudioFormat m_format;
+ qint64 m_audioPosition;
+ QAudioFormat m_format;
- bool m_active;
+ bool m_active;
- QSize m_pixmapSize;
- QList<QPixmap*> m_pixmaps;
+ QSize m_pixmapSize;
+ QList<QPixmap *> m_pixmaps;
- struct Tile {
+ struct Tile
+ {
// Pointer into parent m_pixmaps array
- QPixmap* pixmap;
+ QPixmap *pixmap;
// Flag indicating whether this tile has been painted
- bool painted;
+ bool painted;
};
- QList<Tile> m_tiles;
+ QList<Tile> m_tiles;
// Length of audio data in bytes depicted by each tile
- qint64 m_tileLength;
+ qint64 m_tileLength;
// Position in bytes of the first tile, relative to m_buffer
- qint64 m_tileArrayStart;
+ qint64 m_tileArrayStart;
- qint64 m_windowPosition;
- qint64 m_windowLength;
+ qint64 m_windowPosition;
+ qint64 m_windowLength;
};
#endif // WAVEFORM_H
diff --git a/examples/multimedia/video/CMakeLists.txt b/examples/multimedia/video/CMakeLists.txt
index d3f707074..72e5d7e8a 100644
--- a/examples/multimedia/video/CMakeLists.txt
+++ b/examples/multimedia/video/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
qt_internal_add_example(qmlvideo)
if(TARGET Qt::QuickControls2)
if(TARGET Qt::Svg)
diff --git a/examples/multimedia/video/mediaplayer/AudioControl.qml b/examples/multimedia/video/mediaplayer/AudioControl.qml
deleted file mode 100644
index 7e504bc5c..000000000
--- a/examples/multimedia/video/mediaplayer/AudioControl.qml
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
-
- required property MediaPlayer mediaPlayer
- property bool muted: false
- property real volume: volumeSlider.value/100.
-
- implicitHeight: buttons.height
-
- RowLayout {
- anchors.fill: parent
-
- Item {
- id: buttons
-
- width: muteButton.implicitWidth
- height: muteButton.implicitHeight
-
- RoundButton {
- id: muteButton
- radius: 50.0
- icon.source: muted ? "qrc:///Mute_Icon.svg" : "qrc:///Speaker_Icon.svg"
- onClicked: { muted = !muted }
- }
- }
-
- Slider {
- id: volumeSlider
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignVCenter
-
- enabled: true
- to: 100.0
- value: 100.0
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/CMakeLists.txt b/examples/multimedia/video/mediaplayer/CMakeLists.txt
index df62fbee1..e33a20ad4 100644
--- a/examples/multimedia/video/mediaplayer/CMakeLists.txt
+++ b/examples/multimedia/video/mediaplayer/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(mediaplayer LANGUAGES CXX)
@@ -10,39 +13,56 @@ endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/mediaplayer")
-find_package(Qt6 REQUIRED COMPONENTS Core Quick QuickControls2 Svg)
+find_package(Qt6 REQUIRED COMPONENTS Multimedia Core Quick QuickControls2 Svg)
+
+qt_standard_project_setup(REQUIRES 6.5)
-qt_add_executable(mediaplayer
+qt_add_executable(mediaplayerexample
main.cpp
)
-set(resource_files
- "main.qml"
- "PlaybackControl.qml"
- "MetadataInfo.qml"
- "AudioControl.qml"
- "PlaybackSeekControl.qml"
- "PlaybackRateControl.qml"
- "PlayerMenuBar.qml"
- "TracksInfo.qml"
- "Mute_Icon.svg"
- "Speaker_Icon.svg"
+set_target_properties(mediaplayerexample PROPERTIES
+ MACOSX_BUNDLE TRUE
)
-qt_add_resources(mediaplayer "mediaplayer"
- PREFIX
- "/"
- FILES
- ${resource_files}
+qt_add_qml_module(mediaplayerexample
+ URI mediaplayer
+ QML_FILES
+ "Main.qml"
+ "controls/PlaybackControl.qml"
+ "controls/AudioControl.qml"
+ "controls/PlaybackSeekControl.qml"
+ "controls/SettingsPopup.qml"
+ "controls/UrlPopup.qml"
+ "controls/MetadataInfo.qml"
+ "controls/TracksInfo.qml"
+ RESOURCES
+ "images/backward10.svg"
+ "images/mute.svg"
+ "images/open_new.svg"
+ "images/pause_symbol.svg"
+ "images/play_symbol.svg"
+ "images/forward10.svg"
+ "images/more.svg"
+ "images/speaker.svg"
+ "images/stop_symbol.svg"
+ "images/volume.svg"
+ "images/volume_mute.svg"
+ "images/zoom_maximize.svg"
+ "images/zoom_minimize.svg"
+ "images/link.svg"
+ "images/loop.svg"
)
-target_link_libraries(mediaplayer PRIVATE
+target_link_libraries(mediaplayerexample PRIVATE
Qt6::Core
+ Qt6::Multimedia
Qt6::Svg
Qt6::Quick
+ Qt6::Multimedia
)
-install(TARGETS mediaplayer
+install(TARGETS mediaplayerexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/multimedia/video/mediaplayer/Main.qml b/examples/multimedia/video/mediaplayer/Main.qml
new file mode 100644
index 000000000..bc924dfb8
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/Main.qml
@@ -0,0 +1,178 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import QtQuick.Dialogs
+import QtMultimedia
+import "controls"
+
+//! [0]
+ApplicationWindow {
+ id: root
+ title: qsTr("Multimedia Player")
+ width: 1280
+ height: 720
+ //! [0]
+ minimumWidth: 960
+ minimumHeight: 540
+ visible: true
+ color: "black"
+
+ property alias source: mediaPlayer.source
+ property alias playbackRate: mediaPlayer.playbackRate
+ property bool fullScreen: false
+
+ MessageDialog {
+ id: mediaError
+ buttons: MessageDialog.Ok
+ }
+
+ MouseArea {
+ // an activity listener to hide the playback contols when idle
+ id: activityListener
+ anchors.fill: parent
+ z: 1
+ propagateComposedEvents: true
+ hoverEnabled: true
+
+ property bool inactiveMouse: false
+
+ Timer {
+ id: timer
+ interval: 1500 // milliseconds
+ onTriggered: activityListener.inactiveMouse = true
+ }
+
+ function activityHandler(mouse) {
+ if (activityListener.inactiveMouse)
+ activityListener.inactiveMouse = false
+ timer.restart()
+ timer.start()
+ mouse.accepted = false
+ }
+
+ onPositionChanged: mouse => activityHandler(mouse)
+ onPressed: mouse => activityHandler(mouse)
+ onDoubleClicked: mouse => mouse.accepted = false
+ }
+
+ MetadataInfo {
+ id: metadataInfo
+ }
+
+ TracksInfo {
+ id: audioTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeAudioTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ TracksInfo {
+ id: videoTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeVideoTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ TracksInfo {
+ id: subtitleTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeSubtitleTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ //! [1]
+ MediaPlayer {
+ id: mediaPlayer
+ //! [1]
+ function updateMetadata() {
+ metadataInfo.clear()
+ metadataInfo.read(mediaPlayer.metaData)
+ metadataInfo.read(mediaPlayer.audioTracks[mediaPlayer.activeAudioTrack])
+ metadataInfo.read(mediaPlayer.videoTracks[mediaPlayer.activeVideoTrack])
+ metadataInfo.read(mediaPlayer.subtitleTracks[mediaPlayer.activeSubtitleTrack])
+ }
+ //! [2]
+ videoOutput: videoOutput
+ audioOutput: AudioOutput {
+ id: audio
+ muted: playbackController.muted
+ volume: playbackController.volume
+ }
+ //! [2]
+ //! [4]
+ onErrorOccurred: {
+ mediaError.open()
+ mediaError.text = mediaPlayer.errorString
+ }
+ //! [4]
+ onMetaDataChanged: { updateMetadata() }
+ //! [6]
+ onTracksChanged: {
+ audioTracksInfo.read(mediaPlayer.audioTracks)
+ videoTracksInfo.read(mediaPlayer.videoTracks)
+ subtitleTracksInfo.read(mediaPlayer.subtitleTracks, 6) /* QMediaMetaData::Language = 6 */
+ updateMetadata()
+ mediaPlayer.play()
+ }
+ //! [6]
+ source: new URL("https://download.qt.io/learning/videos/media-player-example/Qt_LogoMergeEffect.mp4")
+ }
+
+ //! [3]
+ VideoOutput {
+ id: videoOutput
+ anchors.fill: parent
+ visible: mediaPlayer.mediaStatus > 0
+
+ TapHandler {
+ onDoubleTapped: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+ }
+ //! [3]
+
+ Rectangle {
+ anchors.fill: parent
+ visible: mediaPlayer.mediaStatus === 0
+ color: "black"
+
+ TapHandler {
+ onDoubleTapped: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+ }
+
+ //! [5]
+ PlaybackControl {
+ id: playbackController
+ //! [5]
+
+ property bool showControls: !activityListener.inactiveMouse || busy
+ opacity: showControls
+ // onOpacityChanged can't be used as it is animated and therefore not immediate
+ onShowControlsChanged: activityListener.cursorShape = showControls ?
+ Qt.ArrowCursor : Qt.BlankCursor
+
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ //! [6]
+ mediaPlayer: mediaPlayer
+ audioTracksInfo: audioTracksInfo
+ videoTracksInfo: videoTracksInfo
+ subtitleTracksInfo: subtitleTracksInfo
+ metadataInfo: metadataInfo
+ }
+ //! [6]
+}
diff --git a/examples/multimedia/video/mediaplayer/MetadataInfo.qml b/examples/multimedia/video/mediaplayer/MetadataInfo.qml
deleted file mode 100644
index 5019c1759..000000000
--- a/examples/multimedia/video/mediaplayer/MetadataInfo.qml
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
- implicitWidth: 200
-
- function clear() {
- elements.clear();
- }
-
- function read(metadata) {
- if (metadata) {
- for (var key of metadata.keys()) {
- if (metadata.stringValue(key)) {
- elements.append(
- { name: metadata.metaDataKeyToString(key)
- , value: metadata.stringValue(key)
- })
- }
- }
- }
- }
-
- ListModel {
- id: elements
- }
-
- Frame {
- anchors.fill: parent
- padding: 15
-
- background: Rectangle {
- color: "lightgray"
- opacity: 0.7
- }
-
- ListView {
- id: metadataList
- visible: elements.count > 0
- anchors.fill: parent
- model: elements
- delegate: RowLayout {
- width: metadataList.width
- Text {
- Layout.preferredWidth: 90
- text: model.name + ":"
- horizontalAlignment: Text.AlignRight
- }
- Text {
- Layout.fillWidth: true
- text: model.value
- wrapMode: Text.WrapAnywhere
- }
- }
- }
-
- Text {
- id: metadataNoList
- visible: elements.count === 0
- text: qsTr("No metadata present")
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/PlaybackControl.qml b/examples/multimedia/video/mediaplayer/PlaybackControl.qml
deleted file mode 100644
index 50715c537..000000000
--- a/examples/multimedia/video/mediaplayer/PlaybackControl.qml
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
-
- required property MediaPlayer mediaPlayer
- property int mediaPlayerState: mediaPlayer.playbackState
- property alias muted: audio.muted
- property alias volume: audio.volume
-
- height: frame.height
-
- opacity: 1
-
- Behavior on opacity { NumberAnimation { duration: 300 }}
-
- function updateOpacity() {
- //hover is not usable in mobile platforms
- if (Qt.platform.os == "android" || Qt.platform.os == "ios")
- return;
-
- if (playbackControlHoover.hovered || mediaPlayerState != MediaPlayer.PlayingState || !mediaPlayer.hasVideo)
- root.opacity = 1;
- else
- root.opacity = 1; // 0; TODO: enable opacity change when HoverHandle is fixed
- }
-
- Connections {
- target: mediaPlayer
- function onPlaybackStateChanged() { updateOpacity() }
- function onHasVideoChanged() { updateOpacity() }
- }
-
- HoverHandler {
- id: playbackControlHoover
- margin: 50
- onHoveredChanged: updateOpacity()
- }
-
- Frame {
- id: frame
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
-
- background: Rectangle {
- color: "white"
- }
-
- ColumnLayout {
- id: playbackControlPanel
- anchors.fill: parent
- anchors.leftMargin: 10
- anchors.rightMargin: 10
-
- PlaybackSeekControl {
- Layout.fillWidth: true
- mediaPlayer: root.mediaPlayer
- }
-
- RowLayout {
- id: playerButtons
-
- Layout.fillWidth: true
-
- PlaybackRateControl {
- Layout.minimumWidth: 100
- Layout.maximumWidth: 150
- Layout.fillHeight: true
- Layout.fillWidth: true
- mediaPlayer: root.mediaPlayer
- }
-
- Item {
- Layout.fillWidth: true
- }
-
- RowLayout {
- Layout.alignment: Qt.AlignCenter
- id: controlButtons
-
- RoundButton {
- id: pauseButton
- radius: 50.0
- text: "\u2016";
- onClicked: mediaPlayer.pause()
- }
-
- RoundButton {
- id: playButton
- radius: 50.0
- text: "\u25B6";
- onClicked: mediaPlayer.play()
- }
-
- RoundButton {
- id: stopButton
- radius: 50.0
- text: "\u25A0";
- onClicked: mediaPlayer.stop()
- }
- }
-
- Item {
- Layout.fillWidth: true
- }
-
- AudioControl {
- id: audio
- Layout.minimumWidth: 100
- Layout.maximumWidth: 150
- Layout.fillWidth: true
- mediaPlayer: root.mediaPlayer
- }
- }
- }
- }
-
- states: [
- State {
- name: "playing"
- when: mediaPlayerState == MediaPlayer.PlayingState
- PropertyChanges { target: pauseButton; visible: true}
- PropertyChanges { target: playButton; visible: false}
- PropertyChanges { target: stopButton; visible: true}
- },
- State {
- name: "stopped"
- when: mediaPlayerState == MediaPlayer.StoppedState
- PropertyChanges { target: pauseButton; visible: false}
- PropertyChanges { target: playButton; visible: true}
- PropertyChanges { target: stopButton; visible: false}
- },
- State {
- name: "paused"
- when: mediaPlayerState == MediaPlayer.PausedState
- PropertyChanges { target: pauseButton; visible: false}
- PropertyChanges { target: playButton; visible: true}
- PropertyChanges { target: stopButton; visible: true}
- }
- ]
-
-}
-
diff --git a/examples/multimedia/video/mediaplayer/PlaybackRateControl.qml b/examples/multimedia/video/mediaplayer/PlaybackRateControl.qml
deleted file mode 100644
index 99c151a77..000000000
--- a/examples/multimedia/video/mediaplayer/PlaybackRateControl.qml
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
-
- required property MediaPlayer mediaPlayer
-
- RowLayout {
- anchors.fill: parent
-
- Slider {
- id: slider
- Layout.fillWidth: true
- snapMode: Slider.SnapOnRelease
- enabled: true
- from: 0.5
- to: 2.5
- stepSize: 0.5
- value: 1.0
-
- onMoved: { mediaPlayer.setPlaybackRate(value) }
- }
- Text {
- text: "Rate " + slider.value + "x"
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/PlaybackSeekControl.qml b/examples/multimedia/video/mediaplayer/PlaybackSeekControl.qml
deleted file mode 100644
index 5c04d1848..000000000
--- a/examples/multimedia/video/mediaplayer/PlaybackSeekControl.qml
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
-
- required property MediaPlayer mediaPlayer
-
- implicitHeight: 20
-
-
- RowLayout {
- anchors.fill: parent
-
- Text {
- id: mediaTime
- Layout.minimumWidth: 50
- Layout.minimumHeight: 18
- horizontalAlignment: Text.AlignRight
- text: {
- var m = Math.floor(mediaPlayer.position / 60000)
- var ms = (mediaPlayer.position / 1000 - m * 60).toFixed(1)
- return `${m}:${ms.padStart(4, 0)}`
- }
- }
-
- Slider {
- id: mediaSlider
- Layout.fillWidth: true
- enabled: mediaPlayer.seekable
- to: 1.0
- value: mediaPlayer.position / mediaPlayer.duration
-
- onMoved: mediaPlayer.setPosition(value * mediaPlayer.duration)
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/PlayerMenuBar.qml b/examples/multimedia/video/mediaplayer/PlayerMenuBar.qml
deleted file mode 100644
index a8fabd30a..000000000
--- a/examples/multimedia/video/mediaplayer/PlayerMenuBar.qml
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Dialogs
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
-
- required property MediaPlayer mediaPlayer
- required property VideoOutput videoOutput
- required property MetadataInfo metadataInfo
- required property TracksInfo audioTracksInfo
- required property TracksInfo videoTracksInfo
- required property TracksInfo subtitleTracksInfo
-
- height: menuBar.height
-
- signal closePlayer
-
- function loadUrl(url) {
- mediaPlayer.stop()
- mediaPlayer.source = url
- mediaPlayer.play()
- }
-
- function closeOverlays(){
- metadataInfo.visible = false;
- audioTracksInfo.visible = false;
- videoTracksInfo.visible = false;
- subtitleTracksInfo.visible = false;
- }
-
- function showOverlay(overlay){
- closeOverlays();
- overlay.visible = true;
- }
-
- Popup {
- id: urlPopup
- anchors.centerIn: Overlay.overlay
-
- RowLayout {
- id: rowOpenUrl
- Label {
- text: qsTr("URL:");
- }
-
- TextInput {
- id: urlText
- focus: true
- Layout.minimumWidth: 400
- wrapMode: TextInput.WrapAnywhere
- Keys.onReturnPressed: { loadUrl(text); urlText.text = ""; urlPopup.close() }
- }
-
- Button {
- text: "Load"
- onClicked: { loadUrl(urlText.text); urlText.text = ""; urlPopup.close() }
- }
- }
- onOpened: { urlPopup.forceActiveFocus() }
- }
-
- FileDialog {
- id: fileDialog
- title: "Please choose a file"
- onAccepted: {
- mediaPlayer.stop()
- mediaPlayer.source = fileDialog.currentFile
- mediaPlayer.play()
- }
- }
-
- MenuBar {
- id: menuBar
- anchors.left: parent.left
- anchors.right: parent.right
-
- Menu {
- title: qsTr("&File")
- Action {
- text: qsTr("&Open")
- onTriggered: fileDialog.open()
- }
- Action {
- text: qsTr("&URL");
- onTriggered: urlPopup.open()
- }
-
- Action {
- text: qsTr("&Exit");
- onTriggered: closePlayer()
- }
- }
-
- Menu {
- title: qsTr("&View")
- Action {
- text: qsTr("Metadata")
- onTriggered: showOverlay(metadataInfo)
- }
- }
-
- Menu {
- title: qsTr("&Tracks")
- Action {
- text: qsTr("Audio")
- onTriggered: showOverlay(audioTracksInfo)
- }
- Action {
- text: qsTr("Video")
- onTriggered: showOverlay(videoTracksInfo)
- }
- Action {
- text: qsTr("Subtitles")
- onTriggered: showOverlay(subtitleTracksInfo)
- }
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/TracksInfo.qml b/examples/multimedia/video/mediaplayer/TracksInfo.qml
deleted file mode 100644
index f2851228a..000000000
--- a/examples/multimedia/video/mediaplayer/TracksInfo.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-Item {
- id: root
- implicitWidth: 200
-
- property int selectedTrack: 0
-
- function read(metadataList) {
- var LanguageKey = 6;
-
- elements.clear()
-
- elements.append(
- { language: "No Selected Track"
- , trackNumber: -1
- })
-
- if (!metadataList)
- return;
-
- metadataList.forEach(function (metadata, index) {
- var language = metadata.stringValue(LanguageKey);
- var label = language ? metadata.stringValue(LanguageKey) : "track " + (index + 1)
- elements.append(
- { language: label
- , trackNumber: index
- })
- });
- }
-
- ListModel {
- id: elements
- }
-
- Frame {
- anchors.fill: parent
- padding: 15
-
- background: Rectangle {
- color: "lightgray"
- opacity: 0.7
- }
-
- ButtonGroup {id:group; }
-
- ListView {
- id: trackList
- visible: elements.count > 0
- anchors.fill: parent
- model: elements
- delegate: RowLayout {
- width: trackList.width
- RadioButton {
- checked: model.trackNumber === selectedTrack
- text: model.language
- ButtonGroup.group: group
- onClicked: selectedTrack = model.trackNumber
- }
- }
- }
-
- Text {
- id: metadataNoList
- visible: elements.count === 0
- text: qsTr("No tracks present")
- }
- }
-}
diff --git a/examples/multimedia/video/mediaplayer/controls/AudioControl.qml b/examples/multimedia/video/mediaplayer/controls/AudioControl.qml
new file mode 100644
index 000000000..81ebe7f10
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/AudioControl.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Item {
+ id: audioController
+
+ property alias busy: slider.pressed
+ //! [0]
+ property alias muted: muteButton.checked
+ property real volume: slider.value
+ //! [0]
+ property alias showSlider: slider.visible
+ property int iconDimension: 24
+
+ implicitHeight: 46
+ implicitWidth: mainLayout.width
+
+ RowLayout {
+ id: mainLayout
+ spacing: 10
+ anchors.verticalCenter: parent.verticalCenter
+
+ RoundButton {
+ id: muteButton
+ implicitHeight: 40
+ implicitWidth: 40
+ radius: 4
+ icon.source: audioController.muted ? "../images/volume_mute.svg" : "../images/volume.svg"
+ icon.width: audioController.iconDimension
+ icon.height: audioController.iconDimension
+ flat: true
+ checkable: true
+ }
+
+ Slider {
+ id: slider
+ visible: !audioController.showSlider
+ implicitWidth: 136
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignVCenter
+
+ enabled: !audioController.muted
+ value: 1
+ }
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml b/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml
new file mode 100644
index 000000000..3e68faa8e
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml
@@ -0,0 +1,30 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ property alias metadata: listModel
+ property alias count: listModel.count
+
+ function clear() {
+ listModel.clear()
+ }
+
+ //! [0]
+ function read(metadata) {
+ if (!metadata)
+ return
+ for (const key of metadata.keys())
+ if (metadata.stringValue(key))
+ listModel.append({
+ name: metadata.metaDataKeyToString(key),
+ value: metadata.stringValue(key)
+ })
+ }
+
+ ListModel {
+ id: listModel
+ }
+ //! [0]
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml b/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml
new file mode 100644
index 000000000..c61656103
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml
@@ -0,0 +1,317 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+import QtQuick.Dialogs
+
+//! [0]
+Item {
+ id: playbackController
+
+ required property MediaPlayer mediaPlayer
+ required property MetadataInfo metadataInfo
+ required property TracksInfo audioTracksInfo
+ required property TracksInfo videoTracksInfo
+ required property TracksInfo subtitleTracksInfo
+ //! [0]
+
+ property alias muted: audioControl.muted
+ property alias volume: audioControl.volume
+
+ property bool landscapePlaybackControls: root.width >= 668
+ property bool busy: fileDialog.visible
+ || urlPopup.visible
+ || settingsPopup.visible
+ || audioControl.busy
+ || playbackSeekControl.busy
+
+ implicitHeight: landscapePlaybackControls ? 168 : 208
+
+ Behavior on opacity { NumberAnimation { duration: 300 } }
+
+ FileDialog {
+ id: fileDialog
+ title: "Please choose a file"
+ onAccepted: {
+ playbackController.mediaPlayer.stop()
+ playbackController.mediaPlayer.source = fileDialog.currentFile
+ playbackController.mediaPlayer.play()
+ }
+ }
+
+ UrlPopup {
+ id: urlPopup
+ anchors.centerIn: Overlay.overlay
+ mediaPlayer: playbackController.mediaPlayer
+ }
+
+ SettingsPopup {
+ id: settingsPopup
+ anchors.centerIn: Overlay.overlay
+
+ metadataInfo: playbackController.metadataInfo
+ mediaPlayer: playbackController.mediaPlayer
+ audioTracksInfo: playbackController.audioTracksInfo
+ videoTracksInfo: playbackController.videoTracksInfo
+ subtitleTracksInfo: playbackController.subtitleTracksInfo
+ }
+
+ component CustomButton: RoundButton {
+ implicitWidth: 40
+ implicitHeight: 40
+ radius: 4
+ icon.width: 24
+ icon.height: 24
+ flat: true
+ }
+
+ component CustomRoundButton: RoundButton {
+ property int diameter: 40
+ Layout.preferredWidth: diameter
+ Layout.preferredHeight: diameter
+ radius: diameter / 2
+ icon.width: 24
+ icon.height: 24
+ }
+
+ //! [1]
+ CustomButton {
+ id: fileDialogButton
+ icon.source: "../images/open_new.svg"
+ flat: false
+ onClicked: fileDialog.open()
+ }
+
+ CustomButton {
+ id: openUrlButton
+ icon.source: "../images/link.svg"
+ flat: false
+ onClicked: urlPopup.open()
+ }
+ //! [1]
+
+ CustomButton {
+ id: loopButton
+ icon.source: "../images/loop.svg"
+ icon.color: playbackController.mediaPlayer.loops === MediaPlayer.Once ? palette.buttonText : palette.accent
+ onClicked: playbackController.mediaPlayer.loops = playbackController.mediaPlayer.loops === MediaPlayer.Once
+ ? MediaPlayer.Infinite
+ : MediaPlayer.Once
+ }
+
+ CustomButton {
+ id: settingsButton
+ icon.source: "../images/more.svg"
+ onClicked: settingsPopup.open()
+ }
+
+ CustomButton {
+ id: fullScreenButton
+ icon.source: root.fullScreen ? "../images/zoom_minimize.svg"
+ : "../images/zoom_maximize.svg"
+ onClicked: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+
+ RowLayout {
+ id: controlButtons
+ spacing: 16
+
+ CustomRoundButton {
+ id: backward10Button
+ icon.source: "../images/backward10.svg"
+ onClicked: {
+ const pos = Math.max(0, playbackController.mediaPlayer.position - 10000)
+ playbackController.mediaPlayer.setPosition(pos)
+ }
+ }
+
+ //! [2]
+ CustomRoundButton {
+ id: playButton
+ visible: playbackController.mediaPlayer.playbackState !== MediaPlayer.PlayingState
+ icon.source: "../images/play_symbol.svg"
+ onClicked: playbackController.mediaPlayer.play()
+ }
+
+ CustomRoundButton {
+ id: pauseButton
+ visible: playbackController.mediaPlayer.playbackState === MediaPlayer.PlayingState
+ icon.source: "../images/pause_symbol.svg"
+ onClicked: playbackController.mediaPlayer.pause()
+ }
+ //! [2]
+
+ //! [3]
+ CustomRoundButton {
+ id: forward10Button
+ icon.source: "../images/forward10.svg"
+ onClicked: {
+ const pos = Math.min(playbackController.mediaPlayer.duration,
+ playbackController.mediaPlayer.position + 10000)
+ playbackController.mediaPlayer.setPosition(pos)
+ }
+ }
+ //! [3]
+ } // RowLayout controlButtons
+
+ AudioControl {
+ id: audioControl
+ showSlider: root.width >= 960
+ }
+
+ PlaybackSeekControl {
+ id: playbackSeekControl
+ Layout.fillWidth: true
+ mediaPlayer: playbackController.mediaPlayer
+ }
+
+ Frame {
+ id: landscapeLayout
+ anchors.fill: parent
+ padding: 32
+ topPadding: 28
+ visible: landscapePlaybackControls
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ spacing: 16
+
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ id: fdbProxy
+ target: fileDialogButton
+ anchors.left: parent.left
+ }
+
+ LayoutItemProxy {
+ target: openUrlButton
+ anchors.left: fdbProxy.right
+ anchors.leftMargin: 12
+ }
+
+ LayoutItemProxy {
+ target: controlButtons
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ LayoutItemProxy {
+ target: loopButton
+ anchors.right: acProxy.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: acProxy
+ target: audioControl
+ anchors.right: sbProxy.left
+ anchors.rightMargin: 30
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ LayoutItemProxy {
+ id: sbProxy
+ target: settingsButton
+ anchors.right: fbProxy.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: fbProxy
+ target: fullScreenButton
+ anchors.right: parent.right
+ }
+ } // Item
+
+ LayoutItemProxy {
+ target: playbackSeekControl
+ Layout.topMargin: 16
+ Layout.bottomMargin: 16
+ }
+ }
+ } // Frame frame
+
+ Frame {
+ id: portraitLayout
+ anchors.fill: parent
+ padding: 32
+ topPadding: 28
+ visible: !landscapePlaybackControls
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ spacing: 16
+
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ target: loopButton
+ anchors.right: cbProxy.left
+ anchors.rightMargin: 16
+ }
+
+ LayoutItemProxy {
+ id: cbProxy
+ target: controlButtons
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ LayoutItemProxy {
+ target: audioControl
+ anchors.left: cbProxy.right
+ anchors.leftMargin: 16
+ }
+ }
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ id: fdbProxy_
+ target: fileDialogButton
+ anchors.left: parent.left
+ }
+
+ LayoutItemProxy {
+ target: openUrlButton
+ anchors.left: fdbProxy_.right
+ anchors.leftMargin: 12
+ }
+
+ LayoutItemProxy {
+ target: settingsButton
+ anchors.right: fbProxy_.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: fbProxy_
+ target: fullScreenButton
+ anchors.right: parent.right
+ }
+ }
+
+ LayoutItemProxy {
+ target: playbackSeekControl
+ Layout.topMargin: 8
+ Layout.bottomMargin: 8
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml b/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml
new file mode 100644
index 000000000..c94d844f8
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml
@@ -0,0 +1,56 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+
+Item {
+ id: seekController
+ required property MediaPlayer mediaPlayer
+ property alias busy: slider.pressed
+
+ implicitHeight: 20
+
+ function formatToMinutes(milliseconds) {
+ const min = Math.floor(milliseconds / 60000)
+ const sec = ((milliseconds - min * 60000) / 1000).toFixed(1)
+ return `${min}:${sec.padStart(4, 0)}`
+ }
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 22
+
+ //! [0]
+ Text {
+ id: currentTime
+ Layout.preferredWidth: 45
+ text: seekController.formatToMinutes(seekController.mediaPlayer.position)
+ horizontalAlignment: Text.AlignLeft
+ font.pixelSize: 11
+ }
+ //! [0]
+
+ Slider {
+ id: slider
+ Layout.fillWidth: true
+ //! [2]
+ enabled: seekController.mediaPlayer.seekable
+ value: seekController.mediaPlayer.position / seekController.mediaPlayer.duration
+ //! [2]
+ onMoved: seekController.mediaPlayer.setPosition(value * seekController.mediaPlayer.duration)
+ }
+
+ //! [1]
+ Text {
+ id: remainingTime
+ Layout.preferredWidth: 45
+ text: seekController.formatToMinutes(seekController.mediaPlayer.duration - seekController.mediaPlayer.position)
+ horizontalAlignment: Text.AlignRight
+ font.pixelSize: 11
+ }
+ //! [1]
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml b/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml
new file mode 100644
index 000000000..0f24c8503
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml
@@ -0,0 +1,204 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+Popup {
+ id: settingsController
+ focus: true
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
+
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+
+ required property MetadataInfo metadataInfo
+ required property MediaPlayer mediaPlayer
+ required property TracksInfo audioTracksInfo
+ required property TracksInfo videoTracksInfo
+ required property TracksInfo subtitleTracksInfo
+
+ property int vPadding: 20
+ property int hPadding: 26
+ property bool landscapeSettingsPopup: root.width >= settingsLayout.width + metadataLayout.width + 2 * hPadding + 20 + 24
+
+ padding: {
+ top: vPadding
+ bottom: vPadding
+ left: hPadding
+ right: hPadding
+ }
+
+ Flickable {
+ id: flickable
+ implicitWidth: mainLayout.width
+ implicitHeight: landscapeSettingsPopup ? 200 : 340
+ contentWidth: mainLayout.width
+ contentHeight: mainLayout.height
+ flickableDirection: Flickable.VerticalFlick
+ clip: true
+
+ GridLayout {
+ id: mainLayout
+
+ columns: landscapeSettingsPopup ? 2 : 1
+ columnSpacing: 24
+ rowSpacing: 24
+
+ ColumnLayout {
+ id: settingsLayout
+ spacing: 16
+ Layout.alignment: Qt.AlignTop
+
+ Label {
+ id: settingsLabel
+ text: qsTr("Settings")
+ font.pixelSize: 16
+ font.bold: true
+ }
+
+ GridLayout {
+ id: gridLayout
+ columns: 2
+ rowSpacing: 16
+ columnSpacing: 16
+
+ component CustomComboBox: ComboBox {
+ required property TracksInfo tracksInfo
+
+ model: tracksInfo.model
+ enabled: model.count > 0
+ textRole: "data"
+ currentIndex: model.count > 0 ? 0 : -1
+
+ onActivated: {
+ //! [1]
+ settingsController.mediaPlayer.pause()
+ tracksInfo.selectedTrack = currentIndex
+ settingsController.mediaPlayer.play()
+ //! [1]
+ }
+ }
+
+ Label {
+ text: qsTr("Playback Speed")
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ ComboBox {
+ id: rateCb
+ model: ["0.25", "0.5", "0.75", "Normal", "1.25", "1.5", "1.75", "2"]
+ currentIndex: 3
+
+ onCurrentIndexChanged: {
+ //! [0]
+ settingsController.mediaPlayer.playbackRate = (currentIndex + 1) * 0.25
+ //! [0]
+ }
+ }
+
+ Label {
+ text: qsTr("Audio Tracks")
+ enabled: audioCb.enabled
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: audioCb
+ tracksInfo: settingsController.audioTracksInfo
+
+ }
+
+ Label {
+ text: qsTr("Video Tracks")
+ enabled: videoCb.enabled
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: videoCb
+ tracksInfo: settingsController.videoTracksInfo
+ }
+
+ Label {
+ text: qsTr("Subtitle Tracks")
+ enabled: subtitlesCb.enabled
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: subtitlesCb
+ tracksInfo: settingsController.subtitleTracksInfo
+ }
+ }
+ }
+
+ ColumnLayout {
+ id: metadataLayout
+ spacing: 16
+ Layout.alignment: Qt.AlignTop
+
+ Label {
+ id: metadataLabel
+ text: qsTr("Metadata")
+ font.pixelSize: 16
+ font.bold: true
+ }
+
+ Rectangle {
+ id: metadataRect
+ implicitWidth: 240
+ implicitHeight: metadataList.height
+ border.color: "#8E8E93"
+ radius: 6
+
+ Column {
+ id: metadataList
+ visible: settingsController.metadataInfo.count > 0
+
+ padding: 10
+ Repeater {
+ Row {
+ spacing: metadataList.padding
+ Text {
+ text: model.name
+ font.bold: true
+ width: (metadataRect.width - 3 * metadataList.padding) / 2
+ horizontalAlignment: Text.AlignRight
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ }
+
+ Text {
+ text: model.value
+ width: (metadataRect.width - 3 * metadataList.padding) / 2
+ horizontalAlignment: Text.AlignLeft
+ anchors.verticalCenter: parent.verticalCenter
+ wrapMode: Text.WrapAnywhere
+ font.pixelSize: 12
+ }
+ }
+ model: settingsController.metadataInfo.metadata
+ }
+ }
+
+ Text {
+ id: metadataNoList
+ visible: settingsController.metadataInfo.count === 0
+ anchors.centerIn: parent
+ text: qsTr("No metadata present")
+ font.pixelSize: 14
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml b/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml
new file mode 100644
index 000000000..a2ae96f02
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml
@@ -0,0 +1,25 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ property alias model: model
+ property int selectedTrack: 0
+
+ function read(tracks, key = 0) {
+ // language is the 6th index in the enum QMediaMetaData::Key
+ model.clear()
+
+ if (!tracks)
+ return
+
+ tracks.forEach((metadata, index) => {
+ const data = metadata.stringValue(key)
+ const label = data ? data : qsTr("track ") + (index + 1)
+ model.append({data: label, index: index})
+ })
+ }
+
+ ListModel { id: model }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml b/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml
new file mode 100644
index 000000000..5bc304178
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml
@@ -0,0 +1,54 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+
+Popup {
+ id: popupController
+ width: Math.min(500, root.width - 40)
+
+ required property MediaPlayer mediaPlayer
+
+ function loadUrl(url) {
+ popupController.mediaPlayer.stop()
+ popupController.mediaPlayer.source = url
+ popupController.mediaPlayer.play()
+ }
+
+ RowLayout {
+ id: rowOpenUrl
+ anchors.fill: parent
+ Label {
+ text: qsTr("URL:");
+ }
+
+ TextField {
+ id: urlText
+ Layout.fillWidth: true
+ focus: true
+
+ placeholderText: qsTr("Enter text here...")
+ wrapMode: TextInput.WrapAnywhere
+
+ Keys.onReturnPressed: {
+ popupController.loadUrl(text)
+ urlText.text = ""
+ popupController.close()
+ }
+ }
+
+ Button {
+ text: qsTr("Load")
+ enabled: urlText.text !== ""
+ onClicked: {
+ popupController.loadUrl(urlText.text)
+ urlText.text = ""
+ popupController.close()
+ }
+ }
+ }
+ onOpened: { popupController.forceActiveFocus() }
+}
diff --git a/examples/multimedia/video/mediaplayer/doc/images/OqosZsDqvzQ.jpg b/examples/multimedia/video/mediaplayer/doc/images/OqosZsDqvzQ.jpg
deleted file mode 100644
index a53e85803..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/OqosZsDqvzQ.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/PlayerMenuBar.gif b/examples/multimedia/video/mediaplayer/doc/images/PlayerMenuBar.gif
deleted file mode 100644
index 779713332..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/PlayerMenuBar.gif
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/architecture-overview.gif b/examples/multimedia/video/mediaplayer/doc/images/architecture-overview.gif
deleted file mode 100644
index b85ce61c5..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/architecture-overview.gif
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/audio-control.gif b/examples/multimedia/video/mediaplayer/doc/images/audio-control.gif
deleted file mode 100644
index 5ac07ccc2..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/audio-control.gif
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png b/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png
new file mode 100644
index 000000000..857e70abd
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/meta-data.png b/examples/multimedia/video/mediaplayer/doc/images/meta-data.png
deleted file mode 100644
index a96b8f7e1..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/meta-data.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/nHrBbW0H-pc.jpg b/examples/multimedia/video/mediaplayer/doc/images/nHrBbW0H-pc.jpg
deleted file mode 100644
index 2d530a46d..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/nHrBbW0H-pc.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/play-pause-stop.gif b/examples/multimedia/video/mediaplayer/doc/images/play-pause-stop.gif
deleted file mode 100644
index 355f7af86..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/play-pause-stop.gif
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/playbackControlPanel.gif b/examples/multimedia/video/mediaplayer/doc/images/playbackControlPanel.gif
deleted file mode 100644
index c71e577d7..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/playbackControlPanel.gif
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/qmlmediaplayer.jpg b/examples/multimedia/video/mediaplayer/doc/images/qmlmediaplayer.jpg
deleted file mode 100644
index 94e9c04a0..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/qmlmediaplayer.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/settings.png b/examples/multimedia/video/mediaplayer/doc/images/settings.png
new file mode 100644
index 000000000..5cf175795
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/doc/images/settings.png
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/sf_yv01UtIw.jpg b/examples/multimedia/video/mediaplayer/doc/images/sf_yv01UtIw.jpg
deleted file mode 100644
index ab7342d5d..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/sf_yv01UtIw.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/url.png b/examples/multimedia/video/mediaplayer/doc/images/url.png
deleted file mode 100644
index 7bd4ff9f4..000000000
--- a/examples/multimedia/video/mediaplayer/doc/images/url.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/qmlmediaplayer.qdocconf b/examples/multimedia/video/mediaplayer/doc/qmlmediaplayer.qdocconf
deleted file mode 100644
index bb1eab7da..000000000
--- a/examples/multimedia/video/mediaplayer/doc/qmlmediaplayer.qdocconf
+++ /dev/null
@@ -1,7 +0,0 @@
-HTML.extraimages += images/OqosZsDqvzQ.jpg \
- images/sf_yv01UtIw.jpg \
- images/nHrBbW0H-pc.jpg
-
-qhp.QtMultimedia.extraFiles += images/OqosZsDqvzQ.jpg \
- images/sf_yv01UtIw.jpg \
- images/nHrBbW0H-pc.jpg
diff --git a/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc b/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc
index 56cf91596..1cc681f8f 100644
--- a/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc
+++ b/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc
@@ -1,204 +1,151 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/video/mediaplayer
+ \example video/mediaplayer
\title QML Media Player Example
\ingroup multimedia_examples
\ingroup video_examples_qml
- \brief Playing audio and video using Qt Quick.
+ \examplecategory {Graphics & Multimedia}
+ \brief Playing audio and video using the QML \c MediaPlayer type.
\meta {tag} {quick}
\meta {tag} {player}
- \image qmlmediaplayer.jpg
+ \image mediaplayer.png
This example demonstrates a simple multimedia player that can play
audio and video files using various codecs.
\include examples-run.qdocinc
- \section1 Overview
- At its core this is a QML application, see
- \l{Getting Started Programming with Qt Quick} for information specific to
- that. This documentation is focused on how this example utilizes the
- \l{Qt Multimedia QML types}.
-
- \image architecture-overview.gif
-
- \section1 Using MediaPlayer and VideoOutput
- In \c main.qml a MediaPlayer instance is connected to a VideoOutput to
- play back the video:
-
- \quotefromfile multimedia/video/mediaplayer/main.qml
- \skipto MediaPlayer
- \printuntil videoOutput: videoOutput
-
- \c videoOutput is declared like so:
-
- \skipto VideoOutput {
- \printto MetadataInfo {
-
- \section1 PlayerMenuBar
- \image PlayerMenuBar.gif
- This QML type handles media selection from a url or local file, exiting the
- application, viewing meta data, and the selection of available video, audio
- or subtitle tracks.
-
- \quotefromfile multimedia/video/mediaplayer/PlayerMenuBar.qml
- Accessing the mediaPlayer object is done through properties:
- \skipto required property
- \printuntil TracksInfo subtitleTracksInfo
-
- \section2 fileDialog
- A FileDialog, \c fileDialog, is created with an \c onAccepted function that
- will stop \c mediaPlayer, load the source by setting the
- \l{MediaPlayer::source}{source} property and then play it automatically:
- \skipto FileDialog
- \printto MenuBar
-
- This is triggered in the Menu \c File, which is a child of the MenuBar:
- \skipto MenuBar
- \printto }
-
- \section2 loadUrl
- \image url.png
- While \c urlPopup handles prompting and capturing a url, it is the \c loadUrl
- function that interacts with \c mediaPlayer like so:
- \quotefromfile multimedia/video/mediaplayer/PlayerMenuBar.qml
- \skipto function loadUrl
- \printto function closeOverlays(){
-
- \section2 Getting meta data
- \image meta-data.png
-
- In the declaration of \c mediaPlayer, in \c main.qml, there is the function
- \c updateMetadata():
-
- \quotefromfile multimedia/video/mediaplayer/main.qml
- \skipto function updateMetadata(
- \printto }
-
- It is called in the following places:
- \skipto onMetaDataChanged:
- \printto onActiveTracksChanged: { updateMetadata() }
-
- Reading MetaData is done by the \c MetadataInfo type's \c read() function
- \quotefromfile multimedia/video/mediaplayer/MetadataInfo.qml
- \skipto function read(metadata) {
- \printto ListModel
-
- The information is displayed via an \l[QML]{Overlay} item.
-
- \section2 Tracks information and control
- \youtube OqosZsDqvzQ
- This is defined in \c TracksInfo.qml and reading available tracks is done in
- a similar way to \c MetadataInfo:
- \quotefromfile multimedia/video/mediaplayer/TracksInfo.qml
- \skipto function read(metadata
- \printto ListModel
-
- To set a track, the property \c selectedTrack is set like so:
- \skipto ListView
- \printto Text
-
- The \c onSelectectedTrackChanged signal, in each relevant \c TracksInfo
- instance in \c main.qml, is what makes changes to \c mediaPlayer like so:
- \quotefromfile multimedia/video/mediaplayer/main.qml
- \skipto id: audioTracksInfo
- \printuntil audioTracksInfo.selectedTrack
-
- \section1 playbackControlPanel
- \image playbackControlPanel.gif
-
- This item has controls for \l{Playback control}, \l{Play Pause Stop},
- \l{Playback rate control} and \l{Playback seek control}.
-
- \section2 Playback control
- This qml type handles media playback and interacts with the MediaPlayer in
- \c main.qml.
-
- Here are the property definitions.
- \quotefromfile multimedia/video/mediaplayer/PlaybackControl.qml
- \skipto required property
- \printto property alias
-
- Connections:
- \skipuntil Connections
- \printto HoverHandler
-
- \section2 Play Pause Stop
- \image play-pause-stop.gif
- \l{MediaPlayer::play()}{Play}, \l{MediaPlayer::stop()}{stop} and
- \l{MediaPlayer::pause()}{pause} interactions with the MediaPlayer object
- are done like so:
- \skipto RoundButton
- \printto Item {
-
- Playback states done using \l{MediaPlayer::playbackState}{playbackstate}
- like so:
- \skipuntil states:
- \printuntil ]
-
-
- \section2 Playback seek control
-
- \youtube sf_yv01UtIw
-
- Defined in \c PlaybackSeekControl.qml, this component comprises of an item
- with a Text, \c mediaTime, and \l[QML]{Slider}, \c mediaSlider, in a RowLayout.
-
- \c mediaTime uses MediaPlayer's \l{MediaPlayer::position}{position} property
- like so:
- \quotefromfile multimedia/video/mediaplayer/PlaybackSeekControl.qml
- \skipto Text {
- \printto Slider
-
- \c mediaSlider uses the MediaPlayer \l{MediaPlayer::seekable}{seekable},
- \l{MediaPlayer::duration}{duration}, and \l{MediaPlayer::position}{position}
- properties like so:
- \skipto Slider
- \printuntil }
-
- \section2 Playback rate control
- \youtube nHrBbW0H-pc
-
- This type is defined in \c PlaybackRateControl.qml like so:
-
- \quotefromfile multimedia/video/mediaplayer/PlaybackRateControl.qml
- \skipto Slider
- \printuntil text:
+ \section1 Instantiating the MediaPlayer
+ The entry point for the QML code in this example is \c Main.qml. Here
+ an \c ApplicationWindow is created and properties such as the \c id, \c title,
+ \c width and \c height are set.
- \section2 Audio control
- \image audio-control.gif
- This type is defined in \c AudioControl.qml, and utilizes the
- \l{AudioOutput::muted}{muted} and \l{AudioOutput::volume}{volume} properties
- of the AudioOutput instantiated within the MediaPlayer, which is
- instantiated in \c{main.qml}.
-
- \quotefromfile multimedia/video/mediaplayer/AudioControl.qml
- \skipto required
- \printuntil value: 100.0
+ \snippet video/mediaplayer/Main.qml 0
+
+ Next the \c MediaPlayer is created and the two properties that are responsible for the video and
+ audio output are defined.
+ Firstly, \c videoOutput which renders the video viewfinder and secondly \c audioOutput which provides
+ the audio output for the player.
+
+ \snippet video/mediaplayer/Main.qml 1
+ \dots
+ \snippet video/mediaplayer/Main.qml 2
+ \dots
+ \snippet video/mediaplayer/Main.qml 3
+
+ The \c visible property of the \c VideoOutput type is set to \c true when the \c mediaStatus
+ property of the \c MediaPlayer is greater than 0. \c mediaStatus is of enumeration type
+ and is equal to 0 when \e {No media has been set}, and greater than 0 otherwise. Therefore,
+ the \c VideoOutput is visible when media has been set.
+
+ The \c MediaPlayer type has a signal property called \c onErrorOccurred that can be
+ overridden specifically to handle errors. In this case the signal opens a \c MessageDialog using
+ the method \c {open()} and sets its \c text property to a \c MediaPlayer property called
+ \c errorString.
+
+ \snippet video/mediaplayer/Main.qml 4
+
+ \section1 Playback Controls
+
+ In order to have a useable media player, there needs to be an interface to control the playback.
+ This is created in its own component file, \c PlaybackControl.qml, and instantiated in
+ \c Main.qml.
+
+ \snippet video/mediaplayer/Main.qml 5
+ \dots
+ \snippet video/mediaplayer/Main.qml 6
+
+ When created, objects are forwarded to this type such as track information,
+ metadata information and the \c MediaPlayer object itself. In \c PlaybackControl.qml,
+ each one of these objects have a \c {required property}, meaning that these properties must
+ be set when the \c PlaybackControl object is created.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 0
+
+ These playback controls can be broken down into sections. In the top left of the panel lies
+ a collection of buttons used to open a file, either by selecting a file from a file explorer or
+ entering a URL. The file is loaded into the \c MediaPlayer by setting the \c source property.
+ Both buttons are instantiated using a \c CustomButton \c {custom component}.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 1
+
+ Three buttons are created and centered on this panel, handling play, pause and seeking ten
+ seconds backwards or forwards. The media is played and paused using the methods \c {play()}
+ and \c {pause()}, respectively. To know when to draw a play or pause button, the \c playbackState
+ property is queried. For example, when it is equal to the enum value \c MediaPlayer.PlayingState
+ then the pause button is drawn.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 2
+
+ To navigate ten seconds forward or backwards, the \c position of the \c MediaPlayer type is
+ incremented by 10,000 milliseconds and set using the method \c {setPosition()}.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 3
+
+ \section1 Playback Seeking and Audio
+
+ In \c {PlaybackControl.qml}, an \c AudioControl and a \c PlaybackSeekControl type are instantiated.
+ These are both defined in their own component file and are responsible for volume control and
+ playback seeking, respectively. The \c AudioControl type defines a button to mute and a \c Slider,
+ from \c {QtQuick Controls}, to set the volume of the player. Both of these attributes are exposed by
+ defining a \c mute and \c volume property and are accessed from the \c AudioOutput definition in
+ \c {Main.qml}.
+
+ \snippet video/mediaplayer/controls/AudioControl.qml 0
+
+ The \c PlaybackSeekControl uses a \c RowLayout containing a \c Slider with a \c Text item either side.
+ The two \c Text items display the current time and the remaining time of the media being played. These
+ are both calculated using two properties of the \c MediaPlayer type, \c {position}, which gives the
+ current playback position in milliseconds, and \c {duration}, which gives the duration of the media
+ in milliseconds.
+
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 0
+ \dots
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 1
+
+ The \c Slider is only enabled when the media player is seekable and not, for example, live media.
+ The \c MediaPlayer type has a property for this called \c seekable. The \c value of the \c Slider
+ is calculated using the \c position and \c duration properties of the \c MediaPlayer.
+
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 2
+
+ \section1 Metadata and Track Information
+
+ The \c PlaybackControl type instantiates a \c SettingsPopup, which contains information about the
+ metadata of the currently loaded media and track selection, as well as the ability to update the
+ playback rate. This \c Popup is defined in \c SettingsPopup.qml.
+
+ \image settings.png
+
+ The metadata is contained in its own component file, \c MetadataInfo.qml. It contains a \c ListModel,
+ a function to clear it, \c {clear()}, and a function to populate it, \c {read(MediaMetadata metadata)}.
+ The \c {read(MediaMetadata metadata)} function takes as a parameter an object of type \c MediaMetaData,
+ and navigates its key-value structure to extract its data into the \c model of the \c {ListView}. The
+ methods used to do this are \c {keys()}, which returns all the keys of the \c MediaMetaData, and
+ {stringValue(Key key)}, which returns the \c value for a given \c key.
+
+ \snippet video/mediaplayer/controls/MetadataInfo.qml 0
+
+ The data is then displayed in \c {SettingsPopup.qml} in a \c ListView type. The \c delegate of this
+ \c ListView is a row of two \c Text items, corresponding to the key-value pairs abstracted from the
+ \c MediaMetaData item.
+
+ On the other side of the \c Popup there is playback rate controls and track selection for audio, video and
+ subtitles. The playback rate is chosen from a \c ComboBox and set using the property \c playbackRate.
+
+ \snippet video/mediaplayer/controls/SettingsPopup.qml 0
+
+ The type called \c TracksInfo, defined in \c {TracksInfo.qml}, contains the data about the tracks.
+ More specifically, a \c ListModel containing the titles of the tracks, or for subtitles specifically, the
+ langauges. This information is populated in \c Main.qml by calling the \c {read(MediaMetadata mediaMetadata)}
+ function defined in the \c TracksInfo type.
+
+ \snippet video/mediaplayer/Main.qml 6
+
+ The \c model defined in \c TracksInfo is then queried in the \c {ComboBox}es in the
+ \c SettingsPopup to select the current track.
+
+ \snippet video/mediaplayer/controls/SettingsPopup.qml 1
*/
diff --git a/examples/multimedia/video/mediaplayer/images/backward10.svg b/examples/multimedia/video/mediaplayer/images/backward10.svg
new file mode 100644
index 000000000..9166343bd
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/backward10.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M4 13.2001C4 14.7428 4.46919 16.2508 5.34824 17.5335C6.22729 18.8162 7.47672 19.816 8.93853 20.4063C10.4003 20.9967 12.0089 21.1511 13.5607 20.8502C15.1126 20.5492 16.538 19.8063 17.6569 18.7155C18.7757 17.6247 19.5376 16.2348 19.8463 14.7218C20.155 13.2088 19.9965 11.6404 19.391 10.2152C18.7855 8.78993 17.7602 7.57175 16.4446 6.71468C15.129 5.85761 13.5822 5.40015 12 5.40015" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M12.6152 3L10.1537 5.39999L12.6152 7.79997" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M9.16406 16V11.4766H9.09375L7.71094 12.4375V11.375L9.16797 10.3633H10.3438V16H9.16406ZM14.0469 16.1445C13.5833 16.1445 13.1836 16.0247 12.8477 15.7852C12.5143 15.543 12.2578 15.2005 12.0781 14.7578C11.8984 14.3151 11.8086 13.7904 11.8086 13.1836V13.1758C11.8086 12.5664 11.8984 12.0417 12.0781 11.6016C12.2578 11.1589 12.5143 10.8177 12.8477 10.5781C13.1836 10.3385 13.5833 10.2188 14.0469 10.2188C14.513 10.2188 14.9128 10.3385 15.2461 10.5781C15.5794 10.8177 15.8359 11.1589 16.0156 11.6016C16.1953 12.0417 16.2852 12.5664 16.2852 13.1758V13.1836C16.2852 13.7904 16.1953 14.3151 16.0156 14.7578C15.8359 15.2005 15.5794 15.543 15.2461 15.7852C14.9128 16.0247 14.513 16.1445 14.0469 16.1445ZM14.0469 15.2109C14.2708 15.2109 14.4596 15.1302 14.6133 14.9688C14.7695 14.8073 14.888 14.5755 14.9688 14.2734C15.0521 13.9714 15.0938 13.6081 15.0938 13.1836V13.1758C15.0938 12.7487 15.0521 12.3854 14.9688 12.0859C14.888 11.7839 14.7695 11.5534 14.6133 11.3945C14.4596 11.2331 14.2708 11.1523 14.0469 11.1523C13.8255 11.1523 13.6367 11.2331 13.4805 11.3945C13.3268 11.5534 13.2083 11.7839 13.125 12.0859C13.0443 12.3854 13.0039 12.7487 13.0039 13.1758V13.1836C13.0039 13.6081 13.0443 13.9714 13.125 14.2734C13.2083 14.5755 13.3268 14.8073 13.4805 14.9688C13.6367 15.1302 13.8255 15.2109 14.0469 15.2109Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/ff.svg b/examples/multimedia/video/mediaplayer/images/ff.svg
new file mode 100644
index 000000000..7c907c4fa
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/ff.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M5.19465 16.8817C5.5198 17.0557 5.91435 17.0366 6.2212 16.832L12.2212 12.832C12.4994 12.6466 12.6665 12.3344 12.6665 12C12.6665 11.6656 12.4994 11.3534 12.2212 11.1679L6.2212 7.16795C5.91435 6.96338 5.5198 6.9443 5.19465 7.11832C4.86949 7.29234 4.6665 7.6312 4.6665 8V16C4.6665 16.3688 4.86949 16.7077 5.19465 16.8817ZM6.6665 14.1315V9.86852L9.86373 12L6.6665 14.1315Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M13.1946 16.8817C13.5198 17.0557 13.9143 17.0366 14.2212 16.832L20.2212 12.832C20.4994 12.6466 20.6665 12.3344 20.6665 12C20.6665 11.6656 20.4994 11.3534 20.2212 11.1679L14.2212 7.16795C13.9143 6.96338 13.5198 6.9443 13.1946 7.11832C12.8695 7.29234 12.6665 7.6312 12.6665 8V16C12.6665 16.3688 12.8695 16.7077 13.1946 16.8817ZM14.6665 14.1315V9.86852L17.8637 12L14.6665 14.1315Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/forward10.svg b/examples/multimedia/video/mediaplayer/images/forward10.svg
new file mode 100644
index 000000000..190a5aaab
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/forward10.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M20 13.2001C20 14.7428 19.5308 16.2508 18.6518 17.5335C17.7727 18.8162 16.5233 19.816 15.0615 20.4063C13.5997 20.9967 11.9911 21.1511 10.4393 20.8502C8.88743 20.5492 7.46197 19.8063 6.34315 18.7155C5.22433 17.6247 4.4624 16.2348 4.15372 14.7218C3.84504 13.2088 4.00347 11.6404 4.60897 10.2152C5.21447 8.78993 6.23985 7.57175 7.55544 6.71468C8.87103 5.85761 10.4178 5.40015 12 5.40015" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M11.3838 3L13.8453 5.39999L11.3838 7.79997" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M9.16406 16V11.4766H9.09375L7.71094 12.4375V11.375L9.16797 10.3633H10.3438V16H9.16406ZM14.0469 16.1445C13.5833 16.1445 13.1836 16.0247 12.8477 15.7852C12.5143 15.543 12.2578 15.2005 12.0781 14.7578C11.8984 14.3151 11.8086 13.7904 11.8086 13.1836V13.1758C11.8086 12.5664 11.8984 12.0417 12.0781 11.6016C12.2578 11.1589 12.5143 10.8177 12.8477 10.5781C13.1836 10.3385 13.5833 10.2188 14.0469 10.2188C14.513 10.2188 14.9128 10.3385 15.2461 10.5781C15.5794 10.8177 15.8359 11.1589 16.0156 11.6016C16.1953 12.0417 16.2852 12.5664 16.2852 13.1758V13.1836C16.2852 13.7904 16.1953 14.3151 16.0156 14.7578C15.8359 15.2005 15.5794 15.543 15.2461 15.7852C14.9128 16.0247 14.513 16.1445 14.0469 16.1445ZM14.0469 15.2109C14.2708 15.2109 14.4596 15.1302 14.6133 14.9688C14.7695 14.8073 14.888 14.5755 14.9688 14.2734C15.0521 13.9714 15.0938 13.6081 15.0938 13.1836V13.1758C15.0938 12.7487 15.0521 12.3854 14.9688 12.0859C14.888 11.7839 14.7695 11.5534 14.6133 11.3945C14.4596 11.2331 14.2708 11.1523 14.0469 11.1523C13.8255 11.1523 13.6367 11.2331 13.4805 11.3945C13.3268 11.5534 13.2083 11.7839 13.125 12.0859C13.0443 12.3854 13.0039 12.7487 13.0039 13.1758V13.1836C13.0039 13.6081 13.0443 13.9714 13.125 14.2734C13.2083 14.5755 13.3268 14.8073 13.4805 14.9688C13.6367 15.1302 13.8255 15.2109 14.0469 15.2109Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/link.svg b/examples/multimedia/video/mediaplayer/images/link.svg
new file mode 100644
index 000000000..6ce1b983d
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/link.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M11 16C11 16.5523 10.5523 17 10 17H7C5.61667 17 4.4375 16.5125 3.4625 15.5375C2.4875 14.5625 2 13.3833 2 12C2 10.6167 2.4875 9.4375 3.4625 8.4625C4.4375 7.4875 5.61667 7 7 7H10C10.5523 7 11 7.44772 11 8C11 8.55228 10.5523 9 10 9H7C6.16667 9 5.45833 9.29167 4.875 9.875C4.29167 10.4583 4 11.1667 4 12C4 12.8333 4.29167 13.5417 4.875 14.125C5.45833 14.7083 6.16667 15 7 15H10C10.5523 15 11 15.4477 11 16ZM9 13C8.44772 13 8 12.5523 8 12C8 11.4477 8.44772 11 9 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H9ZM14 17C13.4477 17 13 16.5523 13 16C13 15.4477 13.4477 15 14 15H17C17.8333 15 18.5417 14.7083 19.125 14.125C19.7083 13.5417 20 12.8333 20 12C20 11.1667 19.7083 10.4583 19.125 9.875C18.5417 9.29167 17.8333 9 17 9H14C13.4477 9 13 8.55228 13 8C13 7.44772 13.4477 7 14 7H17C18.3833 7 19.5625 7.4875 20.5375 8.4625C21.5125 9.4375 22 10.6167 22 12C22 13.3833 21.5125 14.5625 20.5375 15.5375C19.5625 16.5125 18.3833 17 17 17H14Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/loop.svg b/examples/multimedia/video/mediaplayer/images/loop.svg
new file mode 100644
index 000000000..8161ca867
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/loop.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 17.5C5 17.5 7 17.5 5 17.5C3 17.5 3 17.5 3 15.5C3 13.5 3 8 3 6C3 4 3 4 5 4C7 4 17 4 19 4C21 4 21 4 21 6C21 8 21 13.5 21 15.5C21 17.5 21 17.5 19 17.5C17 17.5 11 17.5 11 17.5M11 17.5L13 15M11 17.5L13 20" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/more.svg b/examples/multimedia/video/mediaplayer/images/more.svg
new file mode 100644
index 000000000..fa8bddec8
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/more.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z" fill="black"/>
+<path d="M22 12C22 13.1046 21.1046 14 20 14C18.8954 14 18 13.1046 18 12C18 10.8954 18.8954 10 20 10C21.1046 10 22 10.8954 22 12Z" fill="black"/>
+<path d="M6 12C6 13.1046 5.10457 14 4 14C2.89543 14 2 13.1046 2 12C2 10.8954 2.89543 10 4 10C5.10457 10 6 10.8954 6 12Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/Mute_Icon.svg b/examples/multimedia/video/mediaplayer/images/mute.svg
index b66b6d311..b66b6d311 100644
--- a/examples/multimedia/video/mediaplayer/Mute_Icon.svg
+++ b/examples/multimedia/video/mediaplayer/images/mute.svg
diff --git a/examples/multimedia/video/mediaplayer/images/open_new.svg b/examples/multimedia/video/mediaplayer/images/open_new.svg
new file mode 100644
index 000000000..6c62237f1
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/open_new.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="File /open_new">
+<path id="Layer01" d="M2 5C2 3.34315 3.34315 2 5 2H11C11.5523 2 12 2.44772 12 3C12 3.55228 11.5523 4 11 4H5C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V13.125C20 12.5727 20.4477 12.125 21 12.125C21.5523 12.125 22 12.5727 22 13.125V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M15 4C14.4477 4 14 3.55228 14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L8.76961 16.6446C8.37908 17.0351 7.74592 17.0351 7.35539 16.6446C6.96487 16.2541 6.96487 15.6209 7.35539 15.2304L18.5858 4H15Z" fill="#0D0D0D"/>
+</g>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/pause_symbol.svg b/examples/multimedia/video/mediaplayer/images/pause_symbol.svg
new file mode 100644
index 000000000..bdf6a9047
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/pause_symbol.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.3335 7C8.3335 6.44772 8.66928 6 9.0835 6H10.5835C10.9977 6 11.3335 6.44772 11.3335 7V17C11.3335 17.5523 10.9977 18 10.5835 18H9.0835C8.66928 18 8.3335 17.5523 8.3335 17V7Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M13.3335 7C13.3335 6.44772 13.6693 6 14.0835 6H15.5835C15.9977 6 16.3335 6.44772 16.3335 7V17C16.3335 17.5523 15.9977 18 15.5835 18H14.0835C13.6693 18 13.3335 17.5523 13.3335 17V7Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/play_symbol.svg b/examples/multimedia/video/mediaplayer/images/play_symbol.svg
new file mode 100644
index 000000000..edb567226
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/play_symbol.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M16.8182 12L6.89091 6.14985L6.89091 17.8501L16.8182 12ZM18.2 13.4143C19.2667 12.7857 19.2667 11.2143 18.2 10.5857L7.4 4.22123C6.33333 3.59264 5 4.37838 5 5.63555L5 18.3644C5 19.6216 6.33333 20.4074 7.4 19.7788L18.2 13.4143Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/rewind.svg b/examples/multimedia/video/mediaplayer/images/rewind.svg
new file mode 100644
index 000000000..e9b34122c
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/rewind.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.4719 16.8817C19.1467 17.0557 18.7522 17.0366 18.4453 16.832L12.4453 12.832C12.1671 12.6466 12 12.3344 12 12C12 11.6656 12.1671 11.3534 12.4453 11.1679L18.4453 7.16795C18.7522 6.96338 19.1467 6.9443 19.4719 7.11832C19.797 7.29234 20 7.6312 20 8V16C20 16.3688 19.797 16.7077 19.4719 16.8817ZM18 14.1315V9.86852L14.8028 12L18 14.1315Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.4719 16.8817C11.1467 17.0557 10.7522 17.0366 10.4453 16.832L4.4453 12.832C4.1671 12.6466 4 12.3344 4 12C4 11.6656 4.1671 11.3534 4.4453 11.1679L10.4453 7.16795C10.7522 6.96338 11.1467 6.9443 11.4719 7.11832C11.797 7.29234 12 7.6312 12 8V16C12 16.3688 11.797 16.7077 11.4719 16.8817ZM10 14.1315V9.86852L6.80278 12L10 14.1315Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/settings.svg b/examples/multimedia/video/mediaplayer/images/settings.svg
new file mode 100644
index 000000000..3a13ccae1
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/settings.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.84998 4C8.84998 2.89543 9.74541 2 10.85 2H13.1222C14.2268 2 15.1222 2.89543 15.1222 4V4.59509C15.1229 4.59732 15.125 4.6023 15.1306 4.61031C15.1434 4.62838 15.1691 4.65242 15.2077 4.66935C15.852 4.95163 16.4515 5.31609 16.9931 5.74921C17.0261 5.77554 17.0594 5.787 17.0815 5.78982C17.0912 5.79106 17.0966 5.79055 17.0989 5.79008L17.9363 5.33741C18.8691 4.8332 20.0332 5.14455 20.5897 6.04706L21.6744 7.80604C22.2777 8.78435 21.9342 10.0686 20.9231 10.6152L19.9875 11.1209C19.9859 11.1226 19.9824 11.1269 19.9781 11.1358C19.9683 11.156 19.9595 11.1904 19.9636 11.2327C19.9877 11.4855 20 11.7414 20 12C20 12.2586 19.9877 12.5145 19.9636 12.7673C19.9595 12.8096 19.9683 12.844 19.9781 12.8642C19.9824 12.8732 19.9859 12.8774 19.9875 12.8791L20.923 13.3848C21.9341 13.9314 22.2776 15.2157 21.6743 16.194L20.5897 17.9529C20.0331 18.8554 18.869 19.1668 17.9362 18.6626L17.0989 18.2099C17.0966 18.2095 17.0912 18.209 17.0815 18.2102C17.0594 18.213 17.026 18.2245 16.9931 18.2508C16.4515 18.6839 15.852 19.0484 15.2077 19.3306C15.1691 19.3476 15.1434 19.3716 15.1306 19.3897C15.125 19.3977 15.1229 19.4027 15.1222 19.4049V20C15.1222 21.1046 14.2268 22 13.1222 22H10.85C9.74541 22 8.84998 21.1046 8.84998 20V19.3928C8.84931 19.3906 8.84725 19.3857 8.84163 19.3777C8.82894 19.3597 8.80351 19.3357 8.76508 19.3187C8.12675 19.0362 7.53272 18.6729 6.99586 18.242C6.96292 18.2156 6.92951 18.2041 6.90737 18.2012C6.89759 18.2 6.8922 18.2005 6.8899 18.201L6.03592 18.6626C5.10317 19.1668 3.93904 18.8554 3.38251 17.9529L2.29784 16.194C1.69457 15.2156 2.03805 13.9314 3.04914 13.3848L4.01099 12.8649C4.01265 12.8632 4.01607 12.859 4.02042 12.85C4.03023 12.8299 4.03897 12.7956 4.03503 12.7534C4.0118 12.5051 3.99995 12.2538 3.99995 12C3.99995 11.7462 4.0118 11.4949 4.03503 11.2466C4.03897 11.2045 4.03022 11.1701 4.02042 11.15C4.01607 11.1411 4.01265 11.1368 4.01098 11.1352L3.04909 10.6152C2.038 10.0686 1.69452 8.78435 2.29779 7.80604L3.38245 6.04707C3.93898 5.14456 5.10312 4.83322 6.03587 5.33742L6.88988 5.79907C6.89218 5.79953 6.89757 5.80005 6.90735 5.79879C6.92949 5.79594 6.9629 5.78441 6.99584 5.75797C7.53271 5.32709 8.12674 4.96379 8.76508 4.68128C8.80351 4.66427 8.82894 4.64029 8.84163 4.62231C8.84725 4.61434 8.84931 4.60938 8.84998 4.60716V4ZM8.85024 4.60578C8.85029 4.60578 8.85026 4.60619 8.85001 4.60703L8.85024 4.60578ZM6.88852 5.79864C6.88854 5.7986 6.88898 5.79869 6.88977 5.79904L6.88852 5.79864ZM4.00988 11.1343C4.00991 11.1342 4.01026 11.1344 4.0109 11.1351L4.00988 11.1343ZM4.00989 12.8658C4.00988 12.8657 4.01021 12.8654 4.01091 12.865L4.00989 12.8658ZM6.88854 18.2014C6.88851 18.2013 6.8889 18.2012 6.88979 18.201L6.88854 18.2014ZM19.9886 12.88C19.9885 12.88 19.9881 12.8797 19.9876 12.8792L19.9886 12.88ZM19.9886 11.12C19.9887 11.12 19.9883 11.1204 19.9876 11.1208L19.9886 11.12ZM17.1003 5.78965C17.1003 5.78968 17.0999 5.78986 17.099 5.79006L17.1003 5.78965ZM15.122 4.5937C15.122 4.59371 15.1221 4.59414 15.1222 4.59496L15.122 4.5937ZM13.1222 4L10.85 4V4.60808C10.85 5.49562 10.2774 6.19908 9.57449 6.51017C9.09654 6.7217 8.65096 6.99408 8.24769 7.31774C7.63839 7.80676 6.73261 7.98755 5.93958 7.55888L5.08481 7.09682L4.00015 8.8558L4.9628 9.37617C5.7538 9.80375 6.09888 10.6574 6.02633 11.4329C6.00889 11.6193 5.99995 11.8085 5.99995 12C5.99995 12.1915 6.00889 12.3807 6.02633 12.5671C6.09889 13.3426 5.75381 14.1963 4.9628 14.6239L4.0002 15.1442L5.08486 16.9032L5.9396 16.4411C6.73263 16.0125 7.63841 16.1933 8.2477 16.6823C8.65097 17.0059 9.09654 17.2783 9.57449 17.4898C10.2774 17.8009 10.85 18.5044 10.85 19.3919V20H13.1222V19.404C13.1222 18.5133 13.6987 17.8083 14.4051 17.4988C14.8875 17.2874 15.3372 17.0142 15.744 16.6889C16.3532 16.2017 17.2575 16.0222 18.0492 16.4501L18.8873 16.9032L19.972 15.1442L19.0357 14.6381C18.2434 14.2098 17.8986 13.3541 17.9726 12.5776C17.9907 12.3878 18 12.1951 18 12C18 11.8049 17.9907 11.6123 17.9726 11.4224C17.8986 10.6459 18.2434 9.79023 19.0357 9.36192L19.972 8.85579L18.8874 7.09681L18.0492 7.54989C17.2575 7.97786 16.3532 7.79836 15.744 7.31116C15.3372 6.98582 14.8875 6.71259 14.4051 6.50124C13.6987 6.19173 13.1222 5.48675 13.1222 4.596L13.1222 4Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14ZM12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/Speaker_Icon.svg b/examples/multimedia/video/mediaplayer/images/speaker.svg
index 723e48b66..723e48b66 100644
--- a/examples/multimedia/video/mediaplayer/Speaker_Icon.svg
+++ b/examples/multimedia/video/mediaplayer/images/speaker.svg
diff --git a/examples/multimedia/video/mediaplayer/images/stop_symbol.svg b/examples/multimedia/video/mediaplayer/images/stop_symbol.svg
new file mode 100644
index 000000000..99f00162f
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/stop_symbol.svg
@@ -0,0 +1,3 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M17.6665 7H7.6665L7.6665 17H17.6665V7ZM7.6665 5C6.56193 5 5.6665 5.89543 5.6665 7V17C5.6665 18.1046 6.56193 19 7.6665 19H17.6665C18.7711 19 19.6665 18.1046 19.6665 17V7C19.6665 5.89543 18.7711 5 17.6665 5H7.6665Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/url.svg b/examples/multimedia/video/mediaplayer/images/url.svg
new file mode 100644
index 000000000..44942911f
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/url.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 10C7 10.5523 6.55228 11 6 11C5.44772 11 5 10.5523 5 10C5 9.44772 5.44772 9 6 9C6.55228 9 7 9.44772 7 10Z" fill="black"/>
+<path d="M7 14C7 14.5523 6.55228 15 6 15C5.44772 15 5 14.5523 5 14C5 13.4477 5.44772 13 6 13C6.55228 13 7 13.4477 7 14Z" fill="black"/>
+<path d="M13 6L9 18" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M18 6L14 18" stroke="black" stroke-width="2" stroke-linecap="round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/volume.svg b/examples/multimedia/video/mediaplayer/images/volume.svg
new file mode 100644
index 000000000..2cdc4df6b
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/volume.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.98759 5.1163C11.1732 3.91192 13.2226 4.75139 13.2226 6.44139V17.5587C13.2226 19.2487 11.1732 20.0882 9.98759 18.8838L6.74406 15.5888C6.72318 15.5675 6.69465 15.5556 6.66488 15.5556H4.33371C3.29051 15.5556 2.44482 14.7099 2.44482 13.6667L2.44482 10.3334C2.44482 9.29016 3.29051 8.44448 4.33371 8.44448H6.66488C6.69465 8.44448 6.72318 8.43253 6.74406 8.41131L9.98759 5.1163ZM11.3101 6.32964C11.2992 6.3316 11.2809 6.33666 11.2545 6.36344L8.011 9.65845C7.65595 10.0191 7.171 10.2223 6.66488 10.2223H4.33371C4.27235 10.2223 4.2226 10.272 4.2226 10.3334L4.2226 13.6667C4.2226 13.7281 4.27235 13.7778 4.33371 13.7778H6.66488C7.171 13.7778 7.65595 13.9809 8.011 14.3416L11.2545 17.6366C11.2809 17.6634 11.2992 17.6685 11.3101 17.6704C11.326 17.6733 11.3496 17.6723 11.3758 17.6615C11.4021 17.6507 11.4196 17.6349 11.4289 17.6218C11.4353 17.6127 11.4448 17.5963 11.4448 17.5587V6.44139C11.4448 6.40381 11.4353 6.38737 11.4289 6.37829C11.4196 6.36513 11.4021 6.34932 11.3758 6.33857C11.3496 6.32781 11.326 6.3268 11.3101 6.32964Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.0329 4.37143C18.6857 4.0243 18.1229 4.0243 17.7758 4.37143C17.4287 4.71857 17.4287 5.28138 17.7758 5.62851C21.3339 9.18662 21.3339 14.9555 17.7758 18.5136C17.4287 18.8607 17.4287 19.4235 17.7758 19.7706C18.1229 20.1178 18.6857 20.1178 19.0329 19.7706C23.2852 15.5183 23.2852 8.62381 19.0329 4.37143ZM16.2044 7.37146C15.8573 7.02433 15.2945 7.02433 14.9474 7.37146C14.6002 7.71859 14.6002 8.28141 14.9474 8.62854C16.9434 10.6246 16.9434 13.8607 14.9474 15.8567C14.6002 16.2039 14.6002 16.7667 14.9474 17.1138C15.2945 17.461 15.8573 17.461 16.2044 17.1138C18.8947 14.4235 18.8947 10.0617 16.2044 7.37146Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/volume_mute.svg b/examples/multimedia/video/mediaplayer/images/volume_mute.svg
new file mode 100644
index 000000000..635c308e9
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/volume_mute.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.6541 5.1163C10.8397 3.91192 12.8891 4.75139 12.8891 6.44139V17.5587C12.8891 19.2487 10.8397 20.0882 9.6541 18.8838L6.41057 15.5888C6.38968 15.5675 6.36116 15.5556 6.33138 15.5556H4.00022C2.95701 15.5556 2.11133 14.7099 2.11133 13.6667L2.11133 10.3334C2.11133 9.29016 2.95701 8.44448 4.00022 8.44448H6.33138C6.36116 8.44448 6.38968 8.43253 6.41057 8.41131L9.6541 5.1163ZM10.9766 6.32964C10.9657 6.3316 10.9474 6.33666 10.921 6.36344L7.67751 9.65845C7.32245 10.0191 6.8375 10.2223 6.33138 10.2223H4.00022C3.93885 10.2223 3.88911 10.272 3.88911 10.3334L3.88911 13.6667C3.88911 13.7281 3.93885 13.7778 4.00022 13.7778H6.33138C6.8375 13.7778 7.32245 13.9809 7.67751 14.3416L10.921 17.6366C10.9474 17.6634 10.9657 17.6685 10.9766 17.6704C10.9925 17.6733 11.0161 17.6723 11.0423 17.6615C11.0686 17.6507 11.0861 17.6349 11.0954 17.6218C11.1018 17.6127 11.1113 17.5963 11.1113 17.5587V6.44139C11.1113 6.40381 11.1018 6.38737 11.0954 6.37829C11.0861 6.36513 11.0686 6.34932 11.0423 6.33857C11.0161 6.32781 10.9925 6.3268 10.9766 6.32964Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071C13.9024 15.3166 13.9024 14.6834 14.2929 14.2929L16.5858 12L14.2929 9.70711C13.9024 9.31658 13.9024 8.68342 14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289L18 10.5858L20.2929 8.29289C20.6834 7.90237 21.3166 7.90237 21.7071 8.29289C22.0976 8.68342 22.0976 9.31658 21.7071 9.70711L19.4142 12L21.7071 14.2929C22.0976 14.6834 22.0976 15.3166 21.7071 15.7071C21.3166 16.0976 20.6834 16.0976 20.2929 15.7071L18 13.4142L15.7071 15.7071Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg b/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg
new file mode 100644
index 000000000..9c7fb8ebb
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.071 3.92892C19.6233 3.92892 20.071 4.37664 20.071 4.92892V9.17157C20.071 9.72385 19.6233 10.1716 19.071 10.1716C18.5188 10.1716 18.071 9.72385 18.071 9.17157V7.34314L16.1716 9.24263C15.781 9.63315 15.1479 9.63315 14.7573 9.24263C14.3668 8.8521 14.3668 8.21894 14.7573 7.82841L16.6568 5.92892L14.8284 5.92892C14.2761 5.92892 13.8284 5.48121 13.8284 4.92892C13.8284 4.37664 14.2761 3.92892 14.8284 3.92892H19.071ZM4.92892 13.8284C5.48121 13.8284 5.92892 14.2761 5.92892 14.8284V16.6569L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L7.34314 18.0711L9.17157 18.0711C9.72385 18.0711 10.1716 18.5188 10.1716 19.0711C10.1716 19.6234 9.72385 20.0711 9.17157 20.0711H4.92892C4.37664 20.0711 3.92892 19.6234 3.92892 19.0711V14.8284C3.92892 14.2761 4.37664 13.8284 4.92892 13.8284Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1716 4.92892C10.1716 5.48121 9.72388 5.92892 9.1716 5.92892L7.34316 5.92892L9.24265 7.82841C9.63318 8.21894 9.63318 8.8521 9.24265 9.24263C8.85213 9.63315 8.21896 9.63315 7.82844 9.24263L5.92896 7.34314V9.17157C5.92896 9.72385 5.48124 10.1716 4.92896 10.1716C4.37667 10.1716 3.92896 9.72385 3.92896 9.17157V4.92892C3.92896 4.37664 4.37667 3.92892 4.92896 3.92892H9.1716C9.72388 3.92892 10.1716 4.37664 10.1716 4.92892ZM19.0711 13.8284C19.6234 13.8284 20.0711 14.2761 20.0711 14.8284V19.0711C20.0711 19.6234 19.6234 20.0711 19.0711 20.0711H14.8284C14.2761 20.0711 13.8284 19.6234 13.8284 19.0711C13.8284 18.5188 14.2761 18.0711 14.8284 18.0711H16.6569L14.2929 15.7071C13.9024 15.3166 13.9024 14.6834 14.2929 14.2929C14.6834 13.9024 15.3166 13.9024 15.7071 14.2929L18.0711 16.6569V14.8284C18.0711 14.2761 18.5188 13.8284 19.0711 13.8284Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg b/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg
new file mode 100644
index 000000000..3d6ae65aa
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.1213 10C14.502 10 14 9.49797 14 8.87868L14 4.12132C14 3.50203 14.502 3 15.1213 3C15.7406 3 16.2426 3.50203 16.2426 4.12132V6.17158L18.3726 4.04163C18.8105 3.60372 19.5205 3.60372 19.9584 4.04163C20.3963 4.47953 20.3963 5.18951 19.9584 5.62741L17.8284 7.75736L19.8787 7.75736C20.498 7.75736 21 8.25939 21 8.87868C21 9.49797 20.498 10 19.8787 10L15.1213 10ZM8.87868 21C8.25939 21 7.75736 20.498 7.75736 19.8787V17.8284L5.10659 20.4792C4.66869 20.9171 3.95871 20.9171 3.52081 20.4792C3.0829 20.0413 3.0829 19.3313 3.52081 18.8934L6.17157 16.2426H4.12132C3.50203 16.2426 3 15.7406 3 15.1213C3 14.502 3.50203 14 4.12132 14L8.87868 14C9.49797 14 10 14.502 10 15.1213L10 19.8787C10 20.498 9.49797 21 8.87868 21Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M3.00002 8.87867C3.00002 8.25939 3.50205 7.75735 4.12134 7.75735H6.1716L4.04166 5.62741C3.60375 5.1895 3.60375 4.47952 4.04166 4.04162C4.47956 3.60372 5.18954 3.60372 5.62744 4.04162L7.75737 6.17155V4.12131C7.75737 3.50203 8.25941 2.99999 8.87869 2.99999C9.49798 2.99999 10 3.50203 10 4.12131L10 8.87867C10 9.49796 9.49798 9.99999 8.87869 9.99999L4.12134 9.99999C3.50205 9.99999 3.00002 9.49796 3.00002 8.87867ZM15.1213 21C14.502 21 14 20.498 14 19.8787V15.1213C14 14.502 14.502 14 15.1213 14L19.8787 14C20.498 14 21 14.502 21 15.1213C21 15.7406 20.498 16.2426 19.8787 16.2426H17.8284L20.4792 18.8934C20.9171 19.3313 20.9171 20.0413 20.4792 20.4792C20.0413 20.9171 19.3313 20.9171 18.8934 20.4792L16.2426 17.8284V19.8787C16.2426 20.498 15.7406 21 15.1213 21Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/main.cpp b/examples/multimedia/video/mediaplayer/main.cpp
index 957083235..3df4d6027 100644
--- a/examples/multimedia/video/mediaplayer/main.cpp
+++ b/examples/multimedia/video/mediaplayer/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
#include <QCommandLineParser>
#include <QDir>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
@@ -68,17 +21,18 @@ int main(int argc, char *argv[])
parser.process(app);
QQmlApplicationEngine engine;
- const QUrl url(QStringLiteral("qrc:/main.qml"));
+ const QUrl url(QStringLiteral("qrc:/Main.qml"));
if (!parser.positionalArguments().isEmpty()) {
QUrl source = QUrl::fromUserInput(parser.positionalArguments().at(0), QDir::currentPath());
- QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, [source](QObject *object, const QUrl &){
- qDebug() << "setting source";
- object->setProperty("source", source);
- });
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
+ &engine, [source](QObject *object, const QUrl &) {
+ qDebug() << "setting source";
+ object->setProperty("source", source);
+ });
}
- engine.load(url);
+ engine.loadFromModule("mediaplayer", "Main");
return app.exec();
}
diff --git a/examples/multimedia/video/mediaplayer/main.qml b/examples/multimedia/video/mediaplayer/main.qml
deleted file mode 100644
index ea31ba2ed..000000000
--- a/examples/multimedia/video/mediaplayer/main.qml
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Window
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtMultimedia
-
-
-Window {
- id: root
- width: 640
- height: 480
- visible: true
- title: qsTr("Multimedia Player")
- property alias source: mediaPlayer.source
-
- Popup {
- id: mediaError
- anchors.centerIn: Overlay.overlay
- Text {
- id: mediaErrorText
- }
- }
-
- MediaPlayer {
- id: mediaPlayer
-
- function updateMetadata() {
- metadataInfo.clear();
- metadataInfo.read(mediaPlayer.metaData);
- metadataInfo.read(mediaPlayer.audioTracks[mediaPlayer.activeAudioTrack]);
- metadataInfo.read(mediaPlayer.videoTracks[mediaPlayer.activeVideoTrack]);
- }
-
- videoOutput: videoOutput
- audioOutput: AudioOutput {
- id: audio
- muted: playbackControl.muted
- volume: playbackControl.volume
- }
-
- onErrorOccurred: { mediaErrorText.text = mediaPlayer.errorString; mediaError.open() }
- onMetaDataChanged: { updateMetadata() }
- onTracksChanged: {
- audioTracksInfo.read(mediaPlayer.audioTracks);
- audioTracksInfo.selectedTrack = mediaPlayer.activeAudioTrack;
- videoTracksInfo.read(mediaPlayer.videoTracks);
- videoTracksInfo.selectedTrack = mediaPlayer.activeVideoTrack;
- subtitleTracksInfo.read(mediaPlayer.subtitleTracks);
- subtitleTracksInfo.selectedTrack = mediaPlayer.activeSubtitleTrack;
- updateMetadata()
- }
- onActiveTracksChanged: { updateMetadata() }
- }
-
- PlayerMenuBar {
- id: menuBar
-
- anchors.left: parent.left
- anchors.right: parent.right
-
- visible: !videoOutput.fullScreen
-
- mediaPlayer: mediaPlayer
- videoOutput: videoOutput
- metadataInfo: metadataInfo
- audioTracksInfo: audioTracksInfo
- videoTracksInfo: videoTracksInfo
- subtitleTracksInfo: subtitleTracksInfo
-
- onClosePlayer: root.close()
- }
-
-
- VideoOutput {
- id: videoOutput
-
- property bool fullScreen: false
-
- anchors.top: fullScreen ? parent.top : menuBar.bottom
- anchors.bottom: playbackControl.top
- anchors.left: parent.left
- anchors.right: parent.right
-
- TapHandler {
- onDoubleTapped: {
- parent.fullScreen ? showNormal() : showFullScreen()
- parent.fullScreen = !parent.fullScreen
- }
- onTapped: {
- metadataInfo.visible = false
- audioTracksInfo.visible = false
- videoTracksInfo.visible = false
- subtitleTracksInfo.visible = false
- }
- }
- }
-
- MetadataInfo {
- id: metadataInfo
-
- anchors.right: parent.right
- anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
- anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
-
- visible: false
- }
-
- TracksInfo {
- id: audioTracksInfo
-
- anchors.right: parent.right
- anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
- anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
-
- visible: false
- onSelectedTrackChanged: mediaPlayer.activeAudioTrack = audioTracksInfo.selectedTrack
- }
-
- TracksInfo {
- id: videoTracksInfo
-
- anchors.right: parent.right
- anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
- anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
-
- visible: false
- onSelectedTrackChanged: mediaPlayer.activeVideoTrack = videoTracksInfo.selectedTrack
- }
-
- TracksInfo {
- id: subtitleTracksInfo
-
- anchors.right: parent.right
- anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
- anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
-
- visible: false
- onSelectedTrackChanged: mediaPlayer.activeSubtitleTrack = subtitleTracksInfo.selectedTrack
- }
-
- PlaybackControl {
- id: playbackControl
-
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
-
- mediaPlayer: mediaPlayer
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/CMakeLists.txt
index 906ba61cf..43975d584 100644
--- a/examples/multimedia/video/qmlvideo/CMakeLists.txt
+++ b/examples/multimedia/video/qmlvideo/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
-project(qmlvideo LANGUAGES CXX)
+project(qmlvideoexample LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
@@ -11,7 +14,9 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Qml Quick)
-qt_add_executable(qmlvideo
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(qmlvideoexample
frequencymonitor.cpp frequencymonitor.h
frequencymonitordeclarative.cpp
performancemonitor.cpp performancemonitor.h
@@ -20,98 +25,33 @@ qt_add_executable(qmlvideo
trace.h
)
-set_target_properties(qmlvideo PROPERTIES
+set_target_properties(qmlvideoexample PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
)
-target_compile_definitions(qmlvideo PUBLIC
+target_compile_definitions(qmlvideoexample PUBLIC
FREQUENCYMONITOR_SUPPORT
PERFORMANCEMONITOR_SUPPORT
)
-target_link_libraries(qmlvideo PUBLIC
+add_subdirectory(qmlvideo)
+add_subdirectory(performancemonitor)
+add_subdirectory(frequencymonitor)
+
+target_link_libraries(qmlvideoexample PRIVATE
Qt::Core
Qt::Gui
Qt::Multimedia
Qt::Qml
Qt::Quick
+ qmlvideo
+ performancemonitor
+ frequencymonitor
)
-# Resources:
-set_source_files_properties("images/folder.png"
- PROPERTIES QT_RESOURCE_ALIAS "folder.png"
-)
-
-set_source_files_properties("images/leaves.jpg"
- PROPERTIES QT_RESOURCE_ALIAS "leaves.jpg"
-)
-
-set_source_files_properties("images/up.png"
- PROPERTIES QT_RESOURCE_ALIAS "up.png"
-)
-
-set(qmlvideo_resource_files
- "images/folder.png"
- "images/leaves.jpg"
- "images/up.png"
- "qml/frequencymonitor/FrequencyItem.qml"
- "qml/performancemonitor/PerformanceItem.qml"
- "qml/qmlvideo/Button.qml"
- "qml/qmlvideo/CameraBasic.qml"
- "qml/qmlvideo/CameraDrag.qml"
- "qml/qmlvideo/CameraDummy.qml"
- "qml/qmlvideo/CameraFullScreen.qml"
- "qml/qmlvideo/CameraFullScreenInverted.qml"
- "qml/qmlvideo/CameraItem.qml"
- "qml/qmlvideo/CameraMove.qml"
- "qml/qmlvideo/CameraOverlay.qml"
- "qml/qmlvideo/CameraResize.qml"
- "qml/qmlvideo/CameraRotate.qml"
- "qml/qmlvideo/CameraSpin.qml"
- "qml/qmlvideo/Content.qml"
- "qml/qmlvideo/ErrorDialog.qml"
- "qml/qmlvideo/FileBrowser.qml"
- "qml/qmlvideo/Scene.qml"
- "qml/qmlvideo/SceneBasic.qml"
- "qml/qmlvideo/SceneDrag.qml"
- "qml/qmlvideo/SceneFullScreen.qml"
- "qml/qmlvideo/SceneFullScreenInverted.qml"
- "qml/qmlvideo/SceneMove.qml"
- "qml/qmlvideo/SceneMulti.qml"
- "qml/qmlvideo/SceneOverlay.qml"
- "qml/qmlvideo/SceneResize.qml"
- "qml/qmlvideo/SceneRotate.qml"
- "qml/qmlvideo/SceneSelectionPanel.qml"
- "qml/qmlvideo/SceneSpin.qml"
- "qml/qmlvideo/SeekControl.qml"
- "qml/qmlvideo/VideoBasic.qml"
- "qml/qmlvideo/VideoDrag.qml"
- "qml/qmlvideo/VideoDummy.qml"
- "qml/qmlvideo/VideoFillMode.qml"
- "qml/qmlvideo/VideoFullScreen.qml"
- "qml/qmlvideo/VideoFullScreenInverted.qml"
- "qml/qmlvideo/VideoItem.qml"
- "qml/qmlvideo/VideoMetadata.qml"
- "qml/qmlvideo/VideoMove.qml"
- "qml/qmlvideo/VideoOverlay.qml"
- "qml/qmlvideo/VideoPlaybackRate.qml"
- "qml/qmlvideo/VideoResize.qml"
- "qml/qmlvideo/VideoRotate.qml"
- "qml/qmlvideo/VideoSeek.qml"
- "qml/qmlvideo/VideoSpin.qml"
- "qml/qmlvideo/main.qml"
-)
-
-qt_add_resources(qmlvideo "qmlvideo"
- PREFIX
- "/"
- FILES
- ${qmlvideo_resource_files}
-)
-
-install(TARGETS qmlvideo
+install(TARGETS qmlvideoexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/multimedia/video/doc/images/qmlvideo-menu.jpg b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg
index 54ab877a1..54ab877a1 100644
--- a/examples/multimedia/video/doc/images/qmlvideo-menu.jpg
+++ b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideo-overlay.jpg b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg
index 6a0d48ae6..6a0d48ae6 100644
--- a/examples/multimedia/video/doc/images/qmlvideo-overlay.jpg
+++ b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg
Binary files differ
diff --git a/examples/multimedia/video/doc/src/qmlvideo.qdoc b/examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc
index b8ab25d03..81f7cf05c 100644
--- a/examples/multimedia/video/doc/src/qmlvideo.qdoc
+++ b/examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\example multimedia/video/qmlvideo
+\example video/qmlvideo
\title QML Video Example
\ingroup multimedia_examples
+\examplecategory {Multimedia}
\brief Transforming video and camera viewfinder content.
\e{QML Video} demonstrates the various transformations (move; resize; rotate;
@@ -50,11 +27,11 @@ which moves across the \l{VideoOutput} item.
\section1 Application Structure
-The \c main.qml file creates a UI which includes the following items:
+The \c Main.qml file creates a UI which includes the following items:
\list
\li Two \c Button instances, each of which displays a filename, and can be
- used to launch a \c FileBrowser.
+ used to launch a \c FileDialog.
\li An exit \c Button.
\li A \c SceneSelectionPanel, which is a flickable list displaying the
available scenes.
@@ -71,13 +48,13 @@ in the center of the screen) is implemented in the \c VideoBasic.qml file. As
you can see from the code, this makes use of a type of inheritance; a
\c VideoBasic item ...
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
-\skipto import
+\quotefromfile video/qmlvideo/qmlvideo/VideoBasic.qml
+\skipto SceneBasic
\printuntil /^\}/
... is of type \c SceneBasic ...
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
+\quotefromfile video/qmlvideo/qmlvideo/SceneBasic.qml
\skipto import
\printuntil contentType
\dots
@@ -89,7 +66,7 @@ you can see from the code, this makes use of a type of inheritance; a
... which itself is a \c Scene:
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
+\quotefromfile video/qmlvideo/qmlvideo/Scene.qml
\skipto import
\printuntil root
\dots
@@ -122,8 +99,11 @@ All that remains is to connect the afterRendering() signal of the QQuickView
object to a JavaScript function, which will eventually call
\c frequencyItem.notify():
-\quotefromfile multimedia/video/qmlvideo/main.cpp
-\skipto QGuiApplication
+\quotefromfile video/qmlvideo/main.cpp
+\skipto int main(
+\printuntil ;
+\dots
+\skipto QQuickView
\printuntil ;
\dots
\skipto QQuickItem
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor.cpp b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp
index 5f48cd35e..d6f1953f6 100644
--- a/examples/multimedia/video/qmlvideo/frequencymonitor.cpp
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "frequencymonitor.h"
+
#include <QDebug>
#include <QElapsedTimer>
#include <QString>
@@ -57,11 +11,20 @@
//#define VERBOSE_TRACE
-inline QDebug qtTrace() { return qDebug() << "[frequencymonitor]"; }
+inline QDebug qtTrace()
+{
+ return qDebug() << "[frequencymonitor]";
+}
#ifdef VERBOSE_TRACE
-inline QDebug qtVerboseTrace() { return qtTrace(); }
+inline QDebug qtVerboseTrace()
+{
+ return qtTrace();
+}
#else
-inline QNoDebug qtVerboseTrace() { return QNoDebug(); }
+inline QNoDebug qtVerboseTrace()
+{
+ return QNoDebug();
+}
#endif
static const int DefaultSamplingInterval = 100;
@@ -94,29 +57,27 @@ public:
};
FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent)
-: QObject(parent)
-, q_ptr(parent)
-, m_active(false)
-, m_instantaneousFrequency(0)
-, m_averageTimer(new QTimer(this))
-, m_count(0)
-, m_averageFrequency(0)
-, m_traceTimer(new QTimer(this))
-, m_stalledTimer(new QTimer(this))
+ : QObject(parent),
+ q_ptr(parent),
+ m_active(false),
+ m_instantaneousFrequency(0),
+ m_averageTimer(new QTimer(this)),
+ m_count(0),
+ m_averageFrequency(0),
+ m_traceTimer(new QTimer(this)),
+ m_stalledTimer(new QTimer(this))
{
m_instantaneousElapsed.start();
- connect(m_averageTimer, &QTimer::timeout,
- this, &FrequencyMonitorPrivate::calculateAverageFrequency);
+ connect(m_averageTimer, &QTimer::timeout, this,
+ &FrequencyMonitorPrivate::calculateAverageFrequency);
if (DefaultSamplingInterval)
m_averageTimer->start(DefaultSamplingInterval);
m_averageElapsed.start();
- connect(m_traceTimer, &QTimer::timeout,
- q_ptr, &FrequencyMonitor::trace);
+ connect(m_traceTimer, &QTimer::timeout, q_ptr, &FrequencyMonitor::trace);
if (DefaultTraceInterval)
m_traceTimer->start(DefaultTraceInterval);
m_stalledTimer->setSingleShot(true);
- connect(m_stalledTimer, &QTimer::timeout,
- this, &FrequencyMonitorPrivate::stalled);
+ connect(m_stalledTimer, &QTimer::timeout, this, &FrequencyMonitorPrivate::stalled);
}
void FrequencyMonitorPrivate::calculateInstantaneousFrequency()
@@ -148,8 +109,7 @@ void FrequencyMonitorPrivate::stalled()
}
}
-FrequencyMonitor::FrequencyMonitor(QObject *parent)
-: QObject(parent)
+FrequencyMonitor::FrequencyMonitor(QObject *parent) : QObject(parent)
{
d_ptr = new FrequencyMonitorPrivate(this);
}
@@ -196,13 +156,14 @@ void FrequencyMonitor::notify()
void FrequencyMonitor::trace()
{
Q_D(FrequencyMonitor);
- const QString value = QString::fromLatin1("instant %1 average %2")
- .arg(d->m_instantaneousFrequency, 0, 'f', 2)
- .arg(d->m_averageFrequency, 0, 'f', 2);
+ const QString value = QStringLiteral("instant %1 average %2")
+ .arg(d->m_instantaneousFrequency, 0, 'f', 2)
+ .arg(d->m_averageFrequency, 0, 'f', 2);
if (d->m_label.isEmpty())
qtTrace() << "FrequencyMonitor::trace" << value;
else
- qtTrace() << "FrequencyMonitor::trace" << "label" << d->m_label << value;
+ qtTrace() << "FrequencyMonitor::trace"
+ << "label" << d->m_label << value;
}
void FrequencyMonitor::setLabel(const QString &value)
@@ -252,3 +213,4 @@ void FrequencyMonitor::setTraceInterval(int value)
}
#include "frequencymonitor.moc"
+#include "moc_frequencymonitor.cpp"
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor.h b/examples/multimedia/video/qmlvideo/frequencymonitor.h
index efeb78589..a1756dc88 100644
--- a/examples/multimedia/video/qmlvideo/frequencymonitor.h
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FREQUENCYMONITOR_H
#define FREQUENCYMONITOR_H
@@ -69,13 +22,16 @@ class FrequencyMonitor : public QObject
Q_DECLARE_PRIVATE(FrequencyMonitor)
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY samplingIntervalChanged)
- Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged)
- Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged)
+ Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY
+ samplingIntervalChanged)
+ Q_PROPERTY(
+ int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged)
+ Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY
+ instantaneousFrequencyChanged)
Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged)
public:
- FrequencyMonitor(QObject *parent = 0);
+ FrequencyMonitor(QObject *parent = nullptr);
~FrequencyMonitor();
static void qmlRegisterType();
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt
new file mode 100644
index 000000000..4a205fa28
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt
@@ -0,0 +1,30 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/frequencymonitor")
+
+qt_add_qml_module(frequencymonitor
+ URI frequencymonitor
+ QML_FILES
+ "FrequencyItem.qml"
+)
+
+target_link_libraries(frequencymonitor PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS frequencymonitor
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml
new file mode 100644
index 000000000..49a7eea9b
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import FrequencyMonitor 1.0
+
+Rectangle {
+ id: root
+ property bool logging: true
+ property bool displayed: true
+ property bool enabled: logging || displayed
+ property alias active: monitor.active
+ property int samplingInterval: 500
+ property color textColor: "yellow"
+ property int textSize: 20
+ property alias label: monitor.label
+
+ border.width: 1
+ border.color: "yellow"
+ width: 5.5 * root.textSize
+ height: 3.0 * root.textSize
+ color: "black"
+ opacity: 0.5
+ radius: 10
+ visible: displayed && active
+
+ // This should ensure that the monitor is on top of all other content
+ z: 999
+
+ function notify() {
+ monitor.notify()
+ }
+
+ FrequencyMonitor {
+ id: monitor
+ samplingInterval: root.enabled ? root.samplingInterval : 0
+ onAverageFrequencyChanged: {
+ if (root.logging) trace()
+ averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
+ }
+ }
+
+ Text {
+ id: labelText
+ anchors {
+ left: parent.left
+ top: parent.top
+ margins: 10
+ }
+ color: root.textColor
+ font.pixelSize: 0.6 * root.textSize
+ text: root.label
+ width: root.width - 2*anchors.margins
+ elide: Text.ElideRight
+ }
+
+ Text {
+ id: averageFrequencyText
+ anchors {
+ right: parent.right
+ bottom: parent.bottom
+ margins: 10
+ }
+ color: root.textColor
+ font.pixelSize: root.textSize
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir
new file mode 100644
index 000000000..a935d2c53
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir
@@ -0,0 +1,3 @@
+module frequencymonitor
+
+FrequencyItem 1.0 FrequencyItem.qml
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp
index 0994ae213..6ed2019ff 100644
--- a/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp
+++ b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp
@@ -1,55 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "frequencymonitor.h"
-#include <QtQml/qqml.h>
+#include <qqml.h>
void FrequencyMonitor::qmlRegisterType()
{
diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp
index e288c0ae4..94c5bfea0 100644
--- a/examples/multimedia/video/qmlvideo/main.cpp
+++ b/examples/multimedia/video/qmlvideo/main.cpp
@@ -1,65 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QtCore/QStandardPaths>
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtQml/QQmlContext>
-#include <QtQml/QQmlEngine>
-#include <QtGui/QGuiApplication>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
+#include "performancemonitor.h"
#include "trace.h"
-
+#include "qmlvideo/videosingleton.h"
#ifdef PERFORMANCEMONITOR_SUPPORT
-#include "performancemonitordeclarative.h"
+# include "performancemonitordeclarative.h"
+#endif
+
+#include <QGuiApplication>
+#include <QQmlContext>
+#include <QQmlEngine>
+#include <QQuickItem>
+#include <QQuickView>
+#include <QStandardPaths>
+#include <QString>
+#include <QStringList>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
#endif
static const QString DefaultFileName1 = "";
@@ -84,7 +43,7 @@ int main(int argc, char *argv[])
const QByteArray arg = args.at(i).toUtf8();
if (arg.startsWith('-')) {
if ("-volume" == arg) {
- if (i+1 < args.count())
+ if (i + 1 < args.count())
volume = 0.01 * args.at(++i).toInt();
else
qtTrace() << "Option \"-volume\" takes a value";
@@ -120,36 +79,47 @@ int main(int argc, char *argv[])
url2 = QUrl::fromLocalFile(source2);
}
+ const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
+ const QUrl videoPath = QUrl::fromLocalFile(moviesLocation.isEmpty() ? app.applicationDirPath()
+ : moviesLocation.front());
+
QQuickView viewer;
- viewer.setSource(QUrl("qrc:///qml/qmlvideo/main.qml"));
+ VideoSingleton* singleton = viewer.engine()->singletonInstance<VideoSingleton*>("qmlvideo", "VideoSingleton");
+ singleton->setVideoPath(videoPath);
+ singleton->setSource1(source1);
+ singleton->setSource2(source2);
+ singleton->setVolume(volume);
+ viewer.loadFromModule("qmlvideo", "Main");
QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QQuickView::close);
- QQuickItem *rootObject = viewer.rootObject();
- rootObject->setProperty("source1", url1);
- rootObject->setProperty("source2", url2);
- rootObject->setProperty("volume", volume);
-
#ifdef PERFORMANCEMONITOR_SUPPORT
+ QQuickItem *rootObject = viewer.rootObject();
if (performanceMonitorState.valid) {
rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging);
rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible);
}
- QObject::connect(&viewer, SIGNAL(afterRendering()),
- rootObject, SLOT(qmlFramePainted()));
+ QObject::connect(&viewer, SIGNAL(afterRendering()), rootObject, SLOT(qmlFramePainted()));
#endif
- const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
- const QUrl videoPath =
- QUrl::fromLocalFile(moviesLocation.isEmpty() ?
- app.applicationDirPath() :
- moviesLocation.front());
- viewer.rootContext()->setContextProperty("videoPath", videoPath);
-
QMetaObject::invokeMethod(rootObject, "init");
- viewer.setMinimumSize(QSize(640, 360));
- viewer.show();
+ auto setupView = [&viewer]() {
+ viewer.setMinimumSize(QSize(640, 360));
+ viewer.show();
+ };
+
+#if QT_CONFIG(permissions)
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&setupView](const QPermission &permission) {
+ // Show UI in any case. If there is no permission, the UI will just
+ // be disabled.
+ if (permission.status() != Qt::PermissionStatus::Granted)
+ qWarning("Camera permission is not granted! Camera will not be available.");
+ setupView();
+ });
+#else
+ setupView();
+#endif
return app.exec();
}
-
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.cpp b/examples/multimedia/video/qmlvideo/performancemonitor.cpp
index 204eabc5a..26f0fae2a 100644
--- a/examples/multimedia/video/qmlvideo/performancemonitor.cpp
+++ b/examples/multimedia/video/qmlvideo/performancemonitor.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "performancemonitor.h"
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.h b/examples/multimedia/video/qmlvideo/performancemonitor.h
index 97b76caf3..683468619 100644
--- a/examples/multimedia/video/qmlvideo/performancemonitor.h
+++ b/examples/multimedia/video/qmlvideo/performancemonitor.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PERFORMANCEMONITOR_H
#define PERFORMANCEMONITOR_H
@@ -60,9 +13,13 @@ struct State
State() : valid(true), logging(false), visible(true) { }
State(bool l, bool v) : valid(true), logging(l), visible(v) { }
bool operator==(const State &other) const
- { return logging == other.logging && visible == other.visible; }
+ {
+ return logging == other.logging && visible == other.visible;
+ }
bool operator!=(const State &other) const
- { return logging != other.logging || visible != other.visible; }
+ {
+ return logging != other.logging || visible != other.visible;
+ }
bool parseArgument(const QByteArray &arg);
@@ -74,4 +31,3 @@ struct State
} // namespace PerformanceMonitor
#endif // PERFORMANCEMONITOR_H
-
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt b/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt
new file mode 100644
index 000000000..beb9e2e08
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/performancemonitor")
+
+qt_add_qml_module(performancemonitor
+ URI performancemonitor
+ QML_FILES
+ "PerformanceItem.qml"
+)
+
+target_link_libraries(performancemonitor PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS performancemonitor
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml
new file mode 100644
index 000000000..5b501b104
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml
@@ -0,0 +1,100 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: root
+ property bool logging: true
+ property bool displayed: true
+ property bool videoActive
+ property int margins: 5
+ property bool enabled: true
+
+ color: "transparent"
+
+ // This should ensure that the monitor is on top of all other content
+ z: 999
+
+ Column {
+ id: column
+ anchors {
+ fill: root
+ margins: 10
+ }
+ spacing: 10
+ }
+
+ QtObject {
+ id: d
+ property Item qmlFrameRateItem: null
+ property Item videoFrameRateItem: null
+ }
+
+ Connections {
+ id: videoFrameRateActiveConnections
+ ignoreUnknownSignals: true
+ function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active }
+ }
+
+ states: [
+ State {
+ name: "hidden"
+ PropertyChanges {
+ root.opacity: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ easing.type: Easing.OutQuart
+ duration: 500
+ }
+ }
+ ]
+
+ state: enabled ? "baseState" : "hidden"
+
+ function createQmlFrameRateItem() {
+ let component = Qt.createComponent("frequencymonitor", "FrequencyItem")
+ if (component.status === Component.Ready)
+ d.qmlFrameRateItem = component.createObject(column, { label: qsTr("QML frame rate"),
+ displayed: root.displayed,
+ logging: root.logging
+ });
+ }
+
+ function createVideoFrameRateItem() {
+ let component = Qt.createComponent("frequencymonitor", "FrequencyItem")
+ if (component.status === Component.Ready)
+ d.videoFrameRateItem = component.createObject(column, { label: qsTr("Video frame rate"),
+ displayed: root.displayed,
+ logging: root.logging
+ });
+ videoFrameRateActiveConnections.target = d.videoFrameRateItem
+ }
+
+
+ function init() {
+ createQmlFrameRateItem()
+ createVideoFrameRateItem()
+ }
+
+ function videoFramePainted() {
+ d.videoFrameRateItem?.notify()
+ }
+
+ function qmlFramePainted() {
+ d.qmlFrameRateItem?.notify()
+ }
+
+ onVideoActiveChanged: {
+ if (d.videoFrameRateItem)
+ d.videoFrameRateItem.active = root.videoActive
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/qmldir b/examples/multimedia/video/qmlvideo/performancemonitor/qmldir
new file mode 100644
index 000000000..636abaf99
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/qmldir
@@ -0,0 +1,3 @@
+module performancemonitor
+
+PerformanceItem 1.0 PerformanceItem.qml
diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp
index 0783fdbd9..a2ad1ca82 100644
--- a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp
+++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp
@@ -1,60 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "frequencymonitor.h"
-#include "performancemonitor.h"
namespace PerformanceMonitor {
- void qmlRegisterTypes()
- {
- FrequencyMonitor::qmlRegisterType();
- }
+void qmlRegisterTypes()
+{
+ FrequencyMonitor::qmlRegisterType();
+}
}
diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h
index ca70657ce..4514d5041 100644
--- a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h
+++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PERFORMANCEMONITORDECLARATIVE_H
#define PERFORMANCEMONITORDECLARATIVE_H
-#include "performancemonitor.h"
-
namespace PerformanceMonitor {
- void qmlRegisterTypes();
+void qmlRegisterTypes();
}
#endif // PERFORMANCEMONITORDECLARATIVE_H
diff --git a/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml
deleted file mode 100644
index ec1bab299..000000000
--- a/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import FrequencyMonitor 1.0
-
-Rectangle {
- id: root
- property bool logging: true
- property bool displayed: true
- property bool enabled: logging || displayed
- property alias active: monitor.active
- property int samplingInterval: 500
- property color textColor: "yellow"
- property int textSize: 20
- property alias label: monitor.label
-
- border.width: 1
- border.color: "yellow"
- width: 5.5 * root.textSize
- height: 3.0 * root.textSize
- color: "black"
- opacity: 0.5
- radius: 10
- visible: displayed && active
-
- // This should ensure that the monitor is on top of all other content
- z: 999
-
- function notify() {
- monitor.notify()
- }
-
- FrequencyMonitor {
- id: monitor
- samplingInterval: root.enabled ? root.samplingInterval : 0
- onAverageFrequencyChanged: {
- if (root.logging) trace()
- averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
- }
- }
-
- Text {
- id: labelText
- anchors {
- left: parent.left
- top: parent.top
- margins: 10
- }
- color: root.textColor
- font.pixelSize: 0.6 * root.textSize
- text: root.label
- width: root.width - 2*anchors.margins
- elide: Text.ElideRight
- }
-
- Text {
- id: averageFrequencyText
- anchors {
- right: parent.right
- bottom: parent.bottom
- margins: 10
- }
- color: root.textColor
- font.pixelSize: root.textSize
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml
deleted file mode 100644
index 5621450cb..000000000
--- a/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- property bool logging: true
- property bool displayed: true
- property bool videoActive
- property int margins: 5
- property bool enabled: true
-
- color: "transparent"
-
- // This should ensure that the monitor is on top of all other content
- z: 999
-
- Column {
- id: column
- anchors {
- fill: root
- margins: 10
- }
- spacing: 10
- }
-
- QtObject {
- id: d
- property Item qmlFrameRateItem: null
- property Item videoFrameRateItem: null
- }
-
- Connections {
- id: videoFrameRateActiveConnections
- ignoreUnknownSignals: true
- function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active }
- }
-
- states: [
- State {
- name: "hidden"
- PropertyChanges {
- target: root
- opacity: 0
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.OutQuart
- duration: 500
- }
- }
- ]
-
- state: enabled ? "baseState" : "hidden"
-
- function createQmlFrameRateItem() {
- var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
- if (component.status == Component.Ready)
- d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate",
- displayed: root.displayed,
- logging: root.logging
- })
- }
-
- function createVideoFrameRateItem() {
- var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
- if (component.status == Component.Ready)
- d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate",
- displayed: root.displayed,
- logging: root.logging
- })
- videoFrameRateActiveConnections.target = d.videoFrameRateItem
- }
-
-
- function init() {
- createQmlFrameRateItem()
- createVideoFrameRateItem()
- }
-
- function videoFramePainted() {
- if (d.videoFrameRateItem)
- d.videoFrameRateItem.notify()
- }
-
- function qmlFramePainted() {
- if (d.qmlFrameRateItem)
- d.qmlFrameRateItem.notify()
- }
-
- onVideoActiveChanged: {
- if (d.videoFrameRateItem)
- d.videoFrameRateItem.active = root.videoActive
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml
deleted file mode 100644
index b06db6119..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Item {
- id: root
-
- property string text
- property color bgColor: "#757575"
- property color bgColorSelected: "#bdbdbd"
- property color textColor: "white"
- property color textColorSelected: "black"
- property alias enabled: mouseArea.enabled
- property alias radius: bgr.radius
-
- signal clicked
-
- Rectangle {
- id: bgr
- anchors.fill: parent
- color: mouseArea.pressed ? bgColorSelected : bgColor
- radius: height / 15
-
- Text {
- id: text
- anchors.centerIn: parent
- text: root.text
- font.pixelSize: 0.4 * parent.height
- color: mouseArea.pressed ? textColorSelected : textColor
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- root.clicked()
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml
deleted file mode 100644
index c30344d2a..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneBasic {
- contentType: "camera"
- started: true
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml
deleted file mode 100644
index c8b7e3d16..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneDrag {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml
deleted file mode 100644
index 6b3bac9b2..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-// Item which is loaded by CameraItem if Qt Multimedia is not available
-Rectangle {
- id: root
- color: "grey"
- height: width
-
- signal fatalError
- signal sizeChanged
- signal framePainted
-
- Text {
- anchors.fill: parent
- anchors.margins: 10
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- text: "Failed to create Camera item\n\nCheck that Qt Multimedia is installed"
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.Wrap
- }
-
- onWidthChanged: height = width
- onHeightChanged: root.sizeChanged()
-
- function start() { }
- function stop() { }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml
deleted file mode 100644
index a1ce00176..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneFullScreen {
- contentType: "camera"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml
deleted file mode 100644
index 9b0cb80c8..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneFullScreenInverted {
- contentType: "camera"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml
deleted file mode 100644
index 26ffcc352..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtMultimedia
-
-Item {
- id: root
- height: width
-
- signal fatalError
- signal sizeChanged
-
- onHeightChanged: root.sizeChanged()
-
- CaptureSession {
- camera: Camera {
- id: camera
-
- onErrorOccurred: function(error, errorString) {
- if (Camera.NoError !== error) {
- console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
- root.fatalError()
- }
- }
- }
- imageCapture: ImageCapture {
- id: imageCapture
- }
-
- recorder: MediaRecorder {
- id: recorder
-// resolution: "640x480"
-// frameRate: 30
- }
- videoOutput: videoOutput
- }
-
- VideoOutput {
- id: videoOutput
- anchors.fill: parent
- }
-
-
- function start() { camera.start() }
- function stop() { camera.stop() }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml
deleted file mode 100644
index 0f9f55171..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneMove {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml
deleted file mode 100644
index 15dc85255..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneOverlay {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml
deleted file mode 100644
index 1fee96489..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneResize {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml
deleted file mode 100644
index 680f4d998..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneRotate {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml
deleted file mode 100644
index 5ae981350..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneSpin {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml
deleted file mode 100644
index 803f7fff3..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- border.color: "white"
- border.width: showBorder ? 1 : 0
- color: "transparent"
- property string contentType // "camera" or "video"
- property string source
- property real volume
- property bool dummy: false
- property bool autoStart: true
- property bool started: false
- property bool showFrameRate: false
- property bool showBorder: false
-
- signal initialized
- signal error
- signal videoFramePainted
-
- Loader {
- id: contentLoader
- }
-
- Connections {
- id: framePaintedConnection
- function onFramePainted() {
- if (frameRateLoader.item)
- frameRateLoader.item.notify()
- root.videoFramePainted()
- }
- ignoreUnknownSignals: true
- }
-
- Connections {
- id: errorConnection
- function onFatalError() {
- console.log("[qmlvideo] Content.onFatalError")
- stop()
- root.error()
- }
- ignoreUnknownSignals: true
- }
-
- Loader {
- id: frameRateLoader
- source: root.showFrameRate ? "../frequencymonitor/FrequencyItem.qml" : ""
- onLoaded: {
- item.parent = root
- item.anchors.top = root.top
- item.anchors.right = root.right
- item.anchors.margins = 10
- }
- }
-
- onWidthChanged: {
- if (contentItem())
- contentItem().width = width
- }
-
- onHeightChanged: {
- if (contentItem())
- contentItem().height = height
- }
-
- function initialize() {
- if ("video" == contentType) {
- contentLoader.source = "VideoItem.qml"
- if (Loader.Error == contentLoader.status) {
- contentLoader.source = "VideoDummy.qml"
- dummy = true
- }
- contentLoader.item.volume = volume
- } else if ("camera" == contentType) {
- contentLoader.source = "CameraItem.qml"
- if (Loader.Error == contentLoader.status) {
- contentLoader.source = "CameraDummy.qml"
- dummy = true
- }
- } else {
- console.log("[qmlvideo] Content.initialize: error: invalid contentType")
- }
- if (contentLoader.item) {
- contentLoader.item.sizeChanged.connect(updateRootSize)
- contentLoader.item.parent = root
- contentLoader.item.width = root.width
- framePaintedConnection.target = contentLoader.item
- errorConnection.target = contentLoader.item
- if (root.autoStart)
- root.start()
- }
- root.initialized()
- }
-
- function start() {
- if (contentLoader.item) {
- if (root.contentType == "video")
- contentLoader.item.mediaSource = root.source
- contentLoader.item.start()
- root.started = true
- }
- }
-
- function stop() {
- if (contentLoader.item) {
- contentLoader.item.stop()
- if (root.contentType == "video")
- contentLoader.item.mediaSource = ""
- root.started = false
- }
- }
-
- function contentItem() { return contentLoader.item }
- function updateRootSize() { root.height = contentItem().height }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml
deleted file mode 100644
index cfe719f3a..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- color: "transparent"
- opacity: 0.0
- property alias enabled: mouseArea.enabled
- property int dialogWidth: 300
- property int dialogHeight: 200
- state: enabled ? "on" : "baseState"
-
- states: [
- State {
- name: "on"
- PropertyChanges {
- target: root
- opacity: 1.0
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.OutQuart
- duration: 500
- }
- }
- ]
-
- Rectangle {
- anchors.fill: parent
- color: "black"
- opacity: 0.75
- }
-
- Rectangle {
- anchors.centerIn: parent
- width: dialogWidth
- height: dialogHeight
- radius: 5
- color: "white"
-
- Text {
- id: text
- anchors.fill: parent
- anchors.margins: 10
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "black"
- wrapMode: Text.WordWrap
- }
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: root.enabled = false
- }
-
- function show(msg) {
- text.text = "<b>Error</b><br><br>" + msg
- root.enabled = true
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
deleted file mode 100644
index 31684368e..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
+++ /dev/null
@@ -1,419 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import Qt.labs.folderlistmodel
-
-Rectangle {
- id: fileBrowser
- color: "transparent"
-
- property string folder
-
- property int itemHeight: Math.min(parent.width, parent.height) / 15
- property int buttonHeight: Math.min(parent.width, parent.height) / 12
-
- signal fileSelected(string file)
-
- function selectFile(file) {
- if (file !== "") {
- folder = loader.item.folders.folder
- fileBrowser.fileSelected(file)
- }
- loader.sourceComponent = undefined
- }
-
- Loader {
- id: loader
- }
-
- function show() {
- loader.sourceComponent = fileBrowserComponent
- loader.item.parent = fileBrowser
- loader.item.anchors.fill = fileBrowser
- loader.item.folder = fileBrowser.folder
- }
-
- Component {
- id: fileBrowserComponent
-
- Rectangle {
- id: root
- color: "black"
- property bool showFocusHighlight: false
- property variant folders: folders1
- property variant view: view1
- property alias folder: folders1.folder
- property color textColor: "white"
-
- FolderListModel {
- id: folders1
- folder: folder
- }
-
- FolderListModel {
- id: folders2
- folder: folder
- }
-
- SystemPalette {
- id: palette
- }
-
- Component {
- id: folderDelegate
-
- Rectangle {
- id: wrapper
- function launch() {
- var path = "file://";
- if (filePath.length > 2 && filePath[1] === ':') // Windows drive logic, see QUrl::fromLocalFile()
- path += '/';
- path += filePath;
- if (folders.isFolder(index))
- down(path);
- else
- fileBrowser.selectFile(path)
- }
- width: root.width
- height: folderImage.height
- color: "transparent"
-
- Rectangle {
- id: highlight
- visible: false
- anchors.fill: parent
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- color: "#212121"
- }
-
- Item {
- id: folderImage
- width: itemHeight
- height: itemHeight
- Image {
- id: folderPicture
- source: "qrc:/folder.png"
- width: itemHeight * 0.9
- height: itemHeight * 0.9
- anchors.left: parent.left
- anchors.margins: 5
- visible: folders.isFolder(index)
- }
- }
-
- Text {
- id: nameText
- anchors.fill: parent;
- verticalAlignment: Text.AlignVCenter
- text: fileName
- anchors.leftMargin: itemHeight + 10
- color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor
- elide: Text.ElideRight
- }
-
- MouseArea {
- id: mouseRegion
- anchors.fill: parent
- onPressed: {
- root.showFocusHighlight = false;
- wrapper.ListView.view.currentIndex = index;
- }
- onClicked: { if (folders === wrapper.ListView.view.model) launch() }
- }
-
- states: [
- State {
- name: "pressed"
- when: mouseRegion.pressed
- PropertyChanges { target: highlight; visible: true }
- PropertyChanges { target: nameText; color: palette.highlightedText }
- }
- ]
- }
- }
-
- ListView {
- id: view1
- anchors.top: titleBar.bottom
- anchors.bottom: cancelButton.top
- width: parent.width
- model: folders1
- delegate: folderDelegate
- highlight: Rectangle {
- color: "#212121"
- visible: root.showFocusHighlight && view1.count != 0
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- focus: true
- state: "current"
- states: [
- State {
- name: "current"
- PropertyChanges { target: view1; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view1; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view1; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- ListView {
- id: view2
- anchors.top: titleBar.bottom
- anchors.bottom: parent.bottom
- x: parent.width
- width: parent.width
- model: folders2
- delegate: folderDelegate
- highlight: Rectangle {
- color: "#212121"
- visible: root.showFocusHighlight && view2.count != 0
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- states: [
- State {
- name: "current"
- PropertyChanges { target: view2; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view2; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view2; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- Rectangle {
- width: parent.width
- height: buttonHeight + 10
- anchors.bottom: parent.bottom
- color: "black"
- }
-
- Rectangle {
- id: cancelButton
- width: parent.width
- height: buttonHeight
- color: "#212121"
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 5
- radius: buttonHeight / 15
-
- Text {
- anchors.fill: parent
- text: "Cancel"
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: fileBrowser.selectFile("")
- }
- }
-
- Keys.onPressed: {
- root.keyPressed(event.key);
- if (event.key === Qt.Key_Return || event.key === Qt.Key_Select || event.key === Qt.Key_Right) {
- view.currentItem.launch();
- event.accepted = true;
- } else if (event.key === Qt.Key_Left) {
- up();
- }
- }
-
-
- Rectangle {
- id: titleBar
- width: parent.width
- height: buttonHeight + 10
- anchors.top: parent.top
- color: "black"
-
- Rectangle {
- width: parent.width;
- height: buttonHeight
- color: "#212121"
- anchors.margins: 5
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- radius: buttonHeight / 15
-
- Rectangle {
- id: upButton
- width: buttonHeight
- height: buttonHeight
- color: "transparent"
- Image {
- width: itemHeight
- height: itemHeight
- anchors.centerIn: parent
- source: "qrc:/up.png"
- }
- MouseArea { id: upRegion; anchors.centerIn: parent
- width: buttonHeight
- height: buttonHeight
- onClicked: up()
- }
- states: [
- State {
- name: "pressed"
- when: upRegion.pressed
- PropertyChanges { target: upButton; color: palette.highlight }
- }
- ]
- }
-
- Text {
- anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
- anchors.leftMargin: 5; anchors.rightMargin: 5
- text: folders.folder
- color: "white"
- elide: Text.ElideLeft;
- horizontalAlignment: Text.AlignLeft;
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
-
- function down(path) {
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitLeft";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitLeft";
- }
- view.x = root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function up() {
- var path = folders.parentFolder;
- if (path.toString().length === 0 || path.toString() === 'file:')
- return;
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitRight";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitRight";
- }
- view.x = -root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function keyPressed(key) {
- switch (key) {
- case Qt.Key_Up:
- case Qt.Key_Down:
- case Qt.Key_Left:
- case Qt.Key_Right:
- root.showFocusHighlight = true;
- break;
- default:
- // do nothing
- break;
- }
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
deleted file mode 100644
index 6a3efd4cb..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- color: "black"
- property alias buttonHeight: closeButton.height
- property string source1
- property string source2
- property int contentWidth: parent.width / 2
- property real volume: 0.25
- property int margins: 5
- property QtObject content
-
- signal close
- signal videoFramePainted
-
- Button {
- id: closeButton
- anchors {
- top: parent.top
- right: parent.right
- margins: root.margins
- }
- width: Math.max(parent.width, parent.height) / 12
- height: Math.min(parent.width, parent.height) / 12
- z: 2.0
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- text: "Back"
- onClicked: root.close()
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
deleted file mode 100644
index 7e215cac6..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property string contentType
- property bool autoStart: false
- property bool started: false
-
- Content {
- id: content
- autoStart: parent.autoStart
- started: parent.started
- anchors.fill: parent
- width: parent.contentWidth
- contentType: parent.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: content.started ? "Tap the screen to stop content"
- : "Tap the screen to start content"
- color: "#e0e0e0"
- z: 2.0
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (content.started)
- content.stop()
- else
- content.start()
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml
deleted file mode 100644
index 433afacd3..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Image {
- id: background
- source: "qrc:/images/leaves.jpg"
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
-
- Content {
- id: content
- anchors.centerIn: parent
- width: root.contentWidth
- contentType: root.contentType
- source: root.source1
- volume: root.volume
- onVideoFramePainted: root.videoFramePainted()
- }
- }
-
- MouseArea {
- anchors.fill: parent
- drag.target: background
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml
deleted file mode 100644
index 5fab6e013..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- state: "left"
-
- states: [
- State {
- name: "fullScreen"
- PropertyChanges { target: content; width: content.parent.width }
- PropertyChanges { target: content; height: content.parent.height }
- }
- ]
-
- transitions: [
- Transition {
- ParallelAnimation {
- PropertyAnimation {
- property: "width"
- easing.type: Easing.Linear
- duration: 250
- }
- PropertyAnimation {
- property: "height"
- easing.type: Easing.Linear
- duration: 250
- }
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: content.state = (content.state == "fullScreen") ? "baseState" : "fullScreen"
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: "Tap on the content to toggle full-screen mode"
- color: "#e0e0e0"
- z: 2.0
- }
-
- Component.onCompleted: root.content = content
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml
deleted file mode 100644
index 7a70d8a0f..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.width
- height: parent.height
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- state: "left"
-
- states: [
- State {
- name: "nonFullScreen"
- PropertyChanges { target: content; width: content.parent.contentWidth }
- }
- ]
-
- transitions: [
- Transition {
- ParallelAnimation {
- PropertyAnimation {
- property: "width"
- easing.type: Easing.Linear
- duration: 250
- }
- PropertyAnimation {
- property: "height"
- easing.type: Easing.Linear
- duration: 250
- }
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: content.state = (content.state == "nonFullScreen") ? "baseState" : "nonFullScreen"
- }
-
- onVideoFramePainted: root.videoFramePainted()
-
- onInitialized: {
- width = parent.width
- height = parent.height
- }
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: "Tap on the content to toggle full-screen mode"
- color: "#e0e0e0"
- z: 2.0
- }
-
- Component.onCompleted: root.content = content
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml
deleted file mode 100644
index 45595bbdb..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.verticalCenter: parent.verticalCenter
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- SequentialAnimation on x {
- id: animation
- loops: Animation.Infinite
- property int from: margin
- property int to: 100
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: animation.from
- to: animation.to
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: animation.to
- to: animation.from
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- onWidthChanged: {
- animation.to = root.width - content.width - margin
- animation.start()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml
deleted file mode 100644
index d650cc0f7..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Rectangle {
- id: overlay
- y: 0.5 * parent.height
- width: content.width
- height: content.height
- color: "#e0e0e0"
- opacity: 0.5
-
- SequentialAnimation on x {
- id: xAnimation
- loops: Animation.Infinite
- property int from: margin
- property int to: 100
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: xAnimation.from
- to: xAnimation.to
- duration: xAnimation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: xAnimation.to
- to: xAnimation.from
- duration: xAnimation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- SequentialAnimation on y {
- id: yAnimation
- loops: Animation.Infinite
- property int from: margin
- property int to: 180
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: yAnimation.from
- to: yAnimation.to
- duration: yAnimation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: yAnimation.to
- to: yAnimation.from
- duration: yAnimation.duration
- easing.type: Easing.InOutCubic
- }
- }
- }
-
- onWidthChanged: {
- xAnimation.to = root.width - content.width - margin
- xAnimation.start()
- }
-
- onHeightChanged: {
- //yAnimation.to = root.height - content.height - margin
- yAnimation.start()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml
deleted file mode 100644
index 45331d15d..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- SequentialAnimation on scale {
- id: animation
- loops: Animation.Infinite
- property int duration: 1500
- running: true
- PropertyAnimation {
- from: 1.5
- to: 0.5
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: 0.5
- to: 1.5
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml
deleted file mode 100644
index 4e1363c03..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property int delta: 30
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: rotatePositiveButton
- anchors {
- right: parent.right
- bottom: rotateNegativeButton.top
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Rotate +" + delta
- onClicked: content.rotation = content.rotation + delta
- }
-
- Button {
- id: rotateNegativeButton
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Rotate -" + delta
- onClicked: content.rotation = content.rotation - delta
- }
-
- Button {
- id: rotateValueButton
- anchors {
- left: parent.left
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 25
- height: root.buttonHeight
- enabled: false
- text: content.rotation % 360
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml
deleted file mode 100644
index f8583a983..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- property int itemHeight: 25
- property string sceneSource: ""
-
- ListModel {
- id: videolist
- ListElement { name: "Multi"; source: "SceneMulti.qml" }
- ListElement { name: "Video"; source: "VideoBasic.qml" }
- ListElement { name: "Drag"; source: "VideoDrag.qml" }
- ListElement { name: "Fillmode"; source: "VideoFillMode.qml" }
- ListElement { name: "Fullscreen"; source: "VideoFullScreen.qml" }
- ListElement { name: "Fullscreen-inverted"; source: "VideoFullScreenInverted.qml" }
- ListElement { name: "Metadata"; source: "VideoMetadata.qml" }
- ListElement { name: "Move"; source: "VideoMove.qml" }
- ListElement { name: "Overlay"; source: "VideoOverlay.qml" }
- ListElement { name: "Playback Rate"; source: "VideoPlaybackRate.qml" }
- ListElement { name: "Resize"; source: "VideoResize.qml" }
- ListElement { name: "Rotate"; source: "VideoRotate.qml" }
- ListElement { name: "Spin"; source: "VideoSpin.qml" }
- ListElement { name: "Seek"; source: "VideoSeek.qml" }
- }
-
- ListModel {
- id: cameralist
- ListElement { name: "Camera"; source: "CameraBasic.qml" }
- ListElement { name: "Drag"; source: "CameraDrag.qml" }
- ListElement { name: "Fullscreen"; source: "CameraFullScreen.qml" }
- ListElement { name: "Fullscreen-inverted"; source: "CameraFullScreenInverted.qml" }
- ListElement { name: "Move"; source: "CameraMove.qml" }
- ListElement { name: "Overlay"; source: "CameraOverlay.qml" }
- ListElement { name: "Resize"; source: "CameraResize.qml" }
- ListElement { name: "Rotate"; source: "CameraRotate.qml" }
- ListElement { name: "Spin"; source: "CameraSpin.qml" }
- }
-
- Component {
- id: leftDelegate
- Item {
- width: root.width / 2
- height: 0.8 * itemHeight
-
- Button {
- anchors.fill: parent
- anchors.margins: 5
- anchors.rightMargin: 2.5
- anchors.bottomMargin: 0
- text: name
- onClicked: root.sceneSource = source
- }
- }
- }
-
- Component {
- id: rightDelegate
- Item {
- width: root.width / 2
- height: 0.8 * itemHeight
-
- Button {
- anchors.fill: parent
- anchors.margins: 5
- anchors.leftMargin: 2.5
- anchors.bottomMargin: 0
- text: name
- onClicked: root.sceneSource = source
- }
- }
- }
-
- Flickable {
- anchors.fill: parent
- contentHeight: (itemHeight * videolist.count) + 10
- clip: true
-
- Row {
- id: layout
- anchors {
- fill: parent
- topMargin: 5
- bottomMargin: 5
- }
-
- Column {
- Repeater {
- model: videolist
- delegate: leftDelegate
- }
- }
-
- Column {
- Repeater {
- model: cameralist
- delegate: rightDelegate
- }
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml
deleted file mode 100644
index 14c14df05..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- PropertyAnimation on rotation {
- id: animation
- loops: Animation.Infinite
- running: true
- from: 0
- to: 360
- duration: 3000
- easing.type: Easing.Linear
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
deleted file mode 100644
index fa6f07532..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneBasic {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml
deleted file mode 100644
index 1295c15f2..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneDrag {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml
deleted file mode 100644
index d36f179ee..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-// Item which is loaded by VideoItem if Qt Multimedia is not available
-Rectangle {
- id: root
- color: "grey"
- height: width
- property int duration: 0
- property int position: 0
- property string source
- property real volume: 1.0
- property real playbackRate: 1.0
-
- signal fatalError
- signal sizeChanged
- signal framePainted
-
- Text {
- anchors.fill: parent
- anchors.margins: 10
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- text: "Failed to create Video item\n\nCheck that Qt Multimedia is installed"
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.Wrap
- }
-
- onWidthChanged: height = width
- onHeightChanged: root.sizeChanged()
-
- function start() { }
- function stop() { }
- function seek() { }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml
deleted file mode 100644
index 7fbae4241..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtMultimedia
-
-Scene {
- id: root
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: button
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 5
- height: root.buttonHeight
- text: "PreserveAspectFit"
- onClicked: {
- if (!content.dummy) {
- var video = content.contentItem()
- if (video.fillMode === VideoOutput.Stretch) {
- video.fillMode = VideoOutput.PreserveAspectFit
- text = "PreserveAspectFit"
- } else if (video.fillMode === VideoOutput.PreserveAspectFit) {
- video.fillMode = VideoOutput.PreserveAspectCrop
- text = "PreserveAspectCrop"
- } else {
- video.fillMode = VideoOutput.Stretch
- text = "Stretch"
- }
- }
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml
deleted file mode 100644
index 12973fb15..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneFullScreen {
- contentType: "video"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml
deleted file mode 100644
index 213ae59d1..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneFullScreenInverted {
- contentType: "video"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml
deleted file mode 100644
index 56ee16f0f..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtMultimedia
-
-VideoOutput {
- id: root
- height: width
-
- property alias duration: mediaPlayer.duration
- property alias mediaSource: mediaPlayer.source
- property alias metaData: mediaPlayer.metaData
- property alias playbackRate: mediaPlayer.playbackRate
- property alias position: mediaPlayer.position
- property alias seekable: mediaPlayer.seekable
- property alias volume: audioOutput.volume
-
- signal sizeChanged
- signal fatalError
-
- onHeightChanged: root.sizeChanged()
-
- MediaPlayer {
- id: mediaPlayer
- videoOutput: root;
- audioOutput: AudioOutput {
- id: audioOutput
- }
-
- onErrorOccurred: function(error, errorString) {
- if (MediaPlayer.NoError !== error) {
- console.log("[qmlvideo] VideoItem.onError error " + error + " errorString " + errorString)
- root.fatalError()
- }
- }
- }
-
- function start() { mediaPlayer.play() }
- function stop() { mediaPlayer.stop() }
- function seek(position) { mediaPlayer.setPosition(position); }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml
deleted file mode 100644
index 4af841454..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtMultimedia
-
-Scene {
- id: root
- property string contentType: "video"
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onInitialized: {
- if (!dummy)
- metadata.createObject(root)
- }
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Component {
- id: metadata
- Column {
- anchors.fill: parent
- property var videoMetaData: content.contentItem().metaData
- Text {
- color: "#e0e0e0"
- text: "Title:" + videoMetaData.value(MediaMetaData.Title)
- }
- Text {
- color: "#e0e0e0"
- text: "Size:" + videoMetaData.value(MediaMetaData.Size)
- }
- Text {
- color: "#e0e0e0"
- text: "Resolution:" + videoMetaData.value(MediaMetaData.Resolution)
- }
- Text {
- color: "#e0e0e0"
- text: "Media type:" + videoMetaData.value(MediaMetaData.MediaType)
- }
- Text {
- color: "#e0e0e0"
- text: "Video codec:" + videoMetaData.value(MediaMetaData.VideoCodec)
- }
- Text {
- color: "#e0e0e0"
- text: "Video bit rate:" + videoMetaData.value(MediaMetaData.VideoBitRate)
- }
- Text {
- color: "#e0e0e0"
- text: "Video frame rate:" +videoMetaData.value(MediaMetaData.VideoFrameRate)
- }
- Text {
- color: "#e0e0e0"
- text: "Audio codec:" + videoMetaData.value(MediaMetaData.AudioCodec)
- }
- Text {
- color: "#e0e0e0"
- text: "Audio bit rate:" + videoMetaData.value(MediaMetaData.AudioBitRate)
- }
- Text {
- color: "#e0e0e0"
- text: "Date:" + videoMetaData.value(MediaMetaData.Date)
- }
- Text {
- color: "#e0e0e0"
- text: "Description:" + videoMetaData.value(MediaMetaData.Description)
- }
- Text {
- color: "#e0e0e0"
- text: "Copyright:" + videoMetaData.value(MediaMetaData.Copyright)
- }
- Text {
- color: "#e0e0e0"
- text: "Seekable:" + content.contentItem().seekable
- }
- Text {
- color: "#e0e0e0"
- text: "Orientation:" + videoMetaData.value(MediaMetaData.Orientation)
- }
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml
deleted file mode 100644
index 8fab32a23..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneMove {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml
deleted file mode 100644
index abbefa937..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneOverlay {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml
deleted file mode 100644
index 0fdefc0f4..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property int margin: 20
- property real delta: 0.1
- property string contentType: "video"
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: increaseButton
- anchors {
- right: parent.right
- bottom: decreaseButton.top
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Increase"
- onClicked: {
- var video = content.contentItem()
- video.playbackRate += delta
- }
- }
-
- Button {
- id: decreaseButton
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Decrease"
- onClicked: {
- var video = content.contentItem()
- video.playbackRate -= delta
- }
- }
-
- Button {
- id: valueButton
- anchors {
- left: parent.left
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 25
- height: root.buttonHeight
- enabled: false
- text: Math.round(10 * content.contentItem().playbackRate) / 10
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml
deleted file mode 100644
index 85961ea36..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneResize {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml
deleted file mode 100644
index 1406ccdea..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneRotate {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml
deleted file mode 100644
index f17fa0a5c..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Scene {
- id: root
- property string contentType: "video"
- contentWidth: parent.width
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- SeekControl {
- anchors {
- left: parent.left
- right: parent.right
- margins: 10
- bottom: parent.bottom
- }
- duration: content.contentItem() ? content.contentItem().duration : 0
- playPosition: content.contentItem() ? content.contentItem().position : 0
- onSeekPositionChanged: content.contentItem().seek(seekPosition);
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml
deleted file mode 100644
index 7c8b2e84f..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-SceneSpin {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml
deleted file mode 100644
index 4289f79f1..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-
-Rectangle {
- id: root
- anchors.fill: parent
- color: "black"
-
- property string source1
- property string source2
- property color bgColor: "black"
- property real volume: 0.25
- property bool perfMonitorsLogging: false
- property bool perfMonitorsVisible: false
-
- QtObject {
- id: d
- property int itemHeight: root.height > root.width ? root.width / 10 : root.height / 10
- property int buttonHeight: 0.8 * itemHeight
- property int margins: 5
- }
-
- Loader {
- id: performanceLoader
-
- Connections {
- target: inner
- function onVisibleChanged() {
- if (performanceLoader.item)
- performanceLoader.item.enabled = !inner.visible
- }
- ignoreUnknownSignals: true
- }
-
- function init() {
- var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
- source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
- }
-
- onLoaded: {
- item.parent = root
- item.anchors.fill = root
- item.logging = root.perfMonitorsLogging
- item.displayed = root.perfMonitorsVisible
- item.enabled = false
- item.init()
- }
- }
-
- Rectangle {
- id: inner
- anchors.fill: parent
- color: root.bgColor
-
- Button {
- id: openFile1Button
- anchors {
- top: parent.top
- left: parent.left
- right: exitButton.left
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- height: d.buttonHeight
- text: (root.source1 == "") ? "Select file 1" : root.source1
- onClicked: fileBrowser1.show()
- }
-
- Button {
- id: openFile2Button
- anchors {
- top: openFile1Button.bottom
- left: parent.left
- right: exitButton.left
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- height: d.buttonHeight
- text: (root.source2 == "") ? "Select file 2" : root.source2
- onClicked: fileBrowser2.show()
- }
-
- Button {
- id: exitButton
- anchors {
- top: parent.top
- right: parent.right
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- width: parent.width / 10
- height: d.buttonHeight
- text: "Exit"
- onClicked: Qt.quit()
- }
-
- Row {
- id: modes
- anchors.top: openFile2Button.bottom
- anchors.margins: 0
- anchors.topMargin: 5
- Button {
- width: root.width / 2
- height: 0.8 * d.itemHeight
- bgColor: "#212121"
- radius: 0
- text: "Video Modes"
- enabled: false
- }
- Button {
- width: root.width / 2
- height: 0.8 * d.itemHeight
- bgColor: "#212121"
- radius: 0
- text: "Camera Modes"
- enabled: false
- }
- }
-
- Rectangle {
- id: divider
- height: 1
- width: parent.width
- color: "black"
- anchors.top: modes.bottom
- }
-
- SceneSelectionPanel {
- id: sceneSelectionPanel
- itemHeight: d.itemHeight
- color: "#212121"
- anchors {
- top: divider.bottom
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
- radius: 0
- onSceneSourceChanged: {
- sceneLoader.source = sceneSource
- var scene = null
- var innerVisible = true
- if (sceneSource == "") {
- if (performanceLoader.item)
- performanceLoader.item.videoActive = false
- } else {
- scene = sceneLoader.item
- if (scene) {
- if (scene.contentType === "video" && source1 === "") {
- errorDialog.show("You must first select a video file")
- sceneSource = ""
- } else {
- scene.parent = root
- scene.color = root.bgColor
- scene.buttonHeight = d.buttonHeight
- scene.source1 = source1
- scene.source2 = source2
- scene.volume = volume
- scene.anchors.fill = root
- scene.close.connect(closeScene)
- scene.content.initialize()
- innerVisible = false
- }
- }
- }
- videoFramePaintedConnection.target = scene
- inner.visible = innerVisible
- }
- }
- }
-
- Loader {
- id: sceneLoader
- }
-
- Connections {
- id: videoFramePaintedConnection
- function onVideoFramePainted() {
- if (performanceLoader.item)
- performanceLoader.item.videoFramePainted()
- }
- ignoreUnknownSignals: true
- }
-
- FileBrowser {
- id: fileBrowser1
- anchors.fill: root
- onFolderChanged: fileBrowser2.folder = folder
- Component.onCompleted: fileSelected.connect(root.openFile1)
- }
-
- FileBrowser {
- id: fileBrowser2
- anchors.fill: root
- onFolderChanged: fileBrowser1.folder = folder
- Component.onCompleted: fileSelected.connect(root.openFile2)
- }
-
- function openFile1(path) {
- root.source1 = path
- }
-
- function openFile2(path) {
- root.source2 = path
- }
-
- ErrorDialog {
- id: errorDialog
- anchors.fill: root
- dialogWidth: d.itemHeight * 5
- dialogHeight: d.itemHeight * 3
- enabled: false
- }
-
- // Called from main() once root properties have been set
- function init() {
- performanceLoader.init()
- fileBrowser1.folder = videoPath
- fileBrowser2.folder = videoPath
- }
-
- function qmlFramePainted() {
- if (performanceLoader.item)
- performanceLoader.item.qmlFramePainted()
- }
-
- function closeScene() {
- sceneSelectionPanel.sceneSource = ""
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro
index 7a6bbccff..b61339264 100644
--- a/examples/multimedia/video/qmlvideo/qmlvideo.pro
+++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro
@@ -12,73 +12,84 @@ DEFINES += \
PERFORMANCEMONITOR_SUPPORT
SOURCES += \
- main.cpp \
frequencymonitor.cpp \
frequencymonitordeclarative.cpp \
+ main.cpp \
performancemonitor.cpp \
- performancemonitordeclarative.cpp
+ performancemonitordeclarative.cpp \
+ qmlvideo/videosingleton.cpp
+
+INCLUDEPATH += qmlvideo
+
+DEFINES += QMLVIDEO_LIB
HEADERS += \
- trace.h \
frequencymonitor.h \
performancemonitor.h \
- performancemonitordeclarative.h
+ performancemonitordeclarative.h \
+ trace.h \
+ qmlvideo/videosingleton.h
resources.files = \
- images/folder.png \
- images/leaves.jpg \
- images/up.png \
- qml/frequencymonitor/FrequencyItem.qml \
- qml/performancemonitor/PerformanceItem.qml \
- qml/qmlvideo/Button.qml \
- qml/qmlvideo/CameraBasic.qml \
- qml/qmlvideo/CameraDrag.qml \
- qml/qmlvideo/CameraDummy.qml \
- qml/qmlvideo/CameraFullScreen.qml \
- qml/qmlvideo/CameraFullScreenInverted.qml \
- qml/qmlvideo/CameraItem.qml \
- qml/qmlvideo/CameraMove.qml \
- qml/qmlvideo/CameraOverlay.qml \
- qml/qmlvideo/CameraResize.qml \
- qml/qmlvideo/CameraRotate.qml \
- qml/qmlvideo/CameraSpin.qml \
- qml/qmlvideo/Content.qml \
- qml/qmlvideo/ErrorDialog.qml \
- qml/qmlvideo/FileBrowser.qml \
- qml/qmlvideo/Scene.qml \
- qml/qmlvideo/SceneBasic.qml \
- qml/qmlvideo/SceneDrag.qml \
- qml/qmlvideo/SceneFullScreen.qml \
- qml/qmlvideo/SceneFullScreenInverted.qml \
- qml/qmlvideo/SceneMove.qml \
- qml/qmlvideo/SceneMulti.qml \
- qml/qmlvideo/SceneOverlay.qml \
- qml/qmlvideo/SceneResize.qml \
- qml/qmlvideo/SceneRotate.qml \
- qml/qmlvideo/SceneSelectionPanel.qml \
- qml/qmlvideo/SceneSpin.qml \
- qml/qmlvideo/SeekControl.qml \
- qml/qmlvideo/VideoBasic.qml \
- qml/qmlvideo/VideoDrag.qml \
- qml/qmlvideo/VideoDummy.qml \
- qml/qmlvideo/VideoFillMode.qml \
- qml/qmlvideo/VideoFullScreen.qml \
- qml/qmlvideo/VideoFullScreenInverted.qml \
- qml/qmlvideo/VideoItem.qml \
- qml/qmlvideo/VideoMetadata.qml \
- qml/qmlvideo/VideoMove.qml \
- qml/qmlvideo/VideoOverlay.qml \
- qml/qmlvideo/VideoPlaybackRate.qml \
- qml/qmlvideo/VideoResize.qml \
- qml/qmlvideo/VideoRotate.qml \
- qml/qmlvideo/VideoSeek.qml \
- qml/qmlvideo/VideoSpin.qml \
- qml/qmlvideo/main.qml
+ frequencymonitor/FrequencyItem.qml \
+ frequencymonitor/qmldir \
+ performancemonitor/PerformanceItem.qml \
+ performancemonitor/qmldir \
+ qmlvideo/CameraBasic.qml \
+ qmlvideo/CameraDrag.qml \
+ qmlvideo/CameraDummy.qml \
+ qmlvideo/CameraFullScreen.qml \
+ qmlvideo/CameraFullScreenInverted.qml \
+ qmlvideo/CameraItem.qml \
+ qmlvideo/CameraMove.qml \
+ qmlvideo/CameraOverlay.qml \
+ qmlvideo/CameraResize.qml \
+ qmlvideo/CameraRotate.qml \
+ qmlvideo/CameraSpin.qml \
+ qmlvideo/Content.qml \
+ qmlvideo/ErrorDialog.qml \
+ qmlvideo/Main.qml \
+ qmlvideo/Scene.qml \
+ qmlvideo/SceneBasic.qml \
+ qmlvideo/SceneDrag.qml \
+ qmlvideo/SceneFullScreen.qml \
+ qmlvideo/SceneFullScreenInverted.qml \
+ qmlvideo/SceneMove.qml \
+ qmlvideo/SceneMulti.qml \
+ qmlvideo/SceneOverlay.qml \
+ qmlvideo/SceneResize.qml \
+ qmlvideo/SceneRotate.qml \
+ qmlvideo/SceneSelectionPanel.qml \
+ qmlvideo/SceneSpin.qml \
+ qmlvideo/SeekControl.qml \
+ qmlvideo/VideoBasic.qml \
+ qmlvideo/VideoDrag.qml \
+ qmlvideo/VideoDummy.qml \
+ qmlvideo/VideoFillMode.qml \
+ qmlvideo/VideoFullScreen.qml \
+ qmlvideo/VideoFullScreenInverted.qml \
+ qmlvideo/VideoItem.qml \
+ qmlvideo/VideoMetadata.qml \
+ qmlvideo/VideoMove.qml \
+ qmlvideo/VideoOverlay.qml \
+ qmlvideo/VideoPlaybackRate.qml \
+ qmlvideo/VideoResize.qml \
+ qmlvideo/VideoRotate.qml \
+ qmlvideo/VideoSeek.qml \
+ qmlvideo/VideoSpin.qml \
+ qmlvideo/images/folder.png \
+ qmlvideo/images/leaves.jpg \
+ qmlvideo/images/up.png \
+ qmlvideo/qmldir
-resources.prefix = /
+resources.prefix = /qt/qml/
RESOURCES += resources
+CONFIG += qmltypes
+QML_IMPORT_NAME = qmlvideo
+QML_IMPORT_MAJOR_VERSION = 1
+
target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideo
INSTALLS += target
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt
new file mode 100644
index 000000000..84a65710e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt
@@ -0,0 +1,81 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/qmlvideo")
+
+qt_add_qml_module(qmlvideo
+ URI qmlvideo
+ SOURCES
+ videosingleton.cpp
+ videosingleton.h
+ qmlvideo_global.h
+ QML_FILES
+ "CameraBasic.qml"
+ "CameraDrag.qml"
+ "CameraDummy.qml"
+ "CameraFullScreen.qml"
+ "CameraFullScreenInverted.qml"
+ "CameraItem.qml"
+ "CameraMove.qml"
+ "CameraOverlay.qml"
+ "CameraResize.qml"
+ "CameraRotate.qml"
+ "CameraSpin.qml"
+ "Content.qml"
+ "ErrorDialog.qml"
+ "Main.qml"
+ "Scene.qml"
+ "SceneBasic.qml"
+ "SceneDrag.qml"
+ "SceneFullScreen.qml"
+ "SceneFullScreenInverted.qml"
+ "SceneMove.qml"
+ "SceneMulti.qml"
+ "SceneOverlay.qml"
+ "SceneResize.qml"
+ "SceneRotate.qml"
+ "SceneSelectionPanel.qml"
+ "SceneSpin.qml"
+ "SeekControl.qml"
+ "VideoBasic.qml"
+ "VideoDrag.qml"
+ "VideoDummy.qml"
+ "VideoFillMode.qml"
+ "VideoFullScreen.qml"
+ "VideoFullScreenInverted.qml"
+ "VideoItem.qml"
+ "VideoMetadata.qml"
+ "VideoMove.qml"
+ "VideoOverlay.qml"
+ "VideoPlaybackRate.qml"
+ "VideoResize.qml"
+ "VideoRotate.qml"
+ "VideoSeek.qml"
+ "VideoSpin.qml"
+ RESOURCES
+ "images/folder.png"
+ "images/leaves.jpg"
+ "images/up.png"
+)
+
+target_compile_definitions(qmlvideo PRIVATE QMLVIDEO_LIB)
+
+target_link_libraries(qmlvideo PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS qmlvideo
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml
new file mode 100644
index 000000000..77072c6c9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneBasic {
+ contentType: "camera"
+ started: true
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml
new file mode 100644
index 000000000..2ea3672c6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneDrag {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml
new file mode 100644
index 000000000..c9d14e595
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+// Item which is loaded by CameraItem if Qt Multimedia is not available
+Rectangle {
+ id: root
+ color: "grey"
+ height: width
+
+ signal fatalError
+ signal sizeChanged
+ signal framePainted
+
+ Label {
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Failed to create Camera item\n\nCheck that Qt Multimedia is installed")
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.Wrap
+ }
+
+ onWidthChanged: height = width
+ onHeightChanged: root.sizeChanged()
+
+ function start() { }
+ function stop() { }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml
new file mode 100644
index 000000000..b204e74ab
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreen {
+ contentType: "camera"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml
new file mode 100644
index 000000000..ff7a40253
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreenInverted {
+ contentType: "camera"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml
new file mode 100644
index 000000000..d6e4b85b5
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+
+Item {
+ id: root
+ height: width
+
+ signal fatalError
+ signal sizeChanged
+
+ onHeightChanged: root.sizeChanged()
+
+ CaptureSession {
+ camera: Camera {
+ id: camera
+
+ onErrorOccurred: function(error, errorString) {
+ if (Camera.NoError !== error) {
+ console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
+ root.fatalError()
+ }
+ }
+ }
+ imageCapture: ImageCapture {
+ id: imageCapture
+ }
+
+ recorder: MediaRecorder {
+ id: recorder
+// resolution: "640x480"
+// frameRate: 30
+ }
+ videoOutput: videoOutput
+ }
+
+ VideoOutput {
+ id: videoOutput
+ anchors.fill: parent
+ }
+
+
+ function start() { camera.start() }
+ function stop() { camera.stop() }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml
new file mode 100644
index 000000000..c4c5da914
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneMove {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml
new file mode 100644
index 000000000..13136be00
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneOverlay {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml
new file mode 100644
index 000000000..d89eef3ad
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneResize {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml
new file mode 100644
index 000000000..8394fb6fd
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneRotate {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml
new file mode 100644
index 000000000..642a0edfd
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneSpin {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml
new file mode 100644
index 000000000..b08d19325
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml
@@ -0,0 +1,125 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import frequencymonitor
+
+Rectangle {
+ id: root
+ border.color: palette.window
+ border.width: showBorder ? 1 : 0
+ color: "transparent"
+ property string contentType // "camera" or "video"
+ property string source
+ property real volume
+ property bool dummy: false
+ property bool autoStart: true
+ property bool started: false
+ property bool showFrameRate: false
+ property bool showBorder: false
+ property alias contentItem: contentLoader.item
+
+ signal initialized
+ signal error
+ signal videoFramePainted
+
+ Loader {
+ id: contentLoader
+ }
+
+ Connections {
+ id: framePaintedConnection
+ function onFramePainted() {
+ (frameRateLoader.item as FrequencyItem)?.notify()
+ root.videoFramePainted()
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Connections {
+ id: errorConnection
+ function onFatalError() {
+ console.log("[qmlvideo] Content.onFatalError")
+ root.stop()
+ root.error()
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Component {
+ id: frequencyItem
+ FrequencyItem {}
+ }
+
+ Loader {
+ id: frameRateLoader
+ sourceComponent: root.showFrameRate ? frequencyItem : undefined
+ onLoaded: {
+ item.parent = root
+ item.anchors.top = root.top
+ item.anchors.right = root.right
+ item.anchors.margins = 10
+ }
+ }
+
+ onWidthChanged: {
+ if (root.contentItem)
+ root.contentItem.width = width
+ }
+
+ onHeightChanged: {
+ if (root.contentItem)
+ root.contentItem.height = height
+ }
+
+ function initialize() {
+ if ("video" == contentType) {
+ contentLoader.source = "VideoItem.qml"
+ if (Loader.Error == contentLoader.status) {
+ contentLoader.source = "VideoDummy.qml"
+ dummy = true
+ }
+ contentLoader.item.volume = volume
+ } else if ("camera" == contentType) {
+ contentLoader.source = "CameraItem.qml"
+ if (Loader.Error == contentLoader.status) {
+ contentLoader.source = "CameraDummy.qml"
+ dummy = true
+ }
+ } else {
+ console.log("[qmlvideo] Content.initialize: error: invalid contentType")
+ }
+ if (contentLoader.item) {
+ contentLoader.item.sizeChanged.connect(updateRootSize)
+ contentLoader.item.parent = root
+ contentLoader.item.width = root.width
+ framePaintedConnection.target = contentLoader.item
+ errorConnection.target = contentLoader.item
+ if (root.autoStart)
+ root.start()
+ }
+ root.initialized()
+ }
+
+ function start() {
+ if (contentLoader.item) {
+ if (root.contentType == "video")
+ contentLoader.item.mediaSource = root.source
+ contentLoader.item.start()
+ root.started = true
+ }
+ }
+
+ // qmllint disable
+ function stop() {
+ if (contentLoader.item) {
+ contentLoader.item.stop()
+ if (root.contentType == "video")
+ contentLoader.item.mediaSource = ""
+ root.started = false
+ }
+ }
+ // qmllint enable
+
+ function updateRootSize() { root.height = (root.contentItem as Item).height }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml b/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml
new file mode 100644
index 000000000..f06079a35
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: root
+ color: "transparent"
+ opacity: 0.0
+ property alias enabled: mouseArea.enabled
+ property int dialogWidth: 300
+ property int dialogHeight: 200
+ state: enabled ? "on" : "baseState"
+
+ states: [
+ State {
+ name: "on"
+ PropertyChanges {
+ root.opacity: 1.0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ easing.type: Easing.OutQuart
+ duration: 500
+ }
+ }
+ ]
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ opacity: 0.75
+ }
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: root.dialogWidth
+ height: root.dialogHeight
+ radius: 5
+ color: "white"
+
+ Text {
+ id: text
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "black"
+ wrapMode: Text.WordWrap
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: root.enabled = false
+ }
+
+ function show(msg) {
+ text.text = "<b>Error</b><br><br>" + msg
+ root.enabled = true
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml
new file mode 100644
index 000000000..49b94590c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml
@@ -0,0 +1,188 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtQuick.Dialogs
+import performancemonitor
+
+Rectangle {
+ id: root
+ anchors.fill: parent
+ color: palette.window
+
+ property bool perfMonitorsLogging: false
+ property bool perfMonitorsVisible: false
+
+ Loader {
+ id: performanceLoader
+
+ Connections {
+ target: columnLayout
+ function onVisibleChanged() {
+ if (performanceLoader.item)
+ performanceLoader.item.enabled = !columnLayout.visible
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Component {
+ id: performanceItem
+ PerformanceItem {}
+ }
+
+ function init() {
+ var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
+ sourceComponent = enabled ? performanceItem : undefined
+ }
+
+ onLoaded: {
+ item.parent = root
+ item.anchors.fill = root
+ item.logging = root.perfMonitorsLogging
+ item.displayed = root.perfMonitorsVisible
+ item.enabled = false
+ item.init()
+ }
+ }
+
+ ColumnLayout {
+ id: columnLayout
+ anchors.fill: parent
+ spacing: 5
+
+ Button {
+ id: openFile1Button
+ text: (VideoSingleton.source1 == '') ? qsTr("Select file 1") : VideoSingleton.source1
+ Component.onCompleted: console.log("source1: " + VideoSingleton.source1)
+ onClicked: {
+ fileDialog.setFirstSource = true
+ fileDialog.open()
+ }
+
+ Layout.fillWidth: true
+ }
+
+ Button {
+ id: openFile2Button
+ text: (VideoSingleton.source2 == '') ? qsTr("Select file 2") : VideoSingleton.source2
+ Component.onCompleted: console.log("source2: " + VideoSingleton.source2)
+ onClicked: {
+ fileDialog.setFirstSource = false
+ fileDialog.open()
+ }
+
+ Layout.fillWidth: true
+ }
+
+ RowLayout {
+ Layout.fillWidth: true
+
+ Label {
+ text: qsTr("Video Modes")
+
+ horizontalAlignment: Qt.AlignHCenter
+ Layout.preferredWidth: 50
+ Layout.fillWidth: true
+ }
+ Label {
+ text: qsTr("Camera Modes")
+
+ horizontalAlignment: Qt.AlignHCenter
+ Layout.preferredWidth: 50
+ Layout.fillWidth: true
+ }
+ }
+
+ SceneSelectionPanel {
+ id: sceneSelectionPanel
+ itemHeight: Math.min(width / 10, height / 10)
+ color: palette.dark
+ radius: 0
+ onSceneSourceChanged: {
+ sceneLoader.source = sceneSource
+ var scene = null
+ var innerVisible = true
+ if (sceneSource == "") {
+ if (performanceLoader.item)
+ performanceLoader.item.videoActive = false
+ } else {
+ scene = sceneLoader.item
+ if (scene) {
+ if (scene.contentType === "video" && VideoSingleton.source1 === "") {
+ errorDialog.show(qsTr("You must first select a video file"))
+ sceneSource = ""
+ } else {
+ scene.parent = root
+ scene.color = root.palette.window
+ scene.source1 = VideoSingleton.source1
+ scene.source2 = VideoSingleton.source2
+ scene.volume = VideoSingleton.volume
+ scene.anchors.fill = root
+ scene.close.connect(closeScene)
+ scene.content.initialize()
+ innerVisible = false
+ }
+ }
+ }
+ videoFramePaintedConnection.target = scene
+ columnLayout.visible = innerVisible
+ }
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+
+ Loader {
+ id: sceneLoader
+ }
+
+ Connections {
+ id: videoFramePaintedConnection
+ // qmllint disable
+ function onVideoFramePainted() {
+ if (performanceLoader.item)
+ performanceLoader.item.videoFramePainted()
+ }
+ // qmllint enable
+ ignoreUnknownSignals: true
+ }
+
+ FileDialog {
+ id: fileDialog
+ property bool setFirstSource
+ onAccepted: function() {
+ if (setFirstSource)
+ VideoSingleton.source1 = selectedFile
+ else
+ VideoSingleton.source2 = selectedFile
+ }
+ }
+
+ ErrorDialog {
+ id: errorDialog
+ anchors.fill: root
+ dialogWidth: Math.min(root.width, root.height) * 0.5
+ dialogHeight: Math.min(root.width, root.height) * 0.3
+ enabled: false
+ }
+
+ // Called from main() once root properties have been set
+ function init() {
+ performanceLoader.init()
+ fileDialog.currentFolder = VideoSingleton.videoPath
+ }
+
+ // qmllint disable
+ function qmlFramePainted() {
+ if (performanceLoader.item)
+ performanceLoader.item.qmlFramePainted()
+ }
+ // qmllint enable
+
+ function closeScene() {
+ sceneSelectionPanel.sceneSource = ""
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml
new file mode 100644
index 000000000..e16478d41
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Rectangle {
+ id: root
+ color: palette.window
+ property string source1
+ property string source2
+ property int contentWidth: parent.width / 2
+ property real volume: 0.25
+ property int margins: 5
+ property QtObject content
+
+ signal close
+ signal videoFramePainted
+
+ Button {
+ id: closeButton
+ anchors {
+ top: parent.top
+ right: parent.right
+ margins: root.margins
+ }
+ z: 2.0
+ text: qsTr("Back")
+ onClicked: root.close()
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml
new file mode 100644
index 000000000..8ad6c99b8
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+ property bool autoStart: false
+ property bool started: false
+
+ Content {
+ id: content
+ autoStart: parent.autoStart
+ started: parent.started
+ anchors.fill: parent
+ width: parent.contentWidth
+ contentType: parent.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: content.started ? qsTr("Tap the screen to stop content")
+ : qsTr("Tap the screen to start content")
+ z: 2.0
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (content.started)
+ content.stop()
+ else
+ content.start()
+ }
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml
new file mode 100644
index 000000000..99a7cb7f1
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Image {
+ id: background
+ source: "images/leaves.jpg"
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: root.contentWidth
+ contentType: root.contentType
+ source: root.source1
+ volume: root.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: background
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml
new file mode 100644
index 000000000..ec8564311
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ state: "left"
+
+ states: [
+ State {
+ name: "fullScreen"
+ PropertyChanges {
+ content.width: content.parent.width
+ content.height: content.parent.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParallelAnimation {
+ PropertyAnimation {
+ property: "width"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ PropertyAnimation {
+ property: "height"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ }
+ }
+ ]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: content.state = (content.state == "fullScreen") ? "baseState" : "fullScreen"
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: qsTr("Tap on the content to toggle full-screen mode")
+ z: 2.0
+ }
+
+ Component.onCompleted: root.content = content
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml
new file mode 100644
index 000000000..cb96ac134
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.width
+ height: parent.height
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ state: "left"
+
+ states: [
+ State {
+ name: "nonFullScreen"
+ PropertyChanges { content.width: root.contentWidth }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParallelAnimation {
+ PropertyAnimation {
+ property: "width"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ PropertyAnimation {
+ property: "height"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ }
+ }
+ ]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: content.state = (content.state === "nonFullScreen") ? "baseState" : "nonFullScreen"
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+
+ onInitialized: {
+ width = parent.width
+ height = parent.height
+ }
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: qsTr("Tap on the content to toggle full-screen mode")
+ z: 2.0
+ }
+
+ Component.onCompleted: root.content = content
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml
new file mode 100644
index 000000000..d1512831e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ SequentialAnimation on x {
+ id: animation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 100
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: animation.from
+ to: animation.to
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: animation.to
+ to: animation.from
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ onWidthChanged: {
+ animation.to = root.width - content.width - margin
+ animation.start()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml
index f06c187e4..f93dabcdd 100644
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
+import QtQuick.Controls
Scene {
id: root
@@ -71,28 +25,30 @@ Scene {
id: root
color: "transparent"
- function content() {
- return root.parent
- }
+ signal start
+ signal stop
- Text {
+ Label {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
margins: 20
}
- text: content() ? content().started ? "Tap to stop" : "Tap to start" : ""
- color: "#e0e0e0"
+ // qmllint disable
+ text: root.started ? qsTr("Tap to stop") : qsTr("Tap to start")
+ // qmllint enable
}
MouseArea {
anchors.fill: parent
+ // qmllint disable
onClicked: {
- if (content().started)
- content().stop()
+ if (root.started)
+ root.stop()
else
- content().start()
+ root.start()
}
+ // qmllint enable
}
}
}
@@ -110,14 +66,19 @@ Scene {
showBorder: true
showFrameRate: started
source: parent.source1
- width: itemWidth
+ width: root.itemWidth
volume: parent.volume
Loader {
id: video1StartStopLoader
+
+ property bool started: parent.started
+
onLoaded: {
item.parent = video1
item.anchors.fill = video1
+ item.start.connect(video1.start)
+ item.stop.connect(video1.stop)
}
}
@@ -126,26 +87,28 @@ Scene {
Rectangle {
id: cameraHolder
+
+ property bool started: false
+
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: root.itemTopMargin
}
border.width: 1
- border.color: "white"
+ border.color: palette.base
color: "transparent"
- width: itemWidth
+ width: root.itemWidth
height: width
- property bool started: false
Loader {
id: cameraLoader
onLoaded: {
item.parent = cameraHolder
- item.centerIn = cameraHolder
+ item.anchors.centerIn = cameraHolder
item.contentType = "camera"
item.showFrameRate = true
- item.width = itemWidth
+ item.width = root.itemWidth
item.z = 1.0
cameraErrorConnection.target = item
item.initialize()
@@ -154,20 +117,26 @@ Scene {
Loader {
id: cameraStartStopLoader
+
+ property bool started: parent.started
+
sourceComponent: startStopComponent
onLoaded: {
item.parent = cameraHolder
item.anchors.fill = cameraHolder
item.z = 2.0
+ item.start.connect(cameraHolder.start)
+ item.stop.connect(cameraHolder.stop)
}
}
Connections {
id: cameraErrorConnection
- onError: {
+ function onError() {
console.log("[qmlvideo] SceneMulti.camera.onError")
cameraHolder.stop()
}
+ ignoreUnknownSignals: true
}
function start() {
@@ -194,14 +163,19 @@ Scene {
showBorder: true
showFrameRate: started
source: parent.source2
- width: itemWidth
+ width: root.itemWidth
volume: parent.volume
Loader {
id: video2StartStopLoader
+
+ property bool started: parent.started
+
onLoaded: {
item.parent = video2
item.anchors.fill = video2
+ item.start.connect(video2.start)
+ item.stop.connect(video2.stop)
}
}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml
new file mode 100644
index 000000000..5863d618c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml
@@ -0,0 +1,83 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Rectangle {
+ id: overlay
+ y: 0.5 * parent.height
+ width: content.width
+ height: content.height
+ color: "#e0e0e0"
+ opacity: 0.5
+
+ SequentialAnimation on x {
+ id: xAnimation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 100
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: xAnimation.from
+ to: xAnimation.to
+ duration: xAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: xAnimation.to
+ to: xAnimation.from
+ duration: xAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ SequentialAnimation on y {
+ id: yAnimation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 180
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: yAnimation.from
+ to: yAnimation.to
+ duration: yAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: yAnimation.to
+ to: yAnimation.from
+ duration: yAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+ }
+
+ onWidthChanged: {
+ xAnimation.to = root.width - content.width - margin
+ xAnimation.start()
+ }
+
+ onHeightChanged: {
+ //yAnimation.to = root.height - content.height - margin
+ yAnimation.start()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml
new file mode 100644
index 000000000..4e2f15588
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ SequentialAnimation on scale {
+ id: animation
+ loops: Animation.Infinite
+ property int duration: 1500
+ running: true
+ PropertyAnimation {
+ from: 1.5
+ to: 0.5
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: 0.5
+ to: 1.5
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml
new file mode 100644
index 000000000..1362522e6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property int margin: 20
+ property int delta: 30
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: rotatePositiveButton
+ anchors {
+ right: parent.right
+ bottom: rotateNegativeButton.top
+ margins: parent.margins
+ }
+ text: qsTr("Rotate +%1").arg(root.delta)
+ onClicked: content.rotation = content.rotation + root.delta
+ }
+
+ Button {
+ id: rotateNegativeButton
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("Rotate -%1").arg(root.delta)
+ onClicked: content.rotation = content.rotation - root.delta
+ }
+
+ Button {
+ id: rotateValueButton
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ enabled: false
+ text: content.rotation % 360
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml
new file mode 100644
index 000000000..91e7c6ad4
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml
@@ -0,0 +1,88 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+pragma ComponentBehavior: Bound
+
+Rectangle {
+ id: root
+ property int itemHeight: 25
+ property string sceneSource: ""
+
+ ListModel {
+ id: videolist
+ ListElement { name: qsTr("Multi"); source: "SceneMulti.qml" }
+ ListElement { name: qsTr("Video"); source: "VideoBasic.qml" }
+ ListElement { name: qsTr("Drag"); source: "VideoDrag.qml" }
+ ListElement { name: qsTr("Fillmode"); source: "VideoFillMode.qml" }
+ ListElement { name: qsTr("Fullscreen"); source: "VideoFullScreen.qml" }
+ ListElement { name: qsTr("Fullscreen-inverted"); source: "VideoFullScreenInverted.qml" }
+ ListElement { name: qsTr("Metadata"); source: "VideoMetadata.qml" }
+ ListElement { name: qsTr("Move"); source: "VideoMove.qml" }
+ ListElement { name: qsTr("Overlay"); source: "VideoOverlay.qml" }
+ ListElement { name: qsTr("Playback Rate"); source: "VideoPlaybackRate.qml" }
+ ListElement { name: qsTr("Resize"); source: "VideoResize.qml" }
+ ListElement { name: qsTr("Rotate"); source: "VideoRotate.qml" }
+ ListElement { name: qsTr("Spin"); source: "VideoSpin.qml" }
+ ListElement { name: qsTr("Seek"); source: "VideoSeek.qml" }
+ }
+
+ ListModel {
+ id: cameralist
+ ListElement { name: qsTr("Camera"); source: "CameraBasic.qml" }
+ ListElement { name: qsTr("Drag"); source: "CameraDrag.qml" }
+ ListElement { name: qsTr("Fullscreen"); source: "CameraFullScreen.qml" }
+ ListElement { name: qsTr("Fullscreen-inverted"); source: "CameraFullScreenInverted.qml" }
+ ListElement { name: qsTr("Move"); source: "CameraMove.qml" }
+ ListElement { name: qsTr("Overlay"); source: "CameraOverlay.qml" }
+ ListElement { name: qsTr("Resize"); source: "CameraResize.qml" }
+ ListElement { name: qsTr("Rotate"); source: "CameraRotate.qml" }
+ ListElement { name: qsTr("Spin"); source: "CameraSpin.qml" }
+ }
+
+ Component {
+ id: buttonDelegate
+ Button {
+ required property string name
+ required property string source
+
+ width: root.width / 2
+ height: root.itemHeight
+
+ text: name
+ padding: 3
+ onClicked: root.sceneSource = source
+ }
+ }
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: (root.itemHeight * videolist.count) + 10
+ clip: true
+
+ Row {
+ id: layout
+ anchors {
+ fill: parent
+ topMargin: 5
+ bottomMargin: 5
+ }
+
+ Column {
+ Repeater {
+ model: videolist
+ delegate: buttonDelegate
+ }
+ }
+
+ Column {
+ Repeater {
+ model: cameralist
+ delegate: buttonDelegate
+ }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml
new file mode 100644
index 000000000..3e280d3b1
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ PropertyAnimation on rotation {
+ id: animation
+ loops: Animation.Infinite
+ running: true
+ from: 0
+ to: 360
+ duration: 3000
+ easing.type: Easing.Linear
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml
index b5bb804da..646e5e8ef 100644
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
@@ -62,7 +15,7 @@ Item {
Rectangle {
id: background
anchors.fill: parent
- color: "white"
+ color: palette.base
opacity: 0.3
radius: parent.height / 15
}
@@ -71,7 +24,7 @@ Item {
id: progressBar
anchors { left: parent.left; top: parent.top; bottom: parent.bottom }
width: seekControl.duration == 0 ? 0 : background.width * seekControl.playPosition / seekControl.duration
- color: "black"
+ color: palette.highlight
opacity: 0.7
}
@@ -80,9 +33,9 @@ Item {
anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 10 }
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
- color: "white"
+ color: palette.windowText
smooth: true
- text: formatTime(playPosition)
+ text: seekControl.formatTime(seekControl.playPosition)
}
Text {
@@ -90,16 +43,16 @@ Item {
anchors { right: parent.right; top: parent.top; bottom: parent.bottom; rightMargin: 10 }
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
- color: "white"
+ color: palette.windowText
smooth: true
- text: formatTime(duration)
+ text: seekControl.formatTime(seekControl.duration)
}
Rectangle {
id: progressHandle
height: parent.height
width: parent.height / 2
- color: "white"
+ color: palette.accent
opacity: 0.5
anchors.verticalCenter: progressBar.verticalCenter
x: seekControl.duration == 0 ? 0 : seekControl.playPosition / seekControl.duration * background.width
@@ -143,8 +96,8 @@ Item {
function formatTime(timeInMs) {
if (!timeInMs || timeInMs <= 0) return "0:00"
- var seconds = timeInMs / 1000;
- var minutes = Math.floor(seconds / 60)
+ let seconds = timeInMs / 1000;
+ let minutes = Math.floor(seconds / 60)
seconds = Math.floor(seconds % 60)
if (seconds < 10) seconds = "0" + seconds;
return minutes + ":" + seconds
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml
new file mode 100644
index 000000000..15c25c978
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneBasic {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml
new file mode 100644
index 000000000..4a5c5d49b
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneDrag {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml
new file mode 100644
index 000000000..a30b9ebf6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+// Item which is loaded by VideoItem if Qt Multimedia is not available
+Rectangle {
+ id: root
+ color: "grey"
+ height: width
+ property int duration: 0
+ property int position: 0
+ property string source
+ property real volume: 1.0
+ property real playbackRate: 1.0
+
+ signal fatalError
+ signal sizeChanged
+ signal framePainted
+
+ Label {
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Failed to create Video item\n\nCheck that Qt Multimedia is installed")
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.Wrap
+ }
+
+ onWidthChanged: height = width
+ onHeightChanged: root.sizeChanged()
+
+ function start() { }
+ function stop() { }
+ function seek() { }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml
new file mode 100644
index 000000000..af950c735
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Scene {
+ id: root
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: button
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("PreserveAspectFit")
+ // qmllint disable
+ onClicked: {
+ if (!content.dummy) {
+ let video = content.contentItem
+ if (video.fillMode === VideoOutput.Stretch) {
+ video.fillMode = VideoOutput.PreserveAspectFit
+ text = qsTr("PreserveAspectFit")
+ } else if (video.fillMode === VideoOutput.PreserveAspectFit) {
+ video.fillMode = VideoOutput.PreserveAspectCrop
+ text = qsTr("PreserveAspectCrop")
+ } else {
+ video.fillMode = VideoOutput.Stretch
+ text = qsTr("Stretch")
+ }
+ }
+ }
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml
new file mode 100644
index 000000000..e49faadb6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreen {
+ contentType: "video"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml
new file mode 100644
index 000000000..0bf82941e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreenInverted {
+ contentType: "video"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml
new file mode 100644
index 000000000..2ea796de8
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+
+VideoOutput {
+ id: root
+ height: width
+
+ property alias duration: mediaPlayer.duration
+ property alias mediaSource: mediaPlayer.source
+ property alias metaData: mediaPlayer.metaData
+ property alias playbackRate: mediaPlayer.playbackRate
+ property alias position: mediaPlayer.position
+ property alias seekable: mediaPlayer.seekable
+ property alias volume: audioOutput.volume
+
+ signal sizeChanged
+ signal fatalError
+
+ onHeightChanged: root.sizeChanged()
+
+ MediaPlayer {
+ id: mediaPlayer
+ videoOutput: root;
+ audioOutput: AudioOutput {
+ id: audioOutput
+ }
+
+ onErrorOccurred: function(error, errorString) {
+ if (MediaPlayer.NoError !== error) {
+ console.log("[qmlvideo] VideoItem.onError error " + error + " errorString " + errorString)
+ root.fatalError()
+ }
+ }
+ }
+
+ function start() { mediaPlayer.play() }
+ function stop() { mediaPlayer.stop() }
+ function seek(position) { mediaPlayer.setPosition(position); }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml
new file mode 100644
index 000000000..f83cbffe9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+pragma ComponentBehavior: Bound
+
+Scene {
+ id: root
+ property string contentType: "video"
+
+ Content {
+ id: videoContent
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onInitialized: {
+ if (!dummy)
+ metadata.createObject(root)
+ }
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Component {
+ id: metadata
+ Column {
+ anchors.fill: parent
+ // qmllint disable
+ property var videoMetaData: videoContent.contentItem?.metaData
+ // qmllint enable
+ Label {
+ text: qsTr("Title: %1").arg(parent.videoMetaData?.value(MediaMetaData.Title) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Resolution: %1").arg(parent.videoMetaData?.value(MediaMetaData.Resolution) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Media type: %1").arg(parent.videoMetaData?.value(MediaMetaData.MediaType) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video codec: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoCodec) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video bit rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoBitRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video frame rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoFrameRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Audio codec: %1").arg(parent.videoMetaData?.value(MediaMetaData.AudioCodec) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Audio bit rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.AudioBitRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Date: %1").arg(parent.videoMetaData?.value(MediaMetaData.Date) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Description: %1").arg(parent.videoMetaData?.value(MediaMetaData.Description) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Copyright: %1").arg(parent.videoMetaData?.value(MediaMetaData.Copyright) ?? qsTr("Unknown"))
+ }
+ Label {
+ // qmllint disable
+ text: qsTr("Seekable: %1").arg(videoContent.contentItem?.seekable ?? qsTr("Unknown"))
+ // qmllint enable
+ }
+ Label {
+ text: qsTr("Orientation: %1").arg(parent.videoMetaData?.value(MediaMetaData.Orientation) ?? qsTr("Unknown"))
+ }
+ }
+ }
+
+ Component.onCompleted: root.content = videoContent
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml
new file mode 100644
index 000000000..2b9230f3c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneMove {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml
new file mode 100644
index 000000000..576b33ff9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneOverlay {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml
new file mode 100644
index 000000000..55e38ef19
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property int margin: 20
+ property real delta: 0.1
+ property string contentType: "video"
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: increaseButton
+ anchors {
+ right: parent.right
+ bottom: decreaseButton.top
+ margins: parent.margins
+ }
+ text: qsTr("Increase")
+ onClicked: {
+ let video = (content.contentItem as VideoItem)
+ video.playbackRate += root.delta
+ }
+ }
+
+ Button {
+ id: decreaseButton
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("Decrease")
+ onClicked: {
+ let video = (content.contentItem as VideoItem)
+ video.playbackRate -= root.delta
+ }
+ }
+
+ Button {
+ id: valueButton
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ enabled: false
+ // qmllint disable
+ text: Math.round(10 * content.contentItem?.playbackRate ?? 1) / 10
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml
new file mode 100644
index 000000000..88fe7a2d2
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneResize {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml
new file mode 100644
index 000000000..d429ec413
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneRotate {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml
new file mode 100644
index 000000000..5e2584fb6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property string contentType: "video"
+ contentWidth: parent.width
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ SeekControl {
+ anchors {
+ left: parent.left
+ right: parent.right
+ margins: 10
+ bottom: parent.bottom
+ }
+ // qmllint disable
+ duration: content.contentItem?.duration ?? 0
+ playPosition: content.contentItem?.position ?? 0
+ onSeekPositionChanged: content.contentItem?.seek(seekPosition);
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml
new file mode 100644
index 000000000..7c365ddc7
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneSpin {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/images/folder.png b/examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png
index 62d97004f..62d97004f 100644
--- a/examples/multimedia/video/qmlvideo/images/folder.png
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/images/leaves.jpg b/examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg
index 66533b34a..66533b34a 100644
--- a/examples/multimedia/video/qmlvideo/images/leaves.jpg
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/images/up.png b/examples/multimedia/video/qmlvideo/qmlvideo/images/up.png
index 6823de004..6823de004 100644
--- a/examples/multimedia/video/qmlvideo/images/up.png
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/up.png
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/qmldir b/examples/multimedia/video/qmlvideo/qmlvideo/qmldir
new file mode 100644
index 000000000..1cba13d95
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/qmldir
@@ -0,0 +1,44 @@
+module qmlvideo
+
+CameraBasic 1.0 CameraBasic.qml
+CameraDrag 1.0 CameraDrag.qml
+CameraDummy 1.0 CameraDummy.qml
+CameraFullScreen 1.0 CameraFullScreen.qml
+CameraFullScreenInverted 1.0 CameraFullScreenInverted.qml
+CameraItem 1.0 CameraItem.qml
+CameraMove 1.0 CameraMove.qml
+CameraOverlay 1.0 CameraOverlay.qml
+CameraResize 1.0 CameraResize.qml
+CameraRotate 1.0 CameraRotate.qml
+CameraSpin 1.0 CameraSpin.qml
+CameraContent 1.0 Content.qml
+ErrorDialog 1.0 ErrorDialog.qml
+Scene 1.0 Scene.qml
+SceneBasic 1.0 SceneBasic.qml
+SceneDrag 1.0 SceneDrag.qml
+SceneFullScreen 1.0 SceneFullScreen.qml
+SceneFullScreeninverted 1.0 SceneFullScreenInverted.qml
+SceneMoved 1.0 SceneMove.qml
+SceneMulti 1.0 SceneMulti.qml
+SceneOverlay 1.0 SceneOverlay.qml
+SceneResize 1.0 SceneResize.qml
+SceneRotate 1.0 SceneRotate.qml
+SceneSelectionPanel 1.0 SceneSelectionPanel.qml
+SceneSpin 1.0 SceneSpin.qml
+SeekControl 1.0 SeekControl.qml
+VideoBasic 1.0 VideoBasic.qml
+VideoDrag 1.0 VideoDrag.qml
+VideoDummy 1.0 VideoDummy.qml
+VideoFillMode 1.0 VideoFillMode.qml
+VideoFullScreen 1.0 VideoFullScreen.qml
+VideoFullScreenInverted 1.0 VideoFullScreenInverted.qml
+VideoItem 1.0 VideoItem.qml
+VideoMetadata 1.0 VideoMetadata.qml
+VideoMove 1.0 VideoMove.qml
+VideoOverlay 1.0 VideoOverlay.qml
+VideoPlaybackRate 1.0 VideoPlaybackRate.qml
+VideoResize 1.0 VideoResize.qml
+VideoRotate 1.0 VideoRotate.qml
+VideoSeek 1.0 VideoSeek.qml
+VideoSpin 1.0 VideoSpin.qml
+Main 1.0 Main.qml
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h b/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h
new file mode 100644
index 000000000..8df5b5b64
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h
@@ -0,0 +1,10 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QtGlobal>
+
+#if defined(QMLVIDEO_LIB)
+#define QMLVIDEO_LIB_EXPORT Q_DECL_EXPORT
+#else
+#define QMLVIDEO_LIB_EXPORT Q_DECL_IMPORT
+#endif
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp
new file mode 100644
index 000000000..2b02fa505
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videosingleton.h"
+
+VideoSingleton::VideoSingleton(QObject * parent) : QObject(parent)
+{ }
+
+QUrl VideoSingleton::source1() const
+{
+ return m_source1;
+}
+void VideoSingleton::setSource1(const QUrl &source1)
+{
+ if (source1 == m_source1)
+ return;
+ m_source1 = source1;
+ emit source1Changed();
+}
+QUrl VideoSingleton::source2() const
+{
+ return m_source2;
+}
+void VideoSingleton::setSource2(const QUrl &source2)
+{
+ if (source2 == m_source2)
+ return;
+ m_source2 = source2;
+ emit source2Changed();
+}
+qreal VideoSingleton::volume() const
+{
+ return m_volume;
+}
+void VideoSingleton::setVolume(qreal volume)
+{
+ if (volume == m_volume)
+ return;
+ m_volume = volume;
+ emit volumeChanged();
+}
+QUrl VideoSingleton::videoPath() const
+{
+ return m_videoPath;
+}
+void VideoSingleton::setVideoPath(const QUrl &videoPath)
+{
+ if (m_videoPath == videoPath)
+ return;
+ m_videoPath = videoPath;
+ emit videoPathChanged();
+}
+
+#include "moc_videosingleton.cpp"
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h
new file mode 100644
index 000000000..3e0d56247
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef QMLVIDEOSINGLETON_H
+#define QMLVIDEOSINGLETON_H
+
+#include "qmlvideo_global.h"
+
+#include <QtQml/qqml.h>
+
+class QMLVIDEO_LIB_EXPORT VideoSingleton : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source1 READ source1 WRITE setSource1 NOTIFY source1Changed FINAL)
+ Q_PROPERTY(QUrl source2 READ source2 WRITE setSource2 NOTIFY source2Changed FINAL)
+ Q_PROPERTY(QUrl videoPath READ videoPath WRITE setVideoPath NOTIFY videoPathChanged FINAL)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged FINAL)
+ QML_SINGLETON
+ QML_ELEMENT
+
+public:
+ explicit VideoSingleton(QObject *parent = nullptr);
+
+ QUrl source1() const;
+ void setSource1(const QUrl &source1);
+ QUrl source2() const;
+ void setSource2(const QUrl &source2);
+ QUrl videoPath() const;
+ void setVideoPath(const QUrl &videoPath);
+ qreal volume() const;
+ void setVolume(qreal volume);
+
+Q_SIGNALS:
+ void source1Changed();
+ void source2Changed();
+ void volumeChanged();
+ void videoPathChanged();
+
+private:
+ QUrl m_source1;
+ QUrl m_source2;
+ QUrl m_videoPath;
+ qreal m_volume = 0.5;
+};
+
+QML_DECLARE_TYPE(VideoSingleton);
+
+#endif // QMLVIDEOSINGLETON_H
diff --git a/examples/multimedia/video/qmlvideo/trace.h b/examples/multimedia/video/qmlvideo/trace.h
index 0ad9b5167..bd7f63b68 100644
--- a/examples/multimedia/video/qmlvideo/trace.h
+++ b/examples/multimedia/video/qmlvideo/trace.h
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TRACE_H
#define TRACE_H
-#include <QtCore/QDebug>
+#include <QDebug>
#define ENABLE_TRACE
//#define VERBOSE_TRACE
@@ -61,13 +14,19 @@ namespace Trace {
class NullDebug
{
public:
- template <typename T>
- NullDebug& operator<<(const T&) { return *this; }
+ template<typename T>
+ NullDebug &operator<<(const T &)
+ {
+ return *this;
+ }
};
-inline NullDebug nullDebug() { return NullDebug(); }
+inline NullDebug nullDebug()
+{
+ return NullDebug();
+}
-template <typename T>
+template<typename T>
struct PtrWrapper
{
PtrWrapper(const T *ptr) : m_ptr(ptr) { }
@@ -76,8 +35,8 @@ struct PtrWrapper
} // namespace Trace
-template <typename T>
-inline QDebug& operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
+template<typename T>
+inline QDebug &operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
{
QDebugStateSaver saver(debug);
debug.nospace() << '[' << static_cast<const void *>(wrapper.m_ptr) << ']';
@@ -86,20 +45,37 @@ inline QDebug& operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
template<typename T>
inline const void *qtVoidPtr(const T *ptr)
-{ return static_cast<const void *>(ptr); }
+{
+ return static_cast<const void *>(ptr);
+}
#define qtThisPtr() qtVoidPtr(this)
#ifdef ENABLE_TRACE
- inline QDebug qtTrace() { return qDebug() << "[qmlvideo]"; }
+inline QDebug qtTrace()
+{
+ return qDebug() << "[qmlvideo]";
+}
# ifdef VERBOSE_TRACE
- inline QDebug qtVerboseTrace() { return qtTrace(); }
+inline QDebug qtVerboseTrace()
+{
+ return qtTrace();
+}
# else
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
+inline Trace::NullDebug qtVerboseTrace()
+{
+ return Trace::nullDebug();
+}
# endif
#else
- inline Trace::NullDebug qtTrace() { return Trace::nullDebug(); }
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
+inline Trace::NullDebug qtTrace()
+{
+ return Trace::nullDebug();
+}
+inline Trace::NullDebug qtVerboseTrace()
+{
+ return Trace::nullDebug();
+}
#endif
#endif // TRACE_H
diff --git a/examples/multimedia/video/recorder/AudioInputSelect.qml b/examples/multimedia/video/recorder/AudioInputSelect.qml
index bb79f2793..d1e30f080 100644
--- a/examples/multimedia/video/recorder/AudioInputSelect.qml
+++ b/examples/multimedia/video/recorder/AudioInputSelect.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
@@ -54,13 +7,18 @@ import QtMultimedia
Row {
id: root
-
+ height: Style.height
property AudioInput selected: available ? audioInput : null
property bool available: (typeof comboBox.currentValue !== 'undefined') && audioSwitch.checked
+ Component.onCompleted: {
+ audioInputModel.populate()
+ comboBox.currentIndex = 0
+ }
+
MediaDevices { id: mediaDevices }
- AudioInput { id: audioInput; muted: false }
+ AudioInput { id: audioInput; muted: !audioSwitch.checked }
Switch {
id: audioSwitch;
@@ -68,15 +26,28 @@ Row {
checked: true
}
+ ListModel {
+ id: audioInputModel
+ property var audioInputs: mediaDevices.audioInputs
+
+ function populate() {
+ audioInputModel.clear()
+
+ for (var audioDevice of audioInputs)
+ audioInputModel.append({ text: audioDevice.description, value:
+ { type: 'audioDevice', audioDevice: audioDevice } })
+ }
+ }
ComboBox {
id: comboBox
width: Style.widthLong
height: Style.height
background: StyleRectangle { anchors.fill: parent }
- model: mediaDevices.audioInputs
- textRole: "description"
+ model: audioInputModel
+ textRole: "text"
font.pointSize: Style.fontSize
- displayText: typeof currentValue === 'undefined' ? "unavailable" : currentValue.description
- onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue
+ displayText: typeof currentValue === 'undefined' ? "unavailable" : currentText
+ valueRole: "value"
+ onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue.audioDevice
}
}
diff --git a/examples/multimedia/video/recorder/CMakeLists.txt b/examples/multimedia/video/recorder/CMakeLists.txt
index 1948c5b23..116a1b817 100644
--- a/examples/multimedia/video/recorder/CMakeLists.txt
+++ b/examples/multimedia/video/recorder/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(recorder LANGUAGES CXX)
@@ -18,10 +21,11 @@ qt_add_executable(recorder
set(resource_files
"main.qml"
+ "main_no_permissions.qml"
"qmldir"
"MediaList.qml"
"AudioInputSelect.qml"
- "CameraSelect.qml"
+ "VideoSourceSelect.qml"
"RecordButton.qml"
"Controls.qml"
"StyleParameter.qml"
diff --git a/examples/multimedia/video/recorder/CameraSelect.qml b/examples/multimedia/video/recorder/CameraSelect.qml
deleted file mode 100644
index 0810d4baf..000000000
--- a/examples/multimedia/video/recorder/CameraSelect.qml
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick
-import QtQuick.Controls
-import QtMultimedia
-
-Row {
- id: root
- height: Style.height
- property Camera selected: available ? camera : null
- property bool available: (typeof comboBox.currentValue !== 'undefined') && cameraSwitch.checked
-
- Camera {
- id: camera
- active: available && selected != null
- }
-
- MediaDevices { id: mediaDevices }
-
- Switch {
- id: cameraSwitch
- anchors.verticalCenter: parent.verticalCenter
- checked: true
- }
-
- ComboBox {
- id: comboBox
- width: Style.widthLong
- height: Style.height
- background: StyleRectangle { anchors.fill: parent }
- model: mediaDevices.videoInputs
- displayText: typeof currentValue === 'undefined' ? "Unavailable" : currentValue.description
- font.pointSize: Style.fontSize
- textRole: "description"
- onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') camera.cameraDevice = currentValue
- }
-}
diff --git a/examples/multimedia/video/recorder/Controls.qml b/examples/multimedia/video/recorder/Controls.qml
index baaad0ddf..627c2fe04 100644
--- a/examples/multimedia/video/recorder/Controls.qml
+++ b/examples/multimedia/video/recorder/Controls.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
@@ -61,7 +14,9 @@ Row {
property bool capturesVisible: false
property alias audioInput: audioInputSelect.selected
- property alias camera: cameraSelect.selected
+ property alias camera: videoSourceSelect.selectedCamera
+ property alias screenCapture: videoSourceSelect.selectedScreenCapture
+ property alias windowCapture: videoSourceSelect.selectedWindowCapture
spacing: Style.interSpacing * Style.ratio
@@ -69,7 +24,7 @@ Row {
id: inputControls
spacing: Style.intraSpacing
- CameraSelect { id: cameraSelect }
+ VideoSourceSelect { id: videoSourceSelect }
AudioInputSelect { id: audioInputSelect }
}
@@ -84,6 +39,7 @@ Row {
id: recordingTime
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: Style.fontSize
+ color: palette.text
}
}
@@ -91,6 +47,10 @@ Row {
id: optionButtons
spacing: Style.intraSpacing
Button {
+ leftPadding: 0
+ rightPadding: 0
+ topPadding: 0
+ bottomPadding: 0
height: Style.height
width: Style.widthMedium
background: StyleRectangle { anchors.fill: parent }
@@ -99,6 +59,10 @@ Row {
font.pointSize: Style.fontSize
}
Button {
+ leftPadding: 0
+ rightPadding: 0
+ topPadding: 0
+ bottomPadding: 0
height: Style.height
width: Style.widthMedium
background: StyleRectangle { anchors.fill: parent }
diff --git a/examples/multimedia/video/recorder/MediaList.qml b/examples/multimedia/video/recorder/MediaList.qml
index 33c65d32c..5fa65393a 100644
--- a/examples/multimedia/video/recorder/MediaList.qml
+++ b/examples/multimedia/video/recorder/MediaList.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
diff --git a/examples/multimedia/video/recorder/Playback.qml b/examples/multimedia/video/recorder/Playback.qml
index fdcfd1723..78575ae26 100644
--- a/examples/multimedia/video/recorder/Playback.qml
+++ b/examples/multimedia/video/recorder/Playback.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
diff --git a/examples/multimedia/video/recorder/RecordButton.qml b/examples/multimedia/video/recorder/RecordButton.qml
index 44d8d48d1..5296a3028 100644
--- a/examples/multimedia/video/recorder/RecordButton.qml
+++ b/examples/multimedia/video/recorder/RecordButton.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
diff --git a/examples/multimedia/video/recorder/SettingsEncoder.qml b/examples/multimedia/video/recorder/SettingsEncoder.qml
index c129eaed0..16a9590be 100644
--- a/examples/multimedia/video/recorder/SettingsEncoder.qml
+++ b/examples/multimedia/video/recorder/SettingsEncoder.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Layouts
@@ -71,7 +24,10 @@ Column {
function onMediaFormatChanged() { root.populateModels() }
}
- Text { text: "Encoder settings" }
+ Text {
+ text: "Encoder settings"
+ color: palette.text
+ }
StyleParameter {
label: "Quality"
diff --git a/examples/multimedia/video/recorder/SettingsMetaData.qml b/examples/multimedia/video/recorder/SettingsMetaData.qml
index e675e2325..7bfc2255d 100644
--- a/examples/multimedia/video/recorder/SettingsMetaData.qml
+++ b/examples/multimedia/video/recorder/SettingsMetaData.qml
@@ -1,70 +1,29 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtMultimedia
+pragma ComponentBehavior: Bound
+
ColumnLayout {
+ id: root
required property MediaRecorder recorder
- Text { text: "Metadata settings" }
+ Text {
+ text: "Metadata settings"
+ color: palette.text
+ }
ListModel { id: metaDataModel }
Connections {
- target: recorder
+ target: root.recorder
function onMetaDataChanged() {
metaDataModel.clear()
- for (var key of recorder.metaData.keys()) {
+ for (var key of root.recorder.metaData.keys()) {
if (recorder.metaData.stringValue(key))
metaDataModel.append(
{ text: recorder.metaData.metaDataKeyToString(key)
@@ -114,7 +73,7 @@ ColumnLayout {
font.pointSize: Style.fontSize
clip: true
onAccepted: {
- recorder.metaData.insert(metaDataType.currentValue, text)
+ root.recorder.metaData.insert(metaDataType.currentValue, text)
recorder.metaDataChanged()
text = ""
textInput.deselect()
@@ -168,8 +127,8 @@ ColumnLayout {
anchors.bottom: parent.bottom
font.pointSize: Style.fontSize
clip: true
- text: recorder.metaData.stringValue(r.value)
- onAccepted: recorder.metaData.insert(r.value, text)
+ text: root.recorder.metaData.stringValue(r.value)
+ onAccepted: root.recorder.metaData.insert(r.value, text)
}
}
@@ -179,7 +138,7 @@ ColumnLayout {
text: "del"
font.pointSize: Style.fontSize
background: StyleRectangle { anchors.fill: parent }
- onClicked: { recorder.metaData.remove(r.value); recorder.metaDataChanged() }
+ onClicked: { root.recorder.metaData.remove(r.value); recorder.metaDataChanged() }
}
}
}
diff --git a/examples/multimedia/video/recorder/Style.qml b/examples/multimedia/video/recorder/Style.qml
index f00a3c9f1..d30c3b8ef 100644
--- a/examples/multimedia/video/recorder/Style.qml
+++ b/examples/multimedia/video/recorder/Style.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma Singleton
import QtQuick
diff --git a/examples/multimedia/video/recorder/StyleParameter.qml b/examples/multimedia/video/recorder/StyleParameter.qml
index 2a6c3ddb3..3a7573b92 100644
--- a/examples/multimedia/video/recorder/StyleParameter.qml
+++ b/examples/multimedia/video/recorder/StyleParameter.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
@@ -68,7 +21,7 @@ Row {
width: Style.widthShort
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
- color: root.enabled ? "black" : "gray"
+ color: root.enabled ? palette.text : palette.mid
font.pointSize: Style.fontSize
}
diff --git a/examples/multimedia/video/recorder/StyleRectangle.qml b/examples/multimedia/video/recorder/StyleRectangle.qml
index 7e9186fc8..e28cf4a19 100644
--- a/examples/multimedia/video/recorder/StyleRectangle.qml
+++ b/examples/multimedia/video/recorder/StyleRectangle.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
diff --git a/examples/multimedia/video/recorder/StyleSlider.qml b/examples/multimedia/video/recorder/StyleSlider.qml
index 5f8e12309..a15304aaa 100644
--- a/examples/multimedia/video/recorder/StyleSlider.qml
+++ b/examples/multimedia/video/recorder/StyleSlider.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
@@ -69,7 +22,7 @@ Row {
height: Style.height
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
- color: root.enabled ? "black" : "gray"
+ color: root.enabled ? palette.text : palette.mid
}
Slider {
diff --git a/examples/multimedia/video/recorder/VideoSourceSelect.qml b/examples/multimedia/video/recorder/VideoSourceSelect.qml
new file mode 100644
index 000000000..7eeed99b9
--- /dev/null
+++ b/examples/multimedia/video/recorder/VideoSourceSelect.qml
@@ -0,0 +1,165 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Row {
+ id: root
+ height: Style.height
+ property Camera selectedCamera: cameraAvailable ? camera : null
+ property ScreenCapture selectedScreenCapture: screenAvailable ? screenCapture : null
+ property WindowCapture selectedWindowCapture: windowAvailable ? windowCapture : null
+
+ property bool sourceAvailable: typeof comboBox.currentValue !== 'undefined' &&
+ comboBox.currentValue.type !== 'toggler' &&
+ videoSourceSwitch.checked
+
+ property bool cameraAvailable: sourceAvailable && comboBox.currentValue.type === 'camera'
+ property bool screenAvailable: sourceAvailable && comboBox.currentValue.type === 'screen'
+ property bool windowAvailable: sourceAvailable && comboBox.currentValue.type === 'window'
+
+ Component.onCompleted: {
+ videoSourceModel.populate()
+
+ for (var i = 0; i < videoSourceModel.count; i++) {
+ if (videoSourceModel.get(i).value.type !== 'toggler') {
+ comboBox.currentIndex = i
+ break
+ }
+ }
+ }
+
+ Camera {
+ id: camera
+ active: cameraAvailable
+ }
+
+ ScreenCapture {
+ id: screenCapture
+ active: screenAvailable
+ }
+
+ WindowCapture {
+ id: windowCapture
+ active: windowAvailable
+ }
+
+ MediaDevices { id: mediaDevices
+ onVideoInputsChanged: {
+
+ videoSourceModel.populate()
+
+ for (var i = 0; i < videoSourceModel.count; i++) {
+ if (videoSourceModel.get(i).value.type !== 'toggler') {
+ comboBox.currentIndex = i
+ break
+ }
+ }
+ }
+ }
+
+ Switch {
+ id: videoSourceSwitch
+ anchors.verticalCenter: parent.verticalCenter
+ checked: true
+ }
+
+ ListModel {
+ id: videoSourceModel
+ property var enabledSources: {
+ 'camera': true,
+ 'screen': true,
+ 'window': false
+ }
+
+ function toggleEnabledSource(type) {
+ enabledSources[type] = !enabledSources[type]
+ populate()
+ }
+
+ function appendItem(text, value) {
+ append({ text: text, value: value})
+ }
+
+ function appendToggler(name, sourceType) {
+ appendItem((enabledSources[sourceType] ? "- Hide " : "+ Show ") + name,
+ { type: 'toggler', 'sourceType': sourceType })
+ }
+
+ function populate() {
+ clear()
+
+ appendToggler('Cameras', 'camera')
+ if (enabledSources['camera'])
+ for (var camera of mediaDevices.videoInputs)
+ appendItem(camera.description, { type: 'camera', camera: camera })
+
+ appendToggler('Screens', 'screen')
+ if (enabledSources['screen'])
+ for (var screen of Application.screens)
+ appendItem(screen.name, { type: 'screen', screen: screen })
+
+ appendToggler('Windows', 'window')
+ if (enabledSources['window'])
+ for (var window of windowCapture.capturableWindows())
+ appendItem(window.description, { type: 'window', window: window })
+ }
+ }
+
+ ComboBox {
+ id: comboBox
+ width: Style.widthLong
+ height: Style.height
+ background: StyleRectangle { anchors.fill: parent }
+ model: videoSourceModel
+ displayText: typeof currentValue === 'undefined' ||
+ currentValue.type === 'toggler' ? "Unavailable" : currentText
+ font.pointSize: Style.fontSize
+ textRole: "text"
+ valueRole: "value"
+ onCurrentValueChanged: {
+ if (typeof currentValue === 'undefined')
+ return
+ if (currentValue.type === 'screen')
+ screenCapture.screen = currentValue.screen
+ else if (currentValue.type === 'camera')
+ camera.cameraDevice = currentValue.camera
+ else if (currentValue.type === 'window')
+ windowCapture.window = currentValue.window
+ else if (currentValue.type === 'toggler')
+ model.toggleEnabledSource(currentValue.sourceType)
+ }
+
+ delegate: ItemDelegate {
+ property bool isToggler: value.type === 'toggler'
+ text: model[comboBox.textRole]
+ width: comboBox.width
+ height: comboBox.height
+ highlighted: comboBox.highlightedIndex === index && !isToggler
+ font.italic: isToggler
+ font.underline: isToggler
+ font.bold: comboBox.currentIndex === index && !isToggler ||
+ isToggler && comboBox.highlightedIndex === index
+ palette.text: isToggler ? comboBox.palette.link : comboBox.palette.text
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (isToggler)
+ videoSourceModel.toggleEnabledSource(value.sourceType)
+ else {
+ comboBox.currentIndex = index
+ comboBox.popup.close()
+ }
+ }
+ }
+
+ required property var value
+ required property int index
+ required property var model
+ }
+
+ }
+}
diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif
new file mode 100644
index 000000000..b02053ea5
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif
Binary files differ
diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif
new file mode 100644
index 000000000..2e5e39215
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif
Binary files differ
diff --git a/examples/multimedia/video/recorder/doc/src/recorder.qdoc b/examples/multimedia/video/recorder/doc/src/recorder.qdoc
index 9ced09e74..3c0de3730 100644
--- a/examples/multimedia/video/recorder/doc/src/recorder.qdoc
+++ b/examples/multimedia/video/recorder/doc/src/recorder.qdoc
@@ -1,46 +1,102 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/video/recorder
- \title QML Recorder Example
+ \example video/recorder
+ \title QML Video Recorder
\ingroup multimedia_examples
\ingroup video_examples_qml
\ingroup camera_examples_qml
+ \examplecategory {Multimedia}
\brief Recording audio and video using Qt Quick.
\meta {tag} {quick}
\image qmlrecorder.jpg
\e{QML Recorder} demonstrates a simple application that can record
- audio and or video files using the camera and microphone.
+ audio and video separate or together, using a microphone, a camera, or
+ with screen capturing.
\include examples-run.qdocinc
- The example uses the QML Camera and AudioInput objects connected to a MediaCaptureSession.
- A MediaRecorder object is then used to record the captured audio and video.
+ \section1 Overview
+ At its core, this is a QML application, see
+ \l{Getting Started Programming with Qt Quick}. This documentation is focused
+ on how this example uses the \l{Qt Multimedia QML Types}.
+
+ \image qml-recorder-overview.gif "Animation cycling through qml objects declared in main.qml"
+
+ The example uses the QML \l Camera and \l AudioInput types connected to a
+ \l CaptureSession. A \l MediaRecorder object is then used to record the
+ captured audio and video.
+
+ In addition to QtMultimedia, features of Qt Quick Windows, Controls, and
+ Layouts are used to implement the graphic user interface and functionality.
+ Playback won't be covered here, for that see the \l{QML Media Player Example}.
+
+ The example demonstrates the following:
+ \list
+ \li Input devices can be selected.
+ \li An input type switched off.
+ \li Settings for capturing such as quality, codec choice, file format,
+ and assigning metadata.
+ \li Captured files are stored and can be played back.
+ \endlist
+
+ \section1 Recording
+
+ The application implements recording.
+
+ \section2 captureSession
+
+ In \c main.qml, \c captureSession is declared like so:
+
+ \quotefromfile video/recorder/main.qml
+ \skipto CaptureSession
+ \printto MediaRecorder
+
+ \section2 recorder
+
+ In \c main.qml, the \l MediaRecorder \c recorder handles recording media
+ as well as capturing a thumbnail for the file and appending it to a ListModel,
+ \c mediaList.
+ \printto Playback
+
+ \c mediaList is declared in the \l Frame \c mediaListFrame
+ \quotefromfile video/recorder/main.qml
+ \skipto Frame
+ \printuntil playback: playback
+
+ \section2 controls
+
+ \image qml-recorder-control-bar-overview.gif
+
+ These are defined in \c Controls.qml and declared in main.qml.
+
+ Its root is a \l Row that contains the \l{Column}{Columns} \c inputControls,
+ \c recordButton, \c optionButtons, each defined in their own .qml files.
+
+ \section3 Selecting a video source
+
+ Defined in \c VideoSourceSelect.qml, \c VideoSourceSlect is comprised of a
+ \l Switch and a \l ComboBox and enables the user to select from available
+ cameras.
+
+ \quotefromfile video/recorder/VideoSourceSelect.qml
+ \skipto Row
+ \printto ComboBox
+
+ \c comboBox, declared in the above snippet, assigns the current video source.
+
+ \printuntil camera.cameraDevice = currentValue.camera
+
+ \section3 Selecting an audio input
+
+ Implemented in the same way as \l{Selecting a video source} and defined in
+ \c AudioInputSelect.qml like so:
+
+ \quotefromfile video/recorder/AudioInputSelect.qml
+ \skipto Row
+ \printto audioInput.device = currentValue
+
*/
diff --git a/examples/multimedia/video/recorder/main.cpp b/examples/multimedia/video/recorder/main.cpp
index 21067f50d..92e54cb1b 100644
--- a/examples/multimedia/video/recorder/main.cpp
+++ b/examples/multimedia/video/recorder/main.cpp
@@ -1,68 +1,51 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
#include <QQmlApplicationEngine>
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
- QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
- &app, [url](QObject *obj, const QUrl &objUrl) {
- if (!obj && url == objUrl)
- QCoreApplication::exit(-1);
- }, Qt::QueuedConnection);
+ QObject::connect(
+ &engine, &QQmlApplicationEngine::objectCreated, &app,
+ [url](QObject *obj, const QUrl &objUrl) {
+ if (!obj && url == objUrl)
+ QCoreApplication::exit(-1);
+ },
+ Qt::QueuedConnection);
+
+#if QT_CONFIG(permissions)
+ // If the permissions are not granted, display another main window, which
+ // simply contains the error message.
+ const QUrl noPermissionsUrl(QStringLiteral("qrc:/main_no_permissions.qml"));
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&](const QPermission &permission) {
+ if (permission.status() != Qt::PermissionStatus::Granted) {
+ qWarning("Camera permission is not granted!");
+ engine.load(noPermissionsUrl);
+ return;
+ }
+ QMicrophonePermission micPermission;
+ qApp->requestPermission(micPermission, [&](const QPermission &permission) {
+ if (permission.status() != Qt::PermissionStatus::Granted) {
+ qWarning("Microphone permission is not granted!");
+ engine.load(noPermissionsUrl);
+ } else {
+ engine.load(url);
+ }
+ });
+ });
+#else
engine.load(url);
+#endif
return app.exec();
}
diff --git a/examples/multimedia/video/recorder/main.qml b/examples/multimedia/video/recorder/main.qml
index c7e625f0e..d8d1cd54f 100644
--- a/examples/multimedia/video/recorder/main.qml
+++ b/examples/multimedia/video/recorder/main.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Window
@@ -61,6 +14,8 @@ Window {
width: Style.screenWidth
height: Style.screenHeigth
+ color: palette.window
+
onWidthChanged:{
Style.calculateRatio(root.width, root.height)
}
@@ -82,6 +37,8 @@ Window {
recorder: recorder
audioInput: controls.audioInput
camera: controls.camera
+ screenCapture: controls.screenCapture
+ windowCapture: controls.windowCapture
videoOutput: videoOutput
}
@@ -119,7 +76,7 @@ Window {
x: controls.capturesVisible ? 0 : parent.width
background: Rectangle {
anchors.fill: parent
- color: "white"
+ color: palette.base
opacity: 0.8
}
@@ -145,7 +102,7 @@ Window {
background: Rectangle {
anchors.fill: parent
- color: "white"
+ color: palette.base
opacity: 0.8
}
diff --git a/examples/multimedia/video/recorder/main_no_permissions.qml b/examples/multimedia/video/recorder/main_no_permissions.qml
new file mode 100644
index 000000000..8c76533b0
--- /dev/null
+++ b/examples/multimedia/video/recorder/main_no_permissions.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Window
+
+Window {
+ id: root
+ visible: true
+ title: "Media recorder"
+ width: Style.screenWidth
+ height: Style.screenHeigth
+
+ StyleRectangle {
+ anchors.fill: parent
+ Text {
+ anchors.fill: parent
+ anchors.margins: 20
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("The example is not usable without the permissions.\n"
+ + "Please grant all requested permissions and restart the application.")
+ }
+ }
+}
diff --git a/examples/multimediawidgets/videographicsitem/CMakeLists.txt b/examples/multimedia/videographicsitem/CMakeLists.txt
index fb8f4d857..a45e373a3 100644
--- a/examples/multimediawidgets/videographicsitem/CMakeLists.txt
+++ b/examples/multimedia/videographicsitem/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(videographicsitem LANGUAGES CXX)
@@ -7,7 +10,7 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/videographicsitem")
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/videographicsitem")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
diff --git a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png b/examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png
index e333c54a2..e333c54a2 100644
--- a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png
+++ b/examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png
Binary files differ
diff --git a/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc
new file mode 100644
index 000000000..74196dfeb
--- /dev/null
+++ b/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example videographicsitem
+ \title Video Graphics Item Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Streaming video on a graphics scene.
+ \meta {tag} {widgets}
+
+ \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that
+ displays video on a graphics scene using QVideoSink.
+
+ \image video-videographicsitem.png
+
+ \sa {Video Widget Example}
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/multimedia/videographicsitem/main.cpp b/examples/multimedia/videographicsitem/main.cpp
new file mode 100644
index 000000000..725243ed9
--- /dev/null
+++ b/examples/multimedia/videographicsitem/main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QUrl>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Player Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt MultiMedia Player QGraphicsView Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL to open.");
+ parser.process(app);
+
+ VideoPlayer player;
+
+ if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
+ const QUrl url = QUrl::fromUserInput(parser.positionalArguments().constFirst(),
+ QDir::currentPath(), QUrl::AssumeLocalFile);
+ player.load(url);
+ }
+
+ player.show();
+
+ return app.exec();
+}
diff --git a/examples/multimediawidgets/videographicsitem/videographicsitem.pro b/examples/multimedia/videographicsitem/videographicsitem.pro
index 30a9b6f21..3415ef64c 100644
--- a/examples/multimediawidgets/videographicsitem/videographicsitem.pro
+++ b/examples/multimedia/videographicsitem/videographicsitem.pro
@@ -8,7 +8,7 @@ HEADERS += videoplayer.h
SOURCES += main.cpp \
videoplayer.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videographicsitem
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/videographicsitem
INSTALLS += target
QT+=widgets
diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.cpp b/examples/multimedia/videographicsitem/videoplayer.cpp
index 2f76f2be3..744a35469 100644
--- a/examples/multimediawidgets/videographicsitem/videoplayer.cpp
+++ b/examples/multimedia/videographicsitem/videoplayer.cpp
@@ -1,60 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "videoplayer.h"
-#include <QtWidgets>
+#include <QBoxLayout>
+#include <QDir>
+#include <QFileDialog>
+#include <QGraphicsScene>
#include <QGraphicsVideoItem>
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
+#include <QGraphicsView>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QScreen>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QStyle>
+#include <QVBoxLayout>
+#include <QWidget>
+
+VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent)
{
m_mediaPlayer = new QMediaPlayer(this);
const QSize screenGeometry = screen()->availableSize();
@@ -68,11 +32,10 @@ VideoPlayer::VideoPlayer(QWidget *parent)
QSlider *rotateSlider = new QSlider(Qt::Horizontal);
rotateSlider->setToolTip(tr("Rotate Video"));
- rotateSlider->setRange(-180, 180);
+ rotateSlider->setRange(-180, 180);
rotateSlider->setValue(0);
- connect(rotateSlider, &QAbstractSlider::valueChanged,
- this, &VideoPlayer::rotateVideo);
+ connect(rotateSlider, &QAbstractSlider::valueChanged, this, &VideoPlayer::rotateVideo);
QAbstractButton *openButton = new QPushButton(tr("Open..."));
connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile);
@@ -86,8 +49,7 @@ VideoPlayer::VideoPlayer(QWidget *parent)
m_positionSlider = new QSlider(Qt::Horizontal);
m_positionSlider->setRange(0, 0);
- connect(m_positionSlider, &QAbstractSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
+ connect(m_positionSlider, &QAbstractSlider::sliderMoved, this, &VideoPlayer::setPosition);
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setContentsMargins(0, 0, 0, 0);
@@ -101,15 +63,13 @@ VideoPlayer::VideoPlayer(QWidget *parent)
layout->addLayout(controlLayout);
m_mediaPlayer->setVideoOutput(m_videoItem);
- connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged,
- this, &VideoPlayer::mediaStateChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged, this,
+ &VideoPlayer::mediaStateChanged);
connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
}
-VideoPlayer::~VideoPlayer()
-{
-}
+VideoPlayer::~VideoPlayer() { }
QSize VideoPlayer::sizeHint() const
{
@@ -126,7 +86,8 @@ void VideoPlayer::openFile()
QFileDialog fileDialog(this);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setWindowTitle(tr("Open Movie"));
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
if (fileDialog.exec() == QDialog::Accepted)
load(fileDialog.selectedUrls().constFirst());
}
@@ -151,7 +112,7 @@ void VideoPlayer::play()
void VideoPlayer::mediaStateChanged(QMediaPlayer::PlaybackState state)
{
- switch(state) {
+ switch (state) {
case QMediaPlayer::PlayingState:
m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
break;
@@ -176,11 +137,12 @@ void VideoPlayer::setPosition(int position)
m_mediaPlayer->setPosition(position);
}
-
void VideoPlayer::rotateVideo(int angle)
{
- //rotate around the center of video element
+ // rotate around the center of video element
qreal x = m_videoItem->boundingRect().width() / 2.0;
qreal y = m_videoItem->boundingRect().height() / 2.0;
m_videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y));
}
+
+#include "moc_videoplayer.cpp"
diff --git a/examples/multimedia/videographicsitem/videoplayer.h b/examples/multimedia/videographicsitem/videoplayer.h
new file mode 100644
index 000000000..5cd4d7434
--- /dev/null
+++ b/examples/multimedia/videographicsitem/videoplayer.h
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOPLAYER_H
+#define VIDEOPLAYER_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QSlider;
+class QGraphicsVideoItem;
+QT_END_NAMESPACE
+
+class VideoPlayer : public QWidget
+{
+ Q_OBJECT
+
+public:
+ VideoPlayer(QWidget *parent = nullptr);
+ ~VideoPlayer();
+
+ void load(const QUrl &url);
+ bool isPlayerAvailable() const;
+
+ QSize sizeHint() const override;
+
+public slots:
+ void openFile();
+ void play();
+
+private slots:
+ void mediaStateChanged(QMediaPlayer::PlaybackState state);
+ void positionChanged(qint64 position);
+ void durationChanged(qint64 duration);
+ void setPosition(int position);
+ void rotateVideo(int angle);
+
+private:
+ QMediaPlayer *m_mediaPlayer = nullptr;
+ QGraphicsVideoItem *m_videoItem = nullptr;
+ QAbstractButton *m_playButton = nullptr;
+ QSlider *m_positionSlider = nullptr;
+};
+
+#endif
diff --git a/examples/multimediawidgets/videowidget/CMakeLists.txt b/examples/multimedia/videowidget/CMakeLists.txt
index fbfaba50b..e47cea1fa 100644
--- a/examples/multimediawidgets/videowidget/CMakeLists.txt
+++ b/examples/multimedia/videowidget/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(videowidget LANGUAGES CXX)
@@ -7,7 +10,7 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/videowidget")
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/videowidget")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
diff --git a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png b/examples/multimedia/videowidget/doc/images/video-videowidget.png
index a3c7bcb44..a3c7bcb44 100644
--- a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png
+++ b/examples/multimedia/videowidget/doc/images/video-videowidget.png
Binary files differ
diff --git a/examples/multimedia/videowidget/doc/src/videowidget.qdoc b/examples/multimedia/videowidget/doc/src/videowidget.qdoc
new file mode 100644
index 000000000..65be142fe
--- /dev/null
+++ b/examples/multimedia/videowidget/doc/src/videowidget.qdoc
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example videowidget
+ \title Video Widget Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Implementing a video player widget.
+ \meta {tag} {widgets,QVideoWidget}
+
+ \e{Video Widget} demonstrates how to implement a simple video player using
+ QVideoWidget.
+
+ \image video-videowidget.png
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/multimedia/videowidget/main.cpp b/examples/multimedia/videowidget/main.cpp
new file mode 100644
index 000000000..a4e2dc4aa
--- /dev/null
+++ b/examples/multimedia/videowidget/main.cpp
@@ -0,0 +1,40 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QScreen>
+#include <QUrl>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Video Widget Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName());
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt Video Widget Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL to open.");
+ parser.process(app);
+
+ VideoPlayer player;
+ if (!parser.positionalArguments().isEmpty()) {
+ const QUrl url = QUrl::fromUserInput(parser.positionalArguments().constFirst(),
+ QDir::currentPath(), QUrl::AssumeLocalFile);
+ player.setUrl(url);
+ }
+
+ const QSize availableGeometry = player.screen()->availableSize();
+ player.resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
+ player.show();
+
+ return app.exec();
+}
diff --git a/examples/multimediawidgets/videowidget/videoplayer.cpp b/examples/multimedia/videowidget/videoplayer.cpp
index ded52499c..1a778d2fb 100644
--- a/examples/multimediawidgets/videowidget/videoplayer.cpp
+++ b/examples/multimedia/videowidget/videoplayer.cpp
@@ -1,60 +1,22 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "videoplayer.h"
-#include <QtWidgets>
+#include <QBoxLayout>
+#include <QFileDialog>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMediaPlayer>
+#include <QPushButton>
+#include <QSizePolicy>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QString>
+#include <QStyle>
#include <QVideoWidget>
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
+VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent)
{
m_mediaPlayer = new QMediaPlayer(this);
QVideoWidget *videoWidget = new QVideoWidget;
@@ -66,14 +28,12 @@ VideoPlayer::VideoPlayer(QWidget *parent)
m_playButton->setEnabled(false);
m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- connect(m_playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
+ connect(m_playButton, &QAbstractButton::clicked, this, &VideoPlayer::play);
m_positionSlider = new QSlider(Qt::Horizontal);
m_positionSlider->setRange(0, 0);
- connect(m_positionSlider, &QAbstractSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
+ connect(m_positionSlider, &QAbstractSlider::sliderMoved, this, &VideoPlayer::setPosition);
m_errorLabel = new QLabel;
m_errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
@@ -92,24 +52,22 @@ VideoPlayer::VideoPlayer(QWidget *parent)
setLayout(layout);
m_mediaPlayer->setVideoOutput(videoWidget);
- connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged,
- this, &VideoPlayer::mediaStateChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged, this,
+ &VideoPlayer::mediaStateChanged);
connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
- connect(m_mediaPlayer, &QMediaPlayer::errorChanged,
- this, &VideoPlayer::handleError);
+ connect(m_mediaPlayer, &QMediaPlayer::errorChanged, this, &VideoPlayer::handleError);
}
-VideoPlayer::~VideoPlayer()
-{
-}
+VideoPlayer::~VideoPlayer() { }
void VideoPlayer::openFile()
{
QFileDialog fileDialog(this);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setWindowTitle(tr("Open Movie"));
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
if (fileDialog.exec() == QDialog::Accepted)
setUrl(fileDialog.selectedUrls().constFirst());
}
@@ -136,7 +94,7 @@ void VideoPlayer::play()
void VideoPlayer::mediaStateChanged(QMediaPlayer::PlaybackState state)
{
- switch(state) {
+ switch (state) {
case QMediaPlayer::PlayingState:
m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
break;
@@ -175,3 +133,5 @@ void VideoPlayer::handleError()
message += errorString;
m_errorLabel->setText(message);
}
+
+#include "moc_videoplayer.cpp"
diff --git a/examples/multimedia/videowidget/videoplayer.h b/examples/multimedia/videowidget/videoplayer.h
new file mode 100644
index 000000000..3657a04de
--- /dev/null
+++ b/examples/multimedia/videowidget/videoplayer.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOPLAYER_H
+#define VIDEOPLAYER_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QSlider;
+class QLabel;
+class QUrl;
+QT_END_NAMESPACE
+
+class VideoPlayer : public QWidget
+{
+ Q_OBJECT
+public:
+ VideoPlayer(QWidget *parent = nullptr);
+ ~VideoPlayer();
+
+ void setUrl(const QUrl &url);
+
+public slots:
+ void openFile();
+ void play();
+
+private slots:
+ void mediaStateChanged(QMediaPlayer::PlaybackState state);
+ void positionChanged(qint64 position);
+ void durationChanged(qint64 duration);
+ void setPosition(int position);
+ void handleError();
+
+private:
+ QMediaPlayer *m_mediaPlayer;
+ QAbstractButton *m_playButton;
+ QSlider *m_positionSlider;
+ QLabel *m_errorLabel;
+};
+
+#endif
diff --git a/examples/multimediawidgets/videowidget/videowidget.pro b/examples/multimedia/videowidget/videowidget.pro
index 603996b2e..56312a028 100644
--- a/examples/multimediawidgets/videowidget/videowidget.pro
+++ b/examples/multimedia/videowidget/videowidget.pro
@@ -10,7 +10,7 @@ SOURCES = \
main.cpp \
videoplayer.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videowidget
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/videowidget
INSTALLS += target
QT+=widgets
diff --git a/examples/multimediawidgets/CMakeLists.txt b/examples/multimediawidgets/CMakeLists.txt
deleted file mode 100644
index 8d16458c2..000000000
--- a/examples/multimediawidgets/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-if(TARGET Qt::Widgets)
- qt_internal_add_example(camera)
- qt_internal_add_example(videographicsitem)
- qt_internal_add_example(videowidget)
- qt_internal_add_example(player)
-endif()
diff --git a/examples/multimediawidgets/camera/android/AndroidManifest.xml b/examples/multimediawidgets/camera/android/AndroidManifest.xml
deleted file mode 100644
index 29c4672cf..000000000
--- a/examples/multimediawidgets/camera/android/AndroidManifest.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example.camera"
- android:installLocation="auto"
- android:versionCode="-- %%INSERT_VERSION_CODE%% --"
- android:versionName="-- %%INSERT_VERSION_NAME%% --">
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default permissions. -->
- <!-- %%INSERT_PERMISSIONS -->
-
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default features. -->
- <!-- %%INSERT_FEATURES -->
-
- <supports-screens
- android:anyDensity="true"
- android:largeScreens="true"
- android:normalScreens="true"
- android:smallScreens="true" />
- <application
- android:name="org.qtproject.qt.android.bindings.QtApplication"
- android:extractNativeLibs="true"
- android:hardwareAccelerated="true"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:requestLegacyExternalStorage="true">
- <activity
- android:name="org.qtproject.qt.android.bindings.QtActivity"
- android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:launchMode="singleTop"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- <!-- Application arguments -->
-
- <meta-data
- android:name="android.app.arguments"
- android:value="-- %%INSERT_APP_ARGUMENTS%% --" />
- <!-- Application arguments -->
- <meta-data
- android:name="android.app.lib_name"
- android:value="-- %%INSERT_APP_LIB_NAME%% --" />
-
- <!-- Background running -->
- <!-- Warning: changing this value to true may cause unexpected crashes if the
- application still try to draw after
- "applicationStateChanged(Qt::ApplicationSuspended)" signal is sent! -->
- <meta-data
- android:name="android.app.background_running"
- android:value="false" />
- <!-- Background running -->
-
- <!-- extract android style -->
- <!-- available android:values :
- * default - In most cases this will be the same as "full", but it can also be
- * something else if needed, e.g., for compatibility reasons
- * full - useful QWidget & Quick Controls 1 apps
- * minimal - useful for Quick Controls 2 apps, it is much faster than "full"
- * none - useful for apps that don't use any of the above Qt modules -->
- <meta-data
- android:name="android.app.extract_android_style"
- android:value="minimal" />
- <!-- extract android style -->
- </activity>
- </application>
-</manifest>
diff --git a/examples/multimediawidgets/camera/camera.h b/examples/multimediawidgets/camera/camera.h
deleted file mode 100644
index 786a6f722..000000000
--- a/examples/multimediawidgets/camera/camera.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CAMERA_H
-#define CAMERA_H
-
-#include <QCamera>
-#include <QImageCapture>
-#include <QMediaRecorder>
-#include <QScopedPointer>
-#include <QMediaMetaData>
-#include <QMediaCaptureSession>
-#include <QMediaDevices>
-#include <QAudioInput>
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-namespace Ui { class Camera; }
-class QActionGroup;
-QT_END_NAMESPACE
-
-class MetaDataDialog;
-
-class Camera : public QMainWindow
-{
- Q_OBJECT
-
-public:
- Camera();
-
-public slots:
- void saveMetaData();
-
-private slots:
- void setCamera(const QCameraDevice &cameraDevice);
-
- void startCamera();
- void stopCamera();
-
- void record();
- void pause();
- void stop();
- void setMuted(bool);
-
- void takeImage();
- void displayCaptureError(int, QImageCapture::Error, const QString &errorString);
-
- void configureCaptureSettings();
- void configureVideoSettings();
- void configureImageSettings();
-
- void displayRecorderError();
- void displayCameraError();
-
- void updateCameraDevice(QAction *action);
-
- void updateCameraActive(bool active);
- void updateCaptureMode();
- void updateRecorderState(QMediaRecorder::RecorderState state);
- void setExposureCompensation(int index);
-
- void updateRecordTime();
-
- void processCapturedImage(int requestId, const QImage &img);
-
- void displayViewfinder();
- void displayCapturedImage();
-
- void readyForCapture(bool ready);
- void imageSaved(int id, const QString &fileName);
-
- void updateCameras();
-
- void showMetaDataDialog();
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
- void keyReleaseEvent(QKeyEvent *event) override;
- void closeEvent(QCloseEvent *event) override;
-
-private:
- Ui::Camera *ui;
-
- QActionGroup *videoDevicesGroup = nullptr;
-
- QMediaDevices m_devices;
- QMediaCaptureSession m_captureSession;
- QScopedPointer<QCamera> m_camera;
- QScopedPointer<QAudioInput> m_audioInput;
- QImageCapture *m_imageCapture;
- QScopedPointer<QMediaRecorder> m_mediaRecorder;
-
- bool m_isCapturingImage = false;
- bool m_applicationExiting = false;
- bool m_doImageCapture = true;
-
- MetaDataDialog *m_metaDataDialog = nullptr;
-};
-
-#endif
diff --git a/examples/multimediawidgets/camera/doc/images/camera-example.png b/examples/multimediawidgets/camera/doc/images/camera-example.png
deleted file mode 100644
index 12e1b5728..000000000
--- a/examples/multimediawidgets/camera/doc/images/camera-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimediawidgets/camera/doc/src/camera.qdoc b/examples/multimediawidgets/camera/doc/src/camera.qdoc
deleted file mode 100644
index 4db430fc3..000000000
--- a/examples/multimediawidgets/camera/doc/src/camera.qdoc
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*!
-
-\example multimediawidgets/camera
-\title Camera Example
-\ingroup multimedia_examples
-\ingroup video_examples
-\ingroup camera_examples
-\meta {tag} {widgets}
-\brief Shows how to capture a still image or record video.
-or video.
-
-The Camera Example demonstrates how you can use \l{Qt Multimedia} to implement
-some basic Camera functionality to take still images and record video clips
-with audio.
-
-\include examples-run.qdocinc
-
-The example implements a \c Camera class that acts as our camera interface. It
-has a user interface, control functions, setting values and a means of defining
-the location where the image or video clip is to be saved. It will also store
-the image and video settings.
-
-The Camera class uses:
-\list
- \li An instance of \l {QCamera}, the API class interface to the hardware.
- \li An instance of \l {QImageCapture} to take still images.
- \li An instance of \l {QMediaRecorder} to record video. It also contains
- the user interface object.
-\endlist
-
-The Camera constructor does some basic initialization:
-\list
- \li The user interface is initialized.
- \li UI signals are connected to slots that react to the triggering event.
-\endlist
-However, most of the work is done when the \e{setCamera()} function is called,
-passing in a \l QCameraDevice.
-
-\e{setCamera()} sets up various connections between the user interface and the
-functionality of the Camera class using signals and slots. It also instantiates
-and initializes the \l {QCamera}, \l {QImageCapture}, and \l {QMediaRecorder}
-objects mentioned above. The still and video recording visual tabs are enabled
-and finally the \l {QCamera::start}{start()} function of the \l{QCamera}
-object is called.
-
-Now that the camera is ready for user commands it waits for a suitable event.
-Such an event can be a key press of either the \l {Qt::Key_CameraFocus} or
-\l {Qt::Key_Camera} buttons on the application window. Camera focus will
-simply display the preview and lock the camera settings. \c Key_Camera will
-either call \e{takeImage()} if doing an image capture, or call
-\c record() or \c stop() (if already recording) on the QMediaRecorder instance
-when recording video.
-
-\image camera-example.png
-
-*/
diff --git a/examples/multimediawidgets/camera/imagesettings.cpp b/examples/multimediawidgets/camera/imagesettings.cpp
deleted file mode 100644
index a14e519e7..000000000
--- a/examples/multimediawidgets/camera/imagesettings.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "imagesettings.h"
-#include "ui_imagesettings.h"
-
-#include <QComboBox>
-#include <QDebug>
-#include <QImageCapture>
-#include <QCamera>
-#include <QMediaCaptureSession>
-
-ImageSettings::ImageSettings(QImageCapture *imageCapture, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::ImageSettingsUi),
- imagecapture(imageCapture)
-{
- ui->setupUi(this);
-
- //image codecs
- ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString()));
- const auto supportedImageFormats = QImageCapture::supportedFormats();
- for (const auto &f : supportedImageFormats) {
- QString description = QImageCapture::fileFormatDescription(f);
- ui->imageCodecBox->addItem(QImageCapture::fileFormatName(f) + ": " + description, QVariant::fromValue(f));
- }
-
- ui->imageQualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
-
- ui->imageResolutionBox->addItem(tr("Default Resolution"));
- const QList<QSize> supportedResolutions = imagecapture->captureSession()->camera()->cameraDevice().photoResolutions();
- for (const QSize &resolution : supportedResolutions) {
- ui->imageResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
- QVariant(resolution));
- }
-
- selectComboBoxItem(ui->imageCodecBox, QVariant::fromValue(imagecapture->fileFormat()));
- selectComboBoxItem(ui->imageResolutionBox, QVariant(imagecapture->resolution()));
- ui->imageQualitySlider->setValue(imagecapture->quality());
-}
-
-ImageSettings::~ImageSettings()
-{
- delete ui;
-}
-
-void ImageSettings::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void ImageSettings::applyImageSettings() const
-{
- imagecapture->setFileFormat(boxValue(ui->imageCodecBox).value<QImageCapture::FileFormat>());
- imagecapture->setQuality(QImageCapture::Quality(ui->imageQualitySlider->value()));
- imagecapture->setResolution(boxValue(ui->imageResolutionBox).toSize());
-}
-
-QVariant ImageSettings::boxValue(const QComboBox *box) const
-{
- int idx = box->currentIndex();
- if (idx == -1)
- return QVariant();
-
- return box->itemData(idx);
-}
-
-void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
-{
- for (int i = 0; i < box->count(); ++i) {
- if (box->itemData(i) == value) {
- box->setCurrentIndex(i);
- break;
- }
- }
-}
diff --git a/examples/multimediawidgets/camera/imagesettings.h b/examples/multimediawidgets/camera/imagesettings.h
deleted file mode 100644
index 6564bd91c..000000000
--- a/examples/multimediawidgets/camera/imagesettings.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef IMAGESETTINGS_H
-#define IMAGESETTINGS_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QImageCapture;
-namespace Ui { class ImageSettingsUi; }
-QT_END_NAMESPACE
-
-class ImageSettings : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ImageSettings(QImageCapture *imageCapture, QWidget *parent = nullptr);
- ~ImageSettings();
-
- void applyImageSettings() const;
-
- QString format() const;
- void setFormat(const QString &format);
-
-protected:
- void changeEvent(QEvent *e) override;
-
-private:
- QVariant boxValue(const QComboBox *box) const;
- void selectComboBoxItem(QComboBox *box, const QVariant &value);
-
- Ui::ImageSettingsUi *ui;
- QImageCapture *imagecapture;
-};
-
-#endif // IMAGESETTINGS_H
diff --git a/examples/multimediawidgets/camera/main.cpp b/examples/multimediawidgets/camera/main.cpp
deleted file mode 100644
index 04982a725..000000000
--- a/examples/multimediawidgets/camera/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "camera.h"
-
-#include <QtWidgets>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- Camera camera;
- camera.show();
-
- return app.exec();
-};
diff --git a/examples/multimediawidgets/camera/metadatadialog.cpp b/examples/multimediawidgets/camera/metadatadialog.cpp
deleted file mode 100644
index 28d8db035..000000000
--- a/examples/multimediawidgets/camera/metadatadialog.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "metadatadialog.h"
-#include "camera.h"
-
-#include <QtWidgets>
-#include <QFormLayout>
-#include <QMediaMetaData>
-
-MetaDataDialog::MetaDataDialog(QWidget *parent)
- : QDialog(parent)
-{
- QFormLayout *metaDataLayout = new QFormLayout;
- for (int key = 0; key < QMediaMetaData::NumMetaData; key++) {
- QString label = QMediaMetaData::metaDataKeyToString(static_cast<QMediaMetaData::Key>(key));
- m_metaDataFields[key] = new QLineEdit;
- if (key == QMediaMetaData::ThumbnailImage) {
- QPushButton *openThumbnail = new QPushButton(tr("Open"));
- connect(openThumbnail, &QPushButton::clicked, this, &MetaDataDialog::openThumbnailImage);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_metaDataFields[key]);
- layout->addWidget(openThumbnail);
- metaDataLayout->addRow(label, layout);
- }
- else if (key == QMediaMetaData::CoverArtImage) {
- QPushButton *openCoverArt = new QPushButton(tr("Open"));
- connect(openCoverArt, &QPushButton::clicked, this, &MetaDataDialog::openCoverArtImage);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_metaDataFields[key]);
- layout->addWidget(openCoverArt);
- metaDataLayout->addRow(label, layout);
- }
- else {
- if (key == QMediaMetaData::Title)
- m_metaDataFields[key]->setText(tr("Qt Camera Example"));
- else if (key == QMediaMetaData::Author)
- m_metaDataFields[key]->setText(tr("The Qt Company"));
- else if (key == QMediaMetaData::Date)
- m_metaDataFields[key]->setText(QDateTime::currentDateTime().toString());
- else if (key == QMediaMetaData::Date)
- m_metaDataFields[key]->setText(QDate::currentDate().toString());
- metaDataLayout->addRow(label, m_metaDataFields[key]);
- }
- }
-
- QWidget *viewport = new QWidget;
- viewport->setLayout(metaDataLayout);
- QScrollArea *scrollArea = new QScrollArea;
- scrollArea->setWidget(viewport);
- QVBoxLayout *dialogLayout = new QVBoxLayout();
- this->setLayout(dialogLayout);
- this->layout()->addWidget(scrollArea);
-
- auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
- | QDialogButtonBox::Cancel);
- this->layout()->addWidget(buttonBox);
-
- this->setWindowTitle(tr("Set Metadata"));
- this->resize(400, 300);
-
- connect(buttonBox, &QDialogButtonBox::accepted, this, &MetaDataDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &MetaDataDialog::reject);
-}
-
-void MetaDataDialog::openThumbnailImage()
-{
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open Image"), QDir::currentPath(), tr("Image Files (*.png *.jpg *.bmp)"));
- if (!fileName.isEmpty())
- m_metaDataFields[QMediaMetaData::ThumbnailImage]->setText(fileName);
-}
-
-void MetaDataDialog::openCoverArtImage()
-{
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open Image"), QDir::currentPath(), tr("Image Files (*.png *.jpg *.bmp)"));
- if (!fileName.isEmpty())
- m_metaDataFields[QMediaMetaData::CoverArtImage]->setText(fileName);
-}
diff --git a/examples/multimediawidgets/camera/metadatadialog.h b/examples/multimediawidgets/camera/metadatadialog.h
deleted file mode 100644
index 0269e3479..000000000
--- a/examples/multimediawidgets/camera/metadatadialog.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-#include <QMediaMetaData>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-QT_END_NAMESPACE
-
-//! [0]
-class MetaDataDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit MetaDataDialog(QWidget *parent = nullptr);
-
- QLineEdit *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
-
-private slots:
- void openThumbnailImage();
- void openCoverArtImage();
-};
-//! [0]
-
-#endif
diff --git a/examples/multimediawidgets/camera/videosettings.cpp b/examples/multimediawidgets/camera/videosettings.cpp
deleted file mode 100644
index f515d1bca..000000000
--- a/examples/multimediawidgets/camera/videosettings.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "videosettings.h"
-#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
-#include "ui_videosettings_mobile.h"
-#else
-#include "ui_videosettings.h"
-#endif
-
-#include <QComboBox>
-#include <QSpinBox>
-#include <QDebug>
-#include <QMediaRecorder>
-#include <QMediaFormat>
-#include <QAudioDevice>
-#include <QMediaCaptureSession>
-#include <QCameraDevice>
-#include <QCamera>
-#include <QAudioInput>
-
-QString toFormattedString(const QCameraFormat &cameraFormat)
-{
- QString string;
- const auto &separator = QStringLiteral(" ");
-
- string.append(QVideoFrameFormat::pixelFormatToString(cameraFormat.pixelFormat()));
- string.append(separator);
-
- string.append(QString::number(cameraFormat.resolution().width()));
- string.append(QStringLiteral("x"));
- string.append(QString::number(cameraFormat.resolution().height()));
- string.append(separator);
-
- string.append(QString::number(cameraFormat.minFrameRate()));
- string.append(QStringLiteral("-"));
- string.append(QString::number(cameraFormat.maxFrameRate()));
- string.append(QStringLiteral("FPS"));
-
- return string;
-}
-
-VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent)
- : QDialog(parent),
- ui(new Ui::VideoSettingsUi),
- mediaRecorder(mediaRecorder)
-{
- ui->setupUi(this);
-
- //sample rate:
- auto audioDevice = mediaRecorder->captureSession()->audioInput()->device();
- ui->audioSampleRateBox->setRange(audioDevice.minimumSampleRate(),
- audioDevice.maximumSampleRate());
-
- // camera format
- ui->videoFormatBox->addItem(tr("Default camera format"));
-
- const QList<QCameraFormat> videoFormats =
- mediaRecorder->captureSession()->camera()->cameraDevice().videoFormats();
-
- for (const QCameraFormat &format : videoFormats) {
- ui->videoFormatBox->addItem(toFormattedString(format), QVariant::fromValue(format));
- }
-
- connect(ui->videoFormatBox, &QComboBox::currentIndexChanged, [this](int /*index*/) {
- const auto &cameraFormat = boxValue(ui->videoFormatBox).value<QCameraFormat>();
- ui->fpsSlider->setRange(cameraFormat.minFrameRate(), cameraFormat.maxFrameRate());
- ui->fpsSpinBox->setRange(cameraFormat.minFrameRate(), cameraFormat.maxFrameRate());
- });
-
- auto currentCameraFormat = mediaRecorder->captureSession()->camera()->cameraFormat();
- ui->fpsSlider->setRange(currentCameraFormat.minFrameRate(), currentCameraFormat.maxFrameRate());
- ui->fpsSpinBox->setRange(currentCameraFormat.minFrameRate(),
- currentCameraFormat.maxFrameRate());
-
- connect(ui->fpsSlider, &QSlider::valueChanged, ui->fpsSpinBox, &QSpinBox::setValue);
- connect(ui->fpsSpinBox, &QSpinBox::valueChanged, ui->fpsSlider, &QSlider::setValue);
-
- updateFormatsAndCodecs();
- connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this, &VideoSettings::updateFormatsAndCodecs);
- connect(ui->videoCodecBox, &QComboBox::currentIndexChanged, this, &VideoSettings::updateFormatsAndCodecs);
- connect(ui->containerFormatBox, &QComboBox::currentIndexChanged, this, &VideoSettings::updateFormatsAndCodecs);
-
- ui->qualitySlider->setRange(0, int(QMediaRecorder::VeryHighQuality));
-
- QMediaFormat format = mediaRecorder->mediaFormat();
- selectComboBoxItem(ui->containerFormatBox, QVariant::fromValue(format.fileFormat()));
- selectComboBoxItem(ui->audioCodecBox, QVariant::fromValue(format.audioCodec()));
- selectComboBoxItem(ui->videoCodecBox, QVariant::fromValue(format.videoCodec()));
-
- ui->qualitySlider->setValue(mediaRecorder->quality());
- ui->audioSampleRateBox->setValue(mediaRecorder->audioSampleRate());
- selectComboBoxItem(
- ui->videoFormatBox,
- QVariant::fromValue(mediaRecorder->captureSession()->camera()->cameraFormat()));
-
- ui->fpsSlider->setValue(mediaRecorder->videoFrameRate());
- ui->fpsSpinBox->setValue(mediaRecorder->videoFrameRate());
-}
-
-VideoSettings::~VideoSettings()
-{
- delete ui;
-}
-
-void VideoSettings::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void VideoSettings::applySettings()
-{
- QMediaFormat format;
- format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
- format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
- format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
-
- mediaRecorder->setMediaFormat(format);
- mediaRecorder->setQuality(QMediaRecorder::Quality(ui->qualitySlider->value()));
- mediaRecorder->setAudioSampleRate(ui->audioSampleRateBox->value());
-
- const auto &cameraFormat = boxValue(ui->videoFormatBox).value<QCameraFormat>();
- mediaRecorder->setVideoResolution(cameraFormat.resolution());
- mediaRecorder->setVideoFrameRate(ui->fpsSlider->value());
-
- mediaRecorder->captureSession()->camera()->setCameraFormat(cameraFormat);
-}
-
-void VideoSettings::updateFormatsAndCodecs()
-{
- if (m_updatingFormats)
- return;
- m_updatingFormats = true;
-
- QMediaFormat format;
- if (ui->containerFormatBox->count())
- format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
- if (ui->audioCodecBox->count())
- format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
- if (ui->videoCodecBox->count())
- format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
-
- int currentIndex = 0;
- ui->audioCodecBox->clear();
- ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
- for (auto codec : format.supportedAudioCodecs(QMediaFormat::Encode)) {
- if (codec == format.audioCodec())
- currentIndex = ui->audioCodecBox->count();
- ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec), QVariant::fromValue(codec));
- }
- ui->audioCodecBox->setCurrentIndex(currentIndex);
-
- currentIndex = 0;
- ui->videoCodecBox->clear();
- ui->videoCodecBox->addItem(tr("Default video codec"), QVariant::fromValue(QMediaFormat::VideoCodec::Unspecified));
- for (auto codec : format.supportedVideoCodecs(QMediaFormat::Encode)) {
- if (codec == format.videoCodec())
- currentIndex = ui->videoCodecBox->count();
- ui->videoCodecBox->addItem(QMediaFormat::videoCodecDescription(codec), QVariant::fromValue(codec));
- }
- ui->videoCodecBox->setCurrentIndex(currentIndex);
-
- currentIndex = 0;
- ui->containerFormatBox->clear();
- ui->containerFormatBox->addItem(tr("Default file format"), QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
- for (auto container : format.supportedFileFormats(QMediaFormat::Encode)) {
- if (container == format.fileFormat())
- currentIndex = ui->containerFormatBox->count();
- ui->containerFormatBox->addItem(QMediaFormat::fileFormatDescription(container), QVariant::fromValue(container));
- }
- ui->containerFormatBox->setCurrentIndex(currentIndex);
-
- m_updatingFormats = false;
-
-}
-
-QVariant VideoSettings::boxValue(const QComboBox *box) const
-{
- int idx = box->currentIndex();
- if (idx == -1)
- return QVariant();
-
- return box->itemData(idx);
-}
-
-void VideoSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
-{
- for (int i = 0; i < box->count(); ++i) {
- if (box->itemData(i) == value) {
- box->setCurrentIndex(i);
- break;
- }
- }
-}
diff --git a/examples/multimediawidgets/camera/videosettings.h b/examples/multimediawidgets/camera/videosettings.h
deleted file mode 100644
index 14e00bc25..000000000
--- a/examples/multimediawidgets/camera/videosettings.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VIDEOSETTINGS_H
-#define VIDEOSETTINGS_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QMediaRecorder;
-namespace Ui { class VideoSettingsUi; }
-QT_END_NAMESPACE
-
-class VideoSettings : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr);
- ~VideoSettings();
-
- void applySettings();
- void updateFormatsAndCodecs();
-
-protected:
- void changeEvent(QEvent *e) override;
-
-private:
- QVariant boxValue(const QComboBox*) const;
- void selectComboBoxItem(QComboBox *box, const QVariant &value);
-
- Ui::VideoSettingsUi *ui;
- QMediaRecorder *mediaRecorder;
- bool m_updatingFormats = false;
-};
-
-#endif // VIDEOSETTINGS_H
diff --git a/examples/multimediawidgets/multimediawidgets.pro b/examples/multimediawidgets/multimediawidgets.pro
deleted file mode 100644
index aa74b00f0..000000000
--- a/examples/multimediawidgets/multimediawidgets.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-
-# These examples all need widgets for now (using creator templates that use widgets)
-qtHaveModule(widgets) {
- SUBDIRS += \
- camera \
- videographicsitem \
- videowidget \
- player
-}
diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp
deleted file mode 100644
index 49c82d877..000000000
--- a/examples/multimediawidgets/player/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "player.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QDir>
-#include <QUrl>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Player Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt MultiMedia Player Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL(s) to open.");
- parser.process(app);
-
- Player player;
-
- if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
- QList<QUrl> urls;
- for (auto &a: parser.positionalArguments())
- urls.append(QUrl::fromUserInput(a, QDir::currentPath()));
- player.addToPlaylist(urls);
- }
-
- player.show();
- return app.exec();
-}
diff --git a/examples/multimediawidgets/player/player.h b/examples/multimediawidgets/player/player.h
deleted file mode 100644
index 3f1c51795..000000000
--- a/examples/multimediawidgets/player/player.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PLAYER_H
-#define PLAYER_H
-
-#include "qmediaplaylist.h"
-
-#include <QWidget>
-#include <QMediaPlayer>
-#include <QMediaMetaData>
-
-QT_BEGIN_NAMESPACE
-class QAbstractItemView;
-class QLabel;
-class QMediaPlayer;
-class QModelIndex;
-class QPushButton;
-class QComboBox;
-class QSlider;
-class QStatusBar;
-class QVideoWidget;
-QT_END_NAMESPACE
-
-class PlaylistModel;
-
-class Player : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit Player(QWidget *parent = nullptr);
- ~Player() = default;
-
- bool isPlayerAvailable() const;
-
- void addToPlaylist(const QList<QUrl> &urls);
-
-signals:
- void fullScreenChanged(bool fullScreen);
-
-private slots:
- void open();
- void durationChanged(qint64 duration);
- void positionChanged(qint64 progress);
- void metaDataChanged();
- void tracksChanged();
-
- void previousClicked();
-
- void seek(int mseconds);
- void jump(const QModelIndex &index);
- void playlistPositionChanged(int);
-
- void statusChanged(QMediaPlayer::MediaStatus status);
- void bufferingProgress(float progress);
- void videoAvailableChanged(bool available);
-
- void selectAudioStream();
- void selectVideoStream();
- void selectSubtitleStream();
-
- void displayErrorMessage();
-
- void audioOutputChanged(int);
-
-private:
- void setTrackInfo(const QString &info);
- void setStatusInfo(const QString &info);
- void handleCursor(QMediaPlayer::MediaStatus status);
- void updateDurationInfo(qint64 currentInfo);
- QString trackName(const QMediaMetaData &metaData, int index);
-
- QMediaPlayer *m_player = nullptr;
- QAudioOutput *m_audioOutput = nullptr;
- QMediaPlaylist *m_playlist = nullptr;
- QVideoWidget *m_videoWidget = nullptr;
- QSlider *m_slider = nullptr;
- QLabel *m_labelDuration = nullptr;
- QPushButton *m_fullScreenButton = nullptr;
- QComboBox *m_audioOutputCombo = nullptr;
- QLabel *m_statusLabel = nullptr;
- QStatusBar *m_statusBar = nullptr;
-
- QComboBox *m_audioTracks = nullptr;
- QComboBox *m_videoTracks = nullptr;
- QComboBox *m_subtitleTracks = nullptr;
-
- PlaylistModel *m_playlistModel = nullptr;
- QAbstractItemView *m_playlistView = nullptr;
- QString m_trackInfo;
- QString m_statusInfo;
- qint64 m_duration;
-
- QWidget *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
- QLabel *m_metaDataLabels[QMediaMetaData::NumMetaData] = {};
-};
-
-#endif // PLAYER_H
diff --git a/examples/multimediawidgets/player/playercontrols.cpp b/examples/multimediawidgets/player/playercontrols.cpp
deleted file mode 100644
index 73cf9ae21..000000000
--- a/examples/multimediawidgets/player/playercontrols.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "playercontrols.h"
-
-#include <QBoxLayout>
-#include <QSlider>
-#include <QStyle>
-#include <QToolButton>
-#include <QComboBox>
-#include <QAudio>
-
-PlayerControls::PlayerControls(QWidget *parent)
- : QWidget(parent)
-{
- m_playButton = new QToolButton(this);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(m_playButton, &QAbstractButton::clicked, this, &PlayerControls::playClicked);
-
- m_stopButton = new QToolButton(this);
- m_stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
- m_stopButton->setEnabled(false);
-
- connect(m_stopButton, &QAbstractButton::clicked, this, &PlayerControls::stop);
-
- m_nextButton = new QToolButton(this);
- m_nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
-
- connect(m_nextButton, &QAbstractButton::clicked, this, &PlayerControls::next);
-
- m_previousButton = new QToolButton(this);
- m_previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
-
- connect(m_previousButton, &QAbstractButton::clicked, this, &PlayerControls::previous);
-
- m_muteButton = new QToolButton(this);
- m_muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume));
-
- connect(m_muteButton, &QAbstractButton::clicked, this, &PlayerControls::muteClicked);
-
- m_volumeSlider = new QSlider(Qt::Horizontal, this);
- m_volumeSlider->setRange(0, 100);
-
- connect(m_volumeSlider, &QSlider::valueChanged, this, &PlayerControls::onVolumeSliderValueChanged);
-
- m_rateBox = new QComboBox(this);
- m_rateBox->addItem("0.5x", QVariant(0.5));
- m_rateBox->addItem("1.0x", QVariant(1.0));
- m_rateBox->addItem("2.0x", QVariant(2.0));
- m_rateBox->setCurrentIndex(1);
-
- connect(m_rateBox, QOverload<int>::of(&QComboBox::activated), this, &PlayerControls::updateRate);
-
- QBoxLayout *layout = new QHBoxLayout;
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(m_stopButton);
- layout->addWidget(m_previousButton);
- layout->addWidget(m_playButton);
- layout->addWidget(m_nextButton);
- layout->addWidget(m_muteButton);
- layout->addWidget(m_volumeSlider);
- layout->addWidget(m_rateBox);
- setLayout(layout);
-}
-
-QMediaPlayer::PlaybackState PlayerControls::state() const
-{
- return m_playerState;
-}
-
-void PlayerControls::setState(QMediaPlayer::PlaybackState state)
-{
- if (state != m_playerState) {
- m_playerState = state;
-
- switch (state) {
- case QMediaPlayer::StoppedState:
- m_stopButton->setEnabled(false);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- case QMediaPlayer::PlayingState:
- m_stopButton->setEnabled(true);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- case QMediaPlayer::PausedState:
- m_stopButton->setEnabled(true);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
- }
-}
-
-float PlayerControls::volume() const
-{
- qreal linearVolume = QAudio::convertVolume(m_volumeSlider->value() / qreal(100),
- QAudio::LogarithmicVolumeScale,
- QAudio::LinearVolumeScale);
-
- return linearVolume;
-}
-
-void PlayerControls::setVolume(float volume)
-{
- qreal logarithmicVolume = QAudio::convertVolume(volume,
- QAudio::LinearVolumeScale,
- QAudio::LogarithmicVolumeScale);
-
- m_volumeSlider->setValue(qRound(logarithmicVolume * 100));
-}
-
-bool PlayerControls::isMuted() const
-{
- return m_playerMuted;
-}
-
-void PlayerControls::setMuted(bool muted)
-{
- if (muted != m_playerMuted) {
- m_playerMuted = muted;
-
- m_muteButton->setIcon(style()->standardIcon(muted
- ? QStyle::SP_MediaVolumeMuted
- : QStyle::SP_MediaVolume));
- }
-}
-
-void PlayerControls::playClicked()
-{
- switch (m_playerState) {
- case QMediaPlayer::StoppedState:
- case QMediaPlayer::PausedState:
- emit play();
- break;
- case QMediaPlayer::PlayingState:
- emit pause();
- break;
- }
-}
-
-void PlayerControls::muteClicked()
-{
- emit changeMuting(!m_playerMuted);
-}
-
-qreal PlayerControls::playbackRate() const
-{
- return m_rateBox->itemData(m_rateBox->currentIndex()).toDouble();
-}
-
-void PlayerControls::setPlaybackRate(float rate)
-{
- for (int i = 0; i < m_rateBox->count(); ++i) {
- if (qFuzzyCompare(rate, float(m_rateBox->itemData(i).toDouble()))) {
- m_rateBox->setCurrentIndex(i);
- return;
- }
- }
-
- m_rateBox->addItem(QString("%1x").arg(rate), QVariant(rate));
- m_rateBox->setCurrentIndex(m_rateBox->count() - 1);
-}
-
-void PlayerControls::updateRate()
-{
- emit changeRate(playbackRate());
-}
-
-void PlayerControls::onVolumeSliderValueChanged()
-{
- emit changeVolume(volume());
-}
diff --git a/examples/multimediawidgets/player/playercontrols.h b/examples/multimediawidgets/player/playercontrols.h
deleted file mode 100644
index 927f72608..000000000
--- a/examples/multimediawidgets/player/playercontrols.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PLAYERCONTROLS_H
-#define PLAYERCONTROLS_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QAbstractSlider;
-class QComboBox;
-QT_END_NAMESPACE
-
-class PlayerControls : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PlayerControls(QWidget *parent = nullptr);
-
- QMediaPlayer::PlaybackState state() const;
- float volume() const;
- bool isMuted() const;
- qreal playbackRate() const;
-
-public slots:
- void setState(QMediaPlayer::PlaybackState state);
- void setVolume(float volume);
- void setMuted(bool muted);
- void setPlaybackRate(float rate);
-
-signals:
- void play();
- void pause();
- void stop();
- void next();
- void previous();
- void changeVolume(float volume);
- void changeMuting(bool muting);
- void changeRate(qreal rate);
-
-private slots:
- void playClicked();
- void muteClicked();
- void updateRate();
- void onVolumeSliderValueChanged();
-
-private:
- QMediaPlayer::PlaybackState m_playerState = QMediaPlayer::StoppedState;
- bool m_playerMuted = false;
- QAbstractButton *m_playButton = nullptr;
- QAbstractButton *m_stopButton = nullptr;
- QAbstractButton *m_nextButton = nullptr;
- QAbstractButton *m_previousButton = nullptr;
- QAbstractButton *m_muteButton = nullptr;
- QAbstractSlider *m_volumeSlider = nullptr;
- QComboBox *m_rateBox = nullptr;
-};
-
-#endif // PLAYERCONTROLS_H
diff --git a/examples/multimediawidgets/player/playlistmodel.cpp b/examples/multimediawidgets/player/playlistmodel.cpp
deleted file mode 100644
index 28fc58a83..000000000
--- a/examples/multimediawidgets/player/playlistmodel.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "playlistmodel.h"
-#include "qmediaplaylist.h"
-
-#include <QFileInfo>
-#include <QUrl>
-
-PlaylistModel::PlaylistModel(QObject *parent)
- : QAbstractItemModel(parent)
-{
- m_playlist.reset(new QMediaPlaylist);
- connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems);
-}
-
-PlaylistModel::~PlaylistModel() = default;
-
-int PlaylistModel::rowCount(const QModelIndex &parent) const
-{
- return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0;
-}
-
-int PlaylistModel::columnCount(const QModelIndex &parent) const
-{
- return !parent.isValid() ? ColumnCount : 0;
-}
-
-QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const
-{
- return m_playlist && !parent.isValid()
- && row >= 0 && row < m_playlist->mediaCount()
- && column >= 0 && column < ColumnCount
- ? createIndex(row, column)
- : QModelIndex();
-}
-
-QModelIndex PlaylistModel::parent(const QModelIndex &child) const
-{
- Q_UNUSED(child);
-
- return QModelIndex();
-}
-
-QVariant PlaylistModel::data(const QModelIndex &index, int role) const
-{
- if (index.isValid() && role == Qt::DisplayRole) {
- QVariant value = m_data[index];
- if (!value.isValid() && index.column() == Title) {
- QUrl location = m_playlist->media(index.row());
- return QFileInfo(location.path()).fileName();
- }
-
- return value;
- }
- return QVariant();
-}
-
-QMediaPlaylist *PlaylistModel::playlist() const
-{
- return m_playlist.data();
-}
-
-bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- Q_UNUSED(role);
- m_data[index] = value;
- emit dataChanged(index, index);
- return true;
-}
-
-void PlaylistModel::beginInsertItems(int start, int end)
-{
- m_data.clear();
- beginInsertRows(QModelIndex(), start, end);
-}
-
-void PlaylistModel::endInsertItems()
-{
- endInsertRows();
-}
-
-void PlaylistModel::beginRemoveItems(int start, int end)
-{
- m_data.clear();
- beginRemoveRows(QModelIndex(), start, end);
-}
-
-void PlaylistModel::endRemoveItems()
-{
- endInsertRows();
-}
-
-void PlaylistModel::changeItems(int start, int end)
-{
- m_data.clear();
- emit dataChanged(index(start,0), index(end,ColumnCount));
-}
diff --git a/examples/multimediawidgets/player/playlistmodel.h b/examples/multimediawidgets/player/playlistmodel.h
deleted file mode 100644
index c2bc8319a..000000000
--- a/examples/multimediawidgets/player/playlistmodel.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PLAYLISTMODEL_H
-#define PLAYLISTMODEL_H
-
-#include <QAbstractItemModel>
-#include <QScopedPointer>
-
-QT_BEGIN_NAMESPACE
-class QMediaPlaylist;
-QT_END_NAMESPACE
-
-class PlaylistModel : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- enum Column
- {
- Title = 0,
- ColumnCount
- };
-
- explicit PlaylistModel(QObject *parent = nullptr);
- ~PlaylistModel();
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
-
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
- QModelIndex parent(const QModelIndex &child) const override;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
-
- QMediaPlaylist *playlist() const;
-
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override;
-
-private slots:
- void beginInsertItems(int start, int end);
- void endInsertItems();
- void beginRemoveItems(int start, int end);
- void endRemoveItems();
- void changeItems(int start, int end);
-
-private:
- QScopedPointer<QMediaPlaylist> m_playlist;
- QMap<QModelIndex, QVariant> m_data;
-};
-
-#endif // PLAYLISTMODEL_H
diff --git a/examples/multimediawidgets/player/qmediaplaylist_p.h b/examples/multimediawidgets/player/qmediaplaylist_p.h
deleted file mode 100644
index a09831377..000000000
--- a/examples/multimediawidgets/player/qmediaplaylist_p.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMEDIAPLAYLIST_P_H
-#define QMEDIAPLAYLIST_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qmediaplaylist.h"
-#include "qplaylistfileparser_p.h"
-
-#include <QtCore/qdebug.h>
-
-#ifdef Q_MOC_RUN
-# pragma Q_MOC_EXPAND_MACROS
-#endif
-
-QT_BEGIN_NAMESPACE
-
-
-class QMediaPlaylistControl;
-
-class QMediaPlaylistPrivate
-{
- Q_DECLARE_PUBLIC(QMediaPlaylist)
-public:
- QMediaPlaylistPrivate()
- : error(QMediaPlaylist::NoError)
- {
- }
-
- virtual ~QMediaPlaylistPrivate()
- {
- if (parser)
- delete parser;
- }
-
- void loadFailed(QMediaPlaylist::Error error, const QString &errorString)
- {
- this->error = error;
- this->errorString = errorString;
-
- emit q_ptr->loadFailed();
- }
-
- void loadFinished()
- {
- q_ptr->addMedia(parser->playlist);
-
- emit q_ptr->loaded();
- }
-
- bool checkFormat(const char *format) const
- {
- QLatin1String f(format);
- QPlaylistFileParser::FileType type = format ? QPlaylistFileParser::UNKNOWN : QPlaylistFileParser::M3U8;
- if (format) {
- if (f == QLatin1String("m3u") || f == QLatin1String("text/uri-list") ||
- f == QLatin1String("audio/x-mpegurl") || f == QLatin1String("audio/mpegurl"))
- type = QPlaylistFileParser::M3U;
- else if (f == QLatin1String("m3u8") || f == QLatin1String("application/x-mpegURL") ||
- f == QLatin1String("application/vnd.apple.mpegurl"))
- type = QPlaylistFileParser::M3U8;
- }
-
- if (type == QPlaylistFileParser::UNKNOWN || type == QPlaylistFileParser::PLS) {
- error = QMediaPlaylist::FormatNotSupportedError;
- errorString = QMediaPlaylist::tr("This file format is not supported.");
- return false;
- }
- return true;
- }
-
- void ensureParser()
- {
- if (parser)
- return;
-
- parser = new QPlaylistFileParser(q_ptr);
- QObject::connect(parser, &QPlaylistFileParser::finished, [this]() { loadFinished(); });
- QObject::connect(parser, &QPlaylistFileParser::error,
- [this](QMediaPlaylist::Error err, const QString& errorMsg) { loadFailed(err, errorMsg); });
- }
-
- int nextPosition(int steps) const;
- int prevPosition(int steps) const;
-
- QList<QUrl> playlist;
-
- int currentPos = -1;
- QMediaPlaylist::PlaybackMode playbackMode = QMediaPlaylist::Sequential;
-
- QPlaylistFileParser *parser = nullptr;
- mutable QMediaPlaylist::Error error;
- mutable QString errorString;
-
- QMediaPlaylist *q_ptr;
-};
-
-QT_END_NAMESPACE
-
-
-#endif // QMEDIAPLAYLIST_P_H
diff --git a/examples/multimediawidgets/player/qplaylistfileparser_p.h b/examples/multimediawidgets/player/qplaylistfileparser_p.h
deleted file mode 100644
index 98011fce0..000000000
--- a/examples/multimediawidgets/player/qplaylistfileparser_p.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PLAYLISTFILEPARSER_P_H
-#define PLAYLISTFILEPARSER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qtmultimediaglobal.h"
-#include "qmediaplaylist.h"
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QIODevice;
-class QUrl;
-class QNetworkRequest;
-
-class QPlaylistFileParserPrivate;
-
-class QPlaylistFileParser : public QObject
-{
- Q_OBJECT
-public:
- QPlaylistFileParser(QObject *parent = nullptr);
- ~QPlaylistFileParser();
-
- enum FileType
- {
- UNKNOWN,
- M3U,
- M3U8, // UTF-8 version of M3U
- PLS
- };
-
- void start(const QUrl &media, QIODevice *stream = nullptr, const QString &mimeType = QString());
- void start(const QUrl &request, const QString &mimeType = QString());
- void start(QIODevice *stream, const QString &mimeType = QString());
- void abort();
-
- QList<QUrl> playlist;
-
-Q_SIGNALS:
- void newItem(const QVariant& content);
- void finished();
- void error(QMediaPlaylist::Error err, const QString& errorMsg);
-
-private Q_SLOTS:
- void handleData();
- void handleError();
-
-private:
-
- static FileType findByMimeType(const QString &mime);
- static FileType findBySuffixType(const QString &suffix);
- static FileType findByDataHeader(const char *data, quint32 size);
- static FileType findPlaylistType(QIODevice *device,
- const QString& mime);
- static FileType findPlaylistType(const QString &suffix,
- const QString& mime,
- const char *data = nullptr,
- quint32 size = 0);
-
- Q_DISABLE_COPY(QPlaylistFileParser)
- Q_DECLARE_PRIVATE(QPlaylistFileParser)
- QScopedPointer<QPlaylistFileParserPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // PLAYLISTFILEPARSER_P_H
diff --git a/examples/multimediawidgets/player/videowidget.cpp b/examples/multimediawidgets/player/videowidget.cpp
deleted file mode 100644
index a97e1d940..000000000
--- a/examples/multimediawidgets/player/videowidget.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "videowidget.h"
-
-#include <QKeyEvent>
-#include <QMouseEvent>
-
-VideoWidget::VideoWidget(QWidget *parent)
- : QVideoWidget(parent)
-{
- setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
-
- QPalette p = palette();
- p.setColor(QPalette::Window, Qt::black);
- setPalette(p);
-
-#ifndef Q_OS_ANDROID // QTBUG-95723
- setAttribute(Qt::WA_OpaquePaintEvent);
-#endif
-}
-
-void VideoWidget::keyPressEvent(QKeyEvent *event)
-{
- if ((event->key() == Qt::Key_Escape || event->key() == Qt::Key_Back) && isFullScreen()) {
- setFullScreen(false);
- event->accept();
- } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
- setFullScreen(!isFullScreen());
- event->accept();
- } else {
- QVideoWidget::keyPressEvent(event);
- }
-}
-
-void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
-{
- setFullScreen(!isFullScreen());
- event->accept();
-}
-
-void VideoWidget::mousePressEvent(QMouseEvent *event)
-{
- QVideoWidget::mousePressEvent(event);
-}
-
diff --git a/examples/multimediawidgets/player/videowidget.h b/examples/multimediawidgets/player/videowidget.h
deleted file mode 100644
index c01632e7b..000000000
--- a/examples/multimediawidgets/player/videowidget.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGET_H
-#define VIDEOWIDGET_H
-
-#include <QVideoWidget>
-
-class VideoWidget : public QVideoWidget
-{
- Q_OBJECT
-
-public:
- explicit VideoWidget(QWidget *parent = nullptr);
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
- void mouseDoubleClickEvent(QMouseEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
-};
-
-#endif // VIDEOWIDGET_H
diff --git a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc
deleted file mode 100644
index 74fbf65cf..000000000
--- a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example multimediawidgets/videographicsitem
- \title Video Graphics Item Example
- \ingroup multimedia_examples
- \brief Streaming video on a graphics scene.
- \meta {tag} {widgets}
-
- \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that
- displays video on a graphics scene using QVideoSink.
-
- \image video-videographicsitem.png
-
- \sa {Video Widget Example}
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/multimediawidgets/videographicsitem/main.cpp b/examples/multimediawidgets/videographicsitem/main.cpp
deleted file mode 100644
index e262c3908..000000000
--- a/examples/multimediawidgets/videographicsitem/main.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "videoplayer.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QDir>
-#include <QUrl>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Player Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt MultiMedia Player QGraphicsView Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL to open.");
- parser.process(app);
-
- VideoPlayer player;
-
- if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
- const QUrl url =
- QUrl::fromUserInput(parser.positionalArguments().constFirst(),
- QDir::currentPath(), QUrl::AssumeLocalFile);
- player.load(url);
- }
-
- player.show();
-
- return app.exec();
-}
-
diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.h b/examples/multimediawidgets/videographicsitem/videoplayer.h
deleted file mode 100644
index 9f01e8790..000000000
--- a/examples/multimediawidgets/videographicsitem/videoplayer.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-class QGraphicsVideoItem;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = nullptr);
- ~VideoPlayer();
-
- void load(const QUrl &url);
- bool isPlayerAvailable() const;
-
- QSize sizeHint() const override;
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::PlaybackState state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void rotateVideo(int angle);
-
-private:
- QMediaPlayer *m_mediaPlayer = nullptr;
- QGraphicsVideoItem *m_videoItem = nullptr;
- QAbstractButton *m_playButton = nullptr;
- QSlider *m_positionSlider = nullptr;
-};
-
-#endif
-
diff --git a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc b/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc
deleted file mode 100644
index 25bf7b2e3..000000000
--- a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example multimediawidgets/videowidget
- \title Video Widget Example
- \ingroup multimedia_examples
- \brief Implementing a video player widget.
- \meta {tag} {widgets,QVideoWidget}
-
- \e{Video Widget} demonstrates how to implement a simple video player using
- QVideoWidget.
-
- \image video-videowidget.png
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/multimediawidgets/videowidget/main.cpp b/examples/multimediawidgets/videowidget/main.cpp
deleted file mode 100644
index 3cf7e7989..000000000
--- a/examples/multimediawidgets/videowidget/main.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "videoplayer.h"
-
-#include <QtWidgets/QApplication>
-#include <QtCore/QCommandLineParser>
-#include <QtCore/QCommandLineOption>
-#include <QtCore/QDir>
-#include <QtCore/QUrl>
-#include <QScreen>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Video Widget Example");
- QCoreApplication::setOrganizationName("QtProject");
- QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName());
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt Video Widget Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL to open.");
- parser.process(app);
-
- VideoPlayer player;
- if (!parser.positionalArguments().isEmpty()) {
- const QUrl url =
- QUrl::fromUserInput(parser.positionalArguments().constFirst(),
- QDir::currentPath(), QUrl::AssumeLocalFile);
- player.setUrl(url);
- }
-
- const QSize availableGeometry = player.screen()->availableSize();
- player.resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
- player.show();
-
- return app.exec();
-}
diff --git a/examples/multimediawidgets/videowidget/videoplayer.h b/examples/multimediawidgets/videowidget/videoplayer.h
deleted file mode 100644
index 723df0b6c..000000000
--- a/examples/multimediawidgets/videowidget/videoplayer.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-class QLabel;
-class QUrl;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-public:
- VideoPlayer(QWidget *parent = nullptr);
- ~VideoPlayer();
-
- void setUrl(const QUrl &url);
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::PlaybackState state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void handleError();
-
-private:
- QMediaPlayer* m_mediaPlayer;
- QAbstractButton *m_playButton;
- QSlider *m_positionSlider;
- QLabel *m_errorLabel;
-};
-
-#endif
diff --git a/examples/spatialaudio/CMakeLists.txt b/examples/spatialaudio/CMakeLists.txt
new file mode 100644
index 000000000..0d92a79f5
--- /dev/null
+++ b/examples/spatialaudio/CMakeLists.txt
@@ -0,0 +1 @@
+qt_internal_add_example(audiopanning)
diff --git a/examples/multimedia/spatialaudio/CMakeLists.txt b/examples/spatialaudio/audiopanning/CMakeLists.txt
index 9e6649fc8..00367897a 100644
--- a/examples/multimedia/spatialaudio/CMakeLists.txt
+++ b/examples/spatialaudio/audiopanning/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(audiodecoder LANGUAGES CXX)
@@ -7,26 +10,26 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/spatialaudio")
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/spatialaudio/audiopanning")
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SpatialAudio Widgets)
-qt_add_executable(spatialaudio
+qt_add_executable(audiopanning
main.cpp
)
-set_target_properties(spatialaudio PROPERTIES
+set_target_properties(audiopanning PROPERTIES
WIN32_EXECUTABLE FALSE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(spatialaudio PUBLIC
+target_link_libraries(audiopanning PUBLIC
Qt::Core
- Qt::Multimedia
+ Qt::SpatialAudio
Qt::Widgets
)
-install(TARGETS spatialaudio
+install(TARGETS audiopanning
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/spatialaudio/audiopanning/audiopanning.pro b/examples/spatialaudio/audiopanning/audiopanning.pro
new file mode 100644
index 000000000..3b1cce652
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/audiopanning.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+TARGET = audiopanning
+
+QT += multimedia widgets spatialaudio
+
+SOURCES = main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/spatialaudio/audiopanning
+INSTALLS += target
diff --git a/examples/multimedia/spatialaudio/doc/images/spatialaudio-example.png b/examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png
index 45c53975d..45c53975d 100644
--- a/examples/multimedia/spatialaudio/doc/images/spatialaudio-example.png
+++ b/examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png
Binary files differ
diff --git a/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc b/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc
new file mode 100644
index 000000000..ebb18e5c7
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc
@@ -0,0 +1,28 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+/*!
+
+\example audiopanning
+\title Spatial Audio Panning Example
+\ingroup spatialaudio_examples
+\ingroup audio_examples
+\examplecategory {Multimedia}
+\meta {tag} {widgets}
+\brief Shows some of the capabilities of the spatial audio engine in Qt.
+
+The Spatial Audio Example demonstrates how you can use \l{Qt Spatial Audio} to
+place sound sources in 3D space and how positioning of the sound source and
+room properties affect the listening experience.
+
+The example lets you specify a sound file to be played back at a certain
+position in 3D space relative to the listener. Using sliders you can change
+the distance and the azimuth and elevation angles to the source. You can also
+change dimensions of a virtual room, the intensity of the room reflections
+and reverb.
+
+Various other properties can also be modified such as the dimensions of a virtual
+room and the intensity of the room reflections and reverb.
+
+\image audiopanning-example.png
+
+*/
diff --git a/examples/spatialaudio/audiopanning/main.cpp b/examples/spatialaudio/audiopanning/main.cpp
new file mode 100644
index 000000000..84e5197bd
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/main.cpp
@@ -0,0 +1,241 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QAudioEngine>
+#include <QAudioListener>
+#include <QAudioRoom>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QCommandLineParser>
+#include <QFileDialog>
+#include <QFormLayout>
+#include <QHBoxLayout>
+#include <QLibraryInfo>
+#include <QLineEdit>
+#include <QPropertyAnimation>
+#include <QPushButton>
+#include <QSlider>
+#include <QSpatialSound>
+#include <QStandardPaths>
+
+class AudioWidget : public QWidget
+{
+public:
+ AudioWidget();
+ void setFile(const QString &file);
+
+private slots:
+ void updatePosition();
+ void newOcclusion();
+ void modeChanged();
+ void fileChanged(const QString &file);
+ void openFileDialog();
+ void updateRoom();
+ void animateChanged();
+
+private:
+ QLineEdit *fileEdit = nullptr;
+ QPushButton *fileDialogButton = nullptr;
+ QSlider *azimuth = nullptr;
+ QSlider *elevation = nullptr;
+ QSlider *distance = nullptr;
+ QSlider *occlusion = nullptr;
+ QSlider *roomDimension = nullptr;
+ QSlider *reverbGain = nullptr;
+ QSlider *reflectionGain = nullptr;
+ QComboBox *mode = nullptr;
+ QCheckBox *animateButton = nullptr;
+ QPropertyAnimation *animation = nullptr;
+
+ QAudioEngine engine;
+ QAudioListener *listener = nullptr;
+ QSpatialSound *sound = nullptr;
+ QAudioRoom *room = nullptr;
+ QFileDialog *fileDialog = nullptr;
+};
+
+AudioWidget::AudioWidget()
+ : QWidget()
+{
+ setMinimumSize(400, 300);
+ auto *form = new QFormLayout(this);
+
+ auto *fileLayout = new QHBoxLayout;
+ fileEdit = new QLineEdit;
+ fileEdit->setPlaceholderText(tr("Audio File"));
+ fileLayout->addWidget(fileEdit);
+ fileDialogButton = new QPushButton(tr("Choose..."));
+ fileLayout->addWidget(fileDialogButton);
+ form->addRow(fileLayout);
+
+ azimuth = new QSlider(Qt::Horizontal);
+ azimuth->setRange(-180, 180);
+ form->addRow(tr("Azimuth (-180 - 180 degree):"), azimuth);
+
+ elevation = new QSlider(Qt::Horizontal);
+ elevation->setRange(-90, 90);
+ form->addRow(tr("Elevation (-90 - 90 degree)"), elevation);
+
+ distance = new QSlider(Qt::Horizontal);
+ distance->setRange(0, 1000);
+ distance->setValue(100);
+ form->addRow(tr("Distance (0 - 10 meter):"), distance);
+
+ occlusion = new QSlider(Qt::Horizontal);
+ occlusion->setRange(0, 400);
+ form->addRow(tr("Occlusion (0 - 4):"), occlusion);
+
+ roomDimension = new QSlider(Qt::Horizontal);
+ roomDimension->setRange(0, 10000);
+ roomDimension->setValue(1000);
+ form->addRow(tr("Room dimension (0 - 100 meter):"), roomDimension);
+
+ reverbGain = new QSlider(Qt::Horizontal);
+ reverbGain->setRange(0, 500);
+ reverbGain->setValue(0);
+ form->addRow(tr("Reverb gain (0-5):"), reverbGain);
+
+ reflectionGain = new QSlider(Qt::Horizontal);
+ reflectionGain->setRange(0, 500);
+ reflectionGain->setValue(0);
+ form->addRow(tr("Reflection gain (0-5):"), reflectionGain);
+
+ mode = new QComboBox;
+ mode->addItem(tr("Surround"), QVariant::fromValue(QAudioEngine::Surround));
+ mode->addItem(tr("Stereo"), QVariant::fromValue(QAudioEngine::Stereo));
+ mode->addItem(tr("Headphone"), QVariant::fromValue(QAudioEngine::Headphone));
+
+ form->addRow(tr("Output mode:"), mode);
+
+ animateButton = new QCheckBox(tr("Animate sound position"));
+ form->addRow(animateButton);
+
+ connect(fileEdit, &QLineEdit::textChanged, this, &AudioWidget::fileChanged);
+ connect(fileDialogButton, &QPushButton::clicked, this, &AudioWidget::openFileDialog);
+
+ connect(azimuth, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(elevation, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(distance, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(occlusion, &QSlider::valueChanged, this, &AudioWidget::newOcclusion);
+
+ connect(roomDimension, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+ connect(reverbGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+ connect(reflectionGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+
+ connect(mode, &QComboBox::currentIndexChanged, this, &AudioWidget::modeChanged);
+
+ room = new QAudioRoom(&engine);
+ room->setWallMaterial(QAudioRoom::BackWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::FrontWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::LeftWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::RightWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::Floor, QAudioRoom::Marble);
+ room->setWallMaterial(QAudioRoom::Ceiling, QAudioRoom::WoodCeiling);
+ updateRoom();
+
+ listener = new QAudioListener(&engine);
+ listener->setPosition({});
+ listener->setRotation({});
+ engine.start();
+
+ sound = new QSpatialSound(&engine);
+ updatePosition();
+
+ animation = new QPropertyAnimation(azimuth, "value");
+ animation->setDuration(10000);
+ animation->setStartValue(-180);
+ animation->setEndValue(180);
+ animation->setLoopCount(-1);
+ connect(animateButton, &QCheckBox::toggled, this, &AudioWidget::animateChanged);
+}
+
+void AudioWidget::setFile(const QString &file)
+{
+ fileEdit->setText(file);
+}
+
+void AudioWidget::updatePosition()
+{
+ const float az = azimuth->value() / 180. * M_PI;
+ const float el = elevation->value() / 180. * M_PI;
+ const float d = distance->value();
+
+ const float x = d * sin(az) * cos(el);
+ const float y = d * sin(el);
+ const float z = -d * cos(az) * cos(el);
+ sound->setPosition({x, y, z});
+}
+
+void AudioWidget::newOcclusion()
+{
+ sound->setOcclusionIntensity(occlusion->value() / 100.);
+}
+
+void AudioWidget::modeChanged()
+{
+ engine.setOutputMode(mode->currentData().value<QAudioEngine::OutputMode>());
+}
+
+void AudioWidget::fileChanged(const QString &file)
+{
+ sound->setSource(QUrl::fromLocalFile(file));
+ sound->setSize(5);
+ sound->setLoops(QSpatialSound::Infinite);
+}
+
+void AudioWidget::openFileDialog()
+{
+ if (fileDialog == nullptr) {
+ const QString dir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
+ fileDialog = new QFileDialog(this, tr("Open Audio File"), dir);
+ fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
+ const QStringList mimeTypes{"audio/mpeg", "audio/aac", "audio/x-ms-wma",
+ "audio/x-flac+ogg", "audio/x-wav"};
+ fileDialog->setMimeTypeFilters(mimeTypes);
+ fileDialog->selectMimeTypeFilter(mimeTypes.constFirst());
+ }
+
+ if (fileDialog->exec() == QDialog::Accepted)
+ fileEdit->setText(fileDialog->selectedFiles().constFirst());
+}
+
+void AudioWidget::updateRoom()
+{
+ const float d = roomDimension->value();
+ room->setDimensions(QVector3D(d, d, 400));
+ room->setReflectionGain(float(reflectionGain->value()) / 100);
+ room->setReverbGain(float(reverbGain->value()) / 100);
+}
+
+void AudioWidget::animateChanged()
+{
+ if (animateButton->isChecked())
+ animation->start();
+ else
+ animation->stop();
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationVersion(qVersion());
+ QGuiApplication::setApplicationDisplayName(AudioWidget::tr("Spatial Audio test application"));
+
+ QCommandLineParser commandLineParser;
+ commandLineParser.addVersionOption();
+ commandLineParser.addHelpOption();
+ commandLineParser.addPositionalArgument("Audio File",
+ "Audio File to play");
+
+ commandLineParser.process(app);
+
+ AudioWidget w;
+ w.show();
+
+ if (!commandLineParser.positionalArguments().isEmpty())
+ w.setFile(commandLineParser.positionalArguments().constFirst());
+
+ return app.exec();
+}
diff --git a/examples/spatialaudio/spatialaudio.pro b/examples/spatialaudio/spatialaudio.pro
new file mode 100644
index 000000000..80039c1a5
--- /dev/null
+++ b/examples/spatialaudio/spatialaudio.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += audiopanning
+