我正在尝试从Qt QML中的本地目录播放视频。
目前,我播放资源文件中的视频,但我的目标是调用本地目录,并逐个播放该目录中的所有视频。在Qt QML中可能这样做吗?
public interface IActivityLogService
{
Task<ActivityLogEntryModel> GetActivityLogEntryAsync(int activityLogEntryId);
Task<IList<ActivityLogEntryModel>> GetActivityLogEntriesAsync(DataRequest<ActivityLogEntry> request);
Task<IList<ActivityLogEntryModel>> GetActivityLogEntriesAsync(int skip, int take,
DataRequest<ActivityLogEntry> request);
Task<IList<ActivityLogEntryModel>> GetActivityLogEntryCountAsync(DataRequest<ActivityLogEntry> request);
Task<ActivityLogEntryModel> CreateNewActivityLogEntryAsync(int activityLogEntryId);
Task<int> UpdateActivityLogEntryAsync(ActivityLogEntryModel model);
Task<int> DeleteActivityLogEntryAsync(ActivityLogEntryModel model);
Task<int> DeleteActivityLogEntryRangeAsync(int index, int length, DataRequest<ActivityLogEntry> request);
}
答案 0 :(得分:0)
您可以获得特定文件夹的文件列表,并使用FolderListModel
QML Type对其进行遍历:
import Qt.labs.folderlistmodel 2.12
// ...
FolderListModel {
id: folderModel
/// Put here URL of folder with videos
folder: "file:" + "/home/tro/Videos/"
/// Put a list of file name filters
nameFilters: ["*.avi"]
showDirs: false
onStatusChanged: {
if (folderModel.status == FolderListModel.Ready) {
console.log('Folder Model Loaded')
console.log("Folder list contains ", folderModel.count, "elements:")
for (var i = 0; i < folderModel.count; ++i) {
console.log("\t", i, folderModel.get(i, "fileURL"))
}
}
}
}
此外,请参阅method get
上的文档以更好地了解您可以获得的信息(例如,在这里我们仅使用fileURL
)。