/// <summary> /// Gets tracks from device. /// </summary> /// <returns>A collection of audio tracks.</returns> public List <Track> GetTracksFromDevice() { List <Track> tracklist = new List <Track>(); try { _mediaDatabase.Connect(); var selectArgs = new SelectArguments { FilterExpression = "MEDIA_TYPE = " + TYPE_MUSIC }; var mediaInfoCommand = new MediaInfoCommand(_mediaDatabase); var selectedMedia = mediaInfoCommand.SelectMedia(selectArgs); while (selectedMedia.Read()) { tracklist.Add(MediaInfoToTrack((AudioInfo)selectedMedia.Current)); } } catch (Exception e) { Log.Error(SAMPLE_LOG_TAG, e.Message); } finally { _mediaDatabase.Disconnect(); } return(tracklist); }
public MediaContentPort() { mediaDatabase = new MediaDatabase(); mediaDatabase.Connect(); mediaInfoCommand = new MediaInfoCommand(mediaDatabase); }
public MediaContentDatabase() { var database = new MediaDatabase(); database.Connect(); _mediaInfoCmd = new MediaInfoCommand(database); }
public DataBase() { var database = new MediaDatabase(); database.Connect(); _mediaInfoCmd = new MediaInfoCommand(database); _files = Directory.GetFiles(_filePath, "*.jpg").Select(Path.GetFullPath).ToList(); }
/// <summary> /// Connects to Media Database. /// </summary> public void ConnectDatabase() { _mediaDatabase = new MediaDatabase(); try { _mediaDatabase.Connect(); } catch (Exception exception) { ErrorHandler("Connecting DB error: " + exception.Message); } }
/// <summary> /// This is a sample to demonstrate how to query the media database to retrieve media content /// For more information about media content, see https://docs.tizen.org/application/dotnet/guides/multimedia/media-content /// </summary> public static async Task AccessMediaContentSampleAsync() { // Ask the user for the permission PrivacyPermissionStatus permission = await PrivacyPermissionService.RequestAsync(PrivacyPrivilege.MediaStorage); if (permission != PrivacyPermissionStatus.Granted) { // TODO: The permission is not granted return; } using (var database = new MediaDatabase()) { try { // Establish a connection to the media database. database.Connect(); // Note that the system automactically scans storage and adds media files to the database. // To request the system to scan a directory explicitly, use MediaDatabase.ScanFolderAsync() // await database.ScanFolderAsync(path); // Query the database to retrieve media files and get a Reader containing results. var command = new MediaInfoCommand(database); var reader = command.SelectMedia(new SelectArguments() { FilterExpression = $"{MediaInfoColumns.MediaType}={(int)MediaType.Music}" + $" OR {MediaInfoColumns.MediaType}={(int)MediaType.Sound}" + $" OR {MediaInfoColumns.MediaType}={(int)MediaType.Video}" }); // Iterate over media data in the results. while (reader.Read()) { var media = reader.Current; // TODO: Insert code to do something with a media file. // Note that your app needs adequate permissions to perform operations on the file Logger.Info($"{media.MediaType}: {media.Title}"); } } catch (MediaDatabaseException) { // TODO: Handle exception as appropriate to your scenario. } } }
/// <summary> /// Get Record from media file /// </summary> /// <param name="path">recorded audio file</param> /// <param name="SttOn">stt on/off mode</param> /// <returns>Record</returns> public Record GetMediaInfo(string path, bool SttOn) { Record record = null; try { // TODO : scan #if media_svc_get_storage_id_failed_return_minus_2 #else mediaDB.Connect(); #endif mediaDB.ScanFile(path); #if media_svc_get_storage_id_failed_return_minus_2 #else mediaInfoCmd = new MediaInfoCommand(mediaDB); #endif AudioInfo info = mediaInfoCmd.Add(path) as AudioInfo; #if media_svc_get_storage_id_failed_return_minus_2 #else mediaDB.Disconnect(); #endif //int minutes = info.Duration / 60000; //int seconds = (info.Duration - minutes * 60000) / 1000; //string duration = String.Format("{0:00}:{1:00}", minutes, seconds); record = new Record { _id = AudioRecordService.numbering, Title = info.Title.Substring(0, info.Title.IndexOf("_T_")), Date = info.DateModified.ToLocalTime().ToString("t"), Duration = info.Duration, Path = path, SttEnabled = SttOn, }; Console.WriteLine(" ** Record :" + record); } catch (Exception e) { Console.WriteLine("###########################################"); Console.WriteLine(" FAILED GetMediaInfo : " + e.Message + ", " + e.Source); Console.WriteLine("###########################################"); MessagingCenter.Send(this, MessageKeys.ErrorOccur, e); } return(record); }
/// <summary> /// Connects to the database. /// </summary> public void Connect() { _mediaDatabase.Connect(); }