Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/qml/pages/CameraUI.qml b/qml/pages/CameraUI.qml
- index 7d0381a..a0320bb 100644
- --- a/qml/pages/CameraUI.qml
- +++ b/qml/pages/CameraUI.qml
- @@ -120,6 +120,15 @@ Page {
- }
- }
- + onRecorderStatusChanged: {
- + if (camera.videoRecorder.recorderStatus == CameraRecorder.FinalizingStatus) {
- + var path = camera.videoRecorder.outputLocation.toString()
- + path = path.replace(/^(file:\/{2})/,"")
- + console.log("finalizing: " + path)
- + galleryModel.append({ filePath: path })
- + }
- + }
- +
- onResolutionChanged: {
- console.log("Video resolution changed:", settings.resolution("video"));
- camera.viewfinder.resolution = getNearestViewFinderResolution();
- diff --git a/qml/pages/GalleryUI.qml b/qml/pages/GalleryUI.qml
- index 3764980..2a34dd4 100644
- --- a/qml/pages/GalleryUI.qml
- +++ b/qml/pages/GalleryUI.qml
- @@ -1,5 +1,7 @@
- import QtQuick 2.0
- import Sailfish.Silica 1.0
- +import QtMultimedia 5.6
- +import Nemo.Thumbnailer 1.0
- import uk.co.piggz.harbour_advanced_camera 1.0
- import "../components/"
- @@ -27,6 +29,23 @@ Page {
- }
- }
- + function isVideo(idx) {
- + if (idx < 0) return;
- + var fullPath = fileList.get(idx).filePath;
- + var fileExt = fullPath.substr(fullPath.lastIndexOf(".") + 1, 3);
- + console.log("Detected", fileExt, "extension...");
- + return (fileExt === "mp4");
- + }
- +
- + function getFileName(idx) {
- + if (idx < 0) return;
- + var fullPath = fileList.get(idx).filePath;
- + var lastSep = fullPath.lastIndexOf("/");
- + var fileName = fullPath.substr(lastSep + 1, fullPath.length - lastSep);
- + console.log("Filename:", fileName);
- + return fileName;
- + }
- +
- RoundButton {
- id: btnClose
- @@ -94,23 +113,46 @@ Page {
- height: parent.height
- color: 'black'
- - Image {
- + property bool isMovie: isVideo(index)
- + property string fileName: getFileName(index)
- +
- + Thumbnail {
- id: thumbnail
- - asynchronous: true
- + width: parent.width
- + height: parent.height
- sourceSize.width: parent.width
- + sourceSize.height: parent.height
- anchors.fill: parent
- - fillMode: Image.PreserveAspectFit
- - source: "file://" + filePath
- + fillMode: Thumbnail.PreserveAspectFit
- + mimeType: isMovie ? "video/" : "image/"
- + //priority: Thumbnail.HighPriority
- + source: filePath
- + smooth: true
- +
- + onStatusChanged: console.log("Thumbnail status for", fileName, status)
- MouseArea {
- anchors.fill: parent
- onClicked: {
- - console.log("Clicked", thumbnail.source);
- btnClose.visible = btnClose.visible ? false : true;
- }
- }
- }
- +
- + RoundButton {
- + id: btnPlay
- +
- + visible: isMovie
- + anchors.centerIn:parent
- + icon.source: "image://theme/icon-m-play"
- + size: Theme.itemSizeMedium
- +
- + onClicked: {
- + console.log("Clicked play button on", filePath);
- + pageStack.push(Qt.resolvedUrl("VideoPlayer.qml"), { "videoFile": filePath });
- + }
- + }
- }
- }
- diff --git a/qml/pages/VideoPlayer.qml b/qml/pages/VideoPlayer.qml
- new file mode 100644
- index 0000000..27fa29f
- --- /dev/null
- +++ b/qml/pages/VideoPlayer.qml
- @@ -0,0 +1,53 @@
- +import QtQuick 2.0
- +import Sailfish.Silica 1.0
- +import QtMultimedia 5.6
- +
- +Page {
- + id: playerPage
- +
- + // The effective value will be restricted by ApplicationWindow.allowedOrientations
- + allowedOrientations: Orientation.All
- +
- + property var videoFile: ({})
- +
- + Rectangle {
- + width: parent.width
- + height: parent.height
- + color: "black"
- +
- + Video {
- + id: videoPlayer
- +
- + width: parent.width
- + height: parent.height
- + source: "file://" + videoFile
- + autoPlay: true
- + fillMode: VideoOutput.PreserveAspectFit
- + focus: true
- +
- + onStatusChanged: {
- + if (status == MediaPlayer.Loading) {
- + console.log("Media loading...");
- + } else if (status == MediaPlayer.Loaded) {
- + console.log("Media loaded!");
- + } else if (status == MediaPlayer.Buffering) {
- + console.log("Media buffering...");
- + } else if (status == MediaPlayer.Buffered) {
- + console.log("Media buffered!");
- + } else if (status == MediaPlayer.EndOfMedia) {
- + console.log("Media ended!");
- + } else if (status == MediaPlayer.InvalidMedia) {
- + console.log("Invalid!");
- + } else if (status == MediaPlayer.UnknownStatus) {
- + console.log("Media unknow status!");
- + } else {
- + console.log("Video player status", status);
- + }
- + }
- +
- + onPlaying: console.log("Media playing \\o/")
- +
- + onStopped: console.log("Media stopped")
- + }
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement