First of all: Happy new year!
I recently started playing around with this interesting platform.
And I am stuck with this:
How to pick an audio file (mp3 or wav or ogg) from my device (Windows, android or ios)?
We have a videopicker, an imagepicker, a camerapicker but no audiopicker.
So how do I get a list of audio files on my device. I can’t find any activity to archieve this.
Hey, that was really fast help, thanx a lot!
Now I am able to setup a list of audiofiles (file:///C:/audiofiles/audio1.mp3, file:///C:/audiofiles/audio2.mp3… ) and load the files to the audio widget by clicking the item.
But how can I browse through audiofiles on my device( Android or ios) and add them to a playlist ?
It may be difficult because of the read permissions on different Android versions or on ios.
This requires (FilePicker), but as I understand it is not in Flipabit
Для этого требуется (FilePicker), но я так понимаю его нет во Flipabit
this way contains the solution:
With a little change in his code example I can list mp3 files:
import QtQuick 2.15
import Qt.labs.folderlistmodel 2.15
ListView {
width: 200; height: 400
FolderListModel {
id: folderModel
nameFilters: ["*.mp3, *.wav"]
}
Component {
id: fileDelegate
Text { text: fileName }
}
model: folderModel
delegate: fileDelegate
}
все, что получилось
но может получить только файлы png, не знаю по чему
everything that happened
but can only get png files, don’t know why
import QtQuick 2.6
import QtQuick.Window 2.2
import Qt.labs.folderlistmodel 2.1
import QtQuick.Controls 1.4ListView { id:list; anchors.fill: parent; anchors.topMargin: btn.height + 20 anchors.leftMargin: 20 spacing: 20 model: FolderListModel { id:folderList; property var folders:[]; folder:"file:///" + "c://"; nameFilters: ["*.pdf","*.png"]; } delegate: Text { id:wrapper; text: fileName MouseArea { id:mos; enabled:fileIsDir; anchors.fill: parent; onClicked: { folderList.folders.push(folderList.folder); folderList.folder += fileName + "/"; } } } }
shouldn’t it be :
nameFilters: ["*.pdf; *.png"];
This is so far my solution for my issue:
import QtQuick 2.2
import QtQuick.Dialogs 1.0
Item {
Connections {
target: document.childByName(“Audio 1”).scriptAdaptor
onEventItemClicked: {
fileDialog.visible = true
}
}
FileDialog {
id: fileDialog
nameFilters: ["*.mp3; *.wav; *.ogg"]
folder: shortcuts.home
onAccepted: {
document.childByName(“Text 1”).content.text = ("" + fileDialog.fileUrls)
}
onRejected: {
}
}
}
Audio picker added in upcoming version.
Flipabit still miss the permission to access the Mediathek in ios (missing iOS App Permission Usage Description Key NSAppleMusicUsageDescription).
This permission is very important for creating music apps.
Is there any hope that you implement it in the next weeks?
Here is my Solution for a filepicker that works on windows, ios and android (tested up to android 11 inclusive files from sdcard):
import QtQuick 2.9
import QtQuick.Controls 2.4
import Qt.labs.platform 1.1
Item {
Connections {
target: document.childByName(“Text Path”).scriptAdaptor
onEventItemClicked: {
fileDialog.visible = true
}
}
FileDialog {
id: fileDialog
nameFilters: ["."]
folder:StandardPaths.standardLocations(StandardPaths.MusicLocation)[1]//shortcuts.home
onAccepted: {
document.childByName(“Text Path”).content.text = ("" + fileDialog.file);
// to fix the content uri to a real filepath for device memory and sdCard
if (document.childByName(“Text Path”).content.text.includes(“primary”) ) {
document.childByName(“Text Path”).content.scriptAdaptor.actionReplaceString(“content://com.android.externalstorage.documents/document/primary”,“file:///storage/emulated/0”)
}
if (document.childByName(“Text Path”).content.text.includes(“primary”) == false) {
document.childByName(“Text Path”).content.scriptAdaptor.actionReplaceString(“content://com.android.externalstorage.documents/document/”,“file:///storage/”)
}
document.childByName(“Text Path”).content.scriptAdaptor.actionReplaceString("%2F","/");
document.childByName(“Text Path”).content.scriptAdaptor.actionReplaceString("%3A","/");
document.childByName(“Audio Edit”).content.audioFile = document.childByName(“Text Path”).content.text
}
onRejected: {
}
}
}
audiopicker.flp (7.0 KB)