Module "QtMobility.gallery" is not installed
-
@qAminzzz Use https://doc.qt.io/qt-5/qstandardpaths.html to get the paths to video/image locations.
Don't forget to request access rights from Android. -
@jsulm thanks for link.
i searched in this link and i made this code :QStringList movies = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); foreach(QString file, movies) { qInfo() << "path: " << file; } output: path: "/storage/emulated/0/Pictures" path: "/storage/emulated/0/Android/data/org.qtproject.example.videoTesting/files/Pictures"
i think it did not work correctly because in "/storage/emulated/0/Pictures" directory there is no all my android device pictures
please help me
-
@jsulm i just did it
QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(QStringList( { "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE" } ));
and works fine
should i request permission more? -
@qAminzzz
i can show video in my app with these codesVideo { id: video anchors.fill: parent source: "file:///storage/emulated/0/download/video.mp4" visible: true volume: 20 MouseArea { anchors.fill: parent onClicked: { video.play() } }
and this works fine.
now i want create a class and get all videos in android device with a function and return them to Video.source -
@qAminzzz said in Module "QtMobility.gallery" is not installed:
now i want create a class and get all videos in android device with a function and return them to Video.source
Then you can go through all the paths where the user can store something (not only images/videos locations) and then use https://doc.qt.io/qt-5/qdir.html#entryList-1 for each of these paths to get the files there and filter those by file extension.
-
@jsulm this link shows to get all files in a directory
but might be there a directory in that directory
or might be there 10 directory in one directory and we can't search all thembut in device gallery there is all media like screen shots, apps, downloads and ...
but in this way we can just see all files in a directory not in device
is there any way to do gallery device work? -
You can also use https://doc.qt.io/qt-5/qdiriterator.html which is reqursive
-
@qAminzzz said in Module "QtMobility.gallery" is not installed:
no which does not my request
Not sure what this means?
"but in device gallery there is all media like screen shots, apps, downloads and" - because the gallery app collects the files from many different locations on the device...
I don't know whether there is an Java API on Android for that. -
@qAminzzz said in Module "QtMobility.gallery" is not installed:
can i search all directories with QDiriterator ?
yes, at least those where your app has read access
-
@jsulm thank you so much
it worked with these code:function:
void searchPaths(QVariant path) { QStringList files; // add files to this ( paths ) QStringList filter; // mp4 files filter filter << "*.mp4"; // add filter qInfo("-----"); QDirIterator dir(path.toString(), filter, QDir::Files, QDirIterator::Subdirectories); // get all files in directory while (dir.hasNext()) { qInfo() << dir.next(); files << dir.next(); // } }
use:
searchPaths("enter path here")
now i can sleep easy. thanks