Media File format
-
Hello everyone!
I am trying to create a simple media player, so I want to open some media files from a directory (which i already did) but i want to split audio files and video files from each other. If any one have an idea, i really appreciate if someone can help, please! -
Hi @HW-Developer
Are you just looking for QTabWidget .? -
Hi @HW-Developer
Are you just looking for QTabWidget .?@mostefa No I did already create the tabwidget (look to the screenshot), i want to split audio files from video files and display each one of them in a different tab
-
@mostefa No I did already create the tabwidget (look to the screenshot), i want to split audio files from video files and display each one of them in a different tab
@HW-Developer
Still don't understand. You want simply to display some files on one tab and others on another? You have separate files for audio and video? Does their file extension change? How do you know which are which? -
@HW-Developer
Still don't understand. You want simply to display some files on one tab and others on another? You have separate files for audio and video? Does their file extension change? How do you know which are which?@JonB Ok, for example, you click the add button to load some media files, you choose a list that you want to play, if that list contains audio files it will be displayed just in the first(all) and third tab(audio) and if it contains video files, it will be displayed in the first(all) and the second tab(video).
So i think if i want to achieve that goal, i have to create a function that will verify the files extensions. but i do not know how to do it as a beginner. -
@JonB Ok, for example, you click the add button to load some media files, you choose a list that you want to play, if that list contains audio files it will be displayed just in the first(all) and third tab(audio) and if it contains video files, it will be displayed in the first(all) and the second tab(video).
So i think if i want to achieve that goal, i have to create a function that will verify the files extensions. but i do not know how to do it as a beginner.@HW-Developer
Yes, if the file types depend on the file names' extensions. Look at http://doc.qt.io/qt-5/qdir.html for stuff to do with "name filters", e.g. something like http://doc.qt.io/qt-5/qdir.html#QDir-2 might be right/a start.Or, if you just want to use whatever code you already have which has all filenames, just look at the segment at the end of each name (there are dedicated functions for this like http://doc.qt.io/qt-5/qfileinfo.html#suffix, or just write your own code treating it as a string) to decide which type of file each one is.
-
@JonB Ok, for example, you click the add button to load some media files, you choose a list that you want to play, if that list contains audio files it will be displayed just in the first(all) and third tab(audio) and if it contains video files, it will be displayed in the first(all) and the second tab(video).
So i think if i want to achieve that goal, i have to create a function that will verify the files extensions. but i do not know how to do it as a beginner.@HW-Developer Sounds like you need http://doc.qt.io/qt-5/qmimedatabase.html
-
@HW-Developer
Yes, if the file types depend on the file names' extensions. Look at http://doc.qt.io/qt-5/qdir.html for stuff to do with "name filters", e.g. something like http://doc.qt.io/qt-5/qdir.html#QDir-2 might be right/a start.Or, if you just want to use whatever code you already have which has all filenames, just look at the segment at the end of each name (there are dedicated functions for this like http://doc.qt.io/qt-5/qfileinfo.html#suffix, or just write your own code treating it as a string) to decide which type of file each one is.
-
@HW-Developer please remember that Qt Multimedia is as capable as the multimedia implementation of the underlying OS; from its documentation:
Limitations
The Qt Multimedia APIs build upon the multimedia framework of the underlying platform. This can mean that support for various codecs or containers can vary between machines, depending on what the end user has installed.So I'd suggest you go and try using libraries ffmpeg (libavformat/libavcodec) or libvlc inside your Qt application which will give you plenty of capabilities regarding audio and video handling.
You may want to take a look at ffplay simple player regarding how those libraries are used (source code).