qt5-cadaques
qt5-cadaques copied to clipboard
10.1. Playing media with a position bar.
back-link: http://qmlbook.org/ch10/index.html#playing-media
import QtSystemInfo 5.0
QtSystemInfo has not been implemented, as of November 19, 2014. Based on my research, it has not been re-introduced since the upgrade to 5.0. Corrected code would read as:
As I am not able to use volume currently, I will not be testing the volume systems of this. Next is the seek bar. ‘seekable’ and ‘position’ are read only properties. ‘if(player.seekable)’ will return true or false, but in my limited testing it seemed to only return true. Someone will need to confirm if some videos can have a ‘seekable’ property set to false. In order to fix this, the code would read:
Item {
width: 720; height: 400
MediaPlayer {
id: player
source: "/home/sssw/Projects/Practice/Multimedia/Big_Buck_Bunny_Trailer_400p.ogg"
}
VideoOutput {
anchors.fill: player
source: player
}
Component.onCompleted: {
player.play()
}
}
Next is the seek bar. ‘seekable’ and ‘position’ are read only properties. ‘if(player.seekable)’ will return true or false, but in my limited testing it seemed to only return true. Someone will need to confirm if some videos can have a ‘seekable’ property set to false. In order to fix this, the code would read:
Rectangle {
id: progressBar
anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 100 }
height: 30
color: "lightgray"
Rectangle {
anchors { left: parent.left; top: parent.top; bottom: parent.bottom }
width: player.duration > 0 ? parent.width * player.position/player.duration : 0
color: "gray"
}
MouseArea {
anchors.fill: parent
onClicked: { player.seek(player.duration * mouse.x/width) }
}
}
For this code, I only added what format and context which was given by the examples.
It may also be noted that http://qt-project.org/wiki/Qt_Multimedia_Backends shows the multimedia backends which are supported, but is in the previous documentation. Based on its note, is it current to 5.4.
Unfortunately, due to the constraints of my system I was unable to go through the rest of the code to verify/validate. Even in this, I have no reporting on sound based on my system. It may also be noted that h.264 can not be played currently. Sintel trailer/video is an example of this.
Hopefully this helps.