[gnome-sound-recorder] recording: set the extension on export
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] recording: set the extension on export
- Date: Thu, 3 Sep 2020 10:57:01 +0000 (UTC)
commit c84fb024c6d91d94bae36b5edf72799c6e7f3440
Author: Kavan Mevada <kavanmevada gmail com>
Date: Wed Sep 2 22:06:01 2020 +0530
recording: set the extension on export
fixes: #17
src/recorder.js | 16 ++++++++++------
src/recording.js | 15 ++++++++++++++-
src/row.js | 2 +-
3 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/recorder.js b/src/recorder.js
index bfaaccb..a907a9b 100644
--- a/src/recorder.js
+++ b/src/recorder.js
@@ -26,27 +26,32 @@ var EncodingProfiles = [
{ name: 'VORBIS',
containerCaps: 'application/ogg;audio/ogg;video/ogg',
audioCaps: 'audio/x-vorbis',
- mimeType: 'audio/x-vorbis' },
+ contentType: 'audio/x-vorbis+ogg',
+ extension: 'ogg' },
{ name: 'OPUS',
containerCaps: 'application/ogg',
audioCaps: 'audio/x-opus',
- mimeType: 'audio/x-opus' },
+ contentType: 'audio/x-opus+ogg',
+ extension: 'opus' },
{ name: 'FLAC',
containerCaps: 'audio/x-flac',
audioCaps: 'audio/x-flac',
- mimeType: 'audio/x-flac' },
+ contentType: 'audio/flac',
+ extension: 'flac' },
{ name: 'MP3',
containerCaps: 'application/x-id3',
audioCaps: 'audio/mpeg,mpegversion=(int)1,layer=(int)3',
- mimeType: 'audio/mpeg' },
+ contentType: 'audio/mpeg',
+ extension: 'mp3' },
{ name: 'M4A',
containerCaps: 'video/quicktime,variant=(string)iso',
audioCaps: 'audio/mpeg,mpegversion=(int)4',
- mimeType: 'audio/mpeg' },
+ contentType: 'video/mp4',
+ extension: 'm4a' },
];
var AudioChannels = {
@@ -108,7 +113,6 @@ var Recorder = new GObject.registerClass({
this.file = RecordingsDir.get_child_for_display_name(_('Recording %d').format(index++));
} while (this.file.query_exists(null));
-
this.recordBus = this.pipeline.get_bus();
this.recordBus.add_signal_watch();
this.handlerId = this.recordBus.connect('message', (_, message) => {
diff --git a/src/recording.js b/src/recording.js
index 273d2fe..d234b6d 100644
--- a/src/recording.js
+++ b/src/recording.js
@@ -2,6 +2,7 @@
const { Gio, GLib, GObject, Gst, GstPbutils } = imports.gi;
const { CacheDir } = imports.application;
const ByteArray = imports.byteArray;
+const Recorder = imports.recorder;
var Recording = new GObject.registerClass({
Signals: {
@@ -27,7 +28,15 @@ var Recording = new GObject.registerClass({
this._loadedPeaks = [];
super._init({});
- let info = file.query_info('time::created,time::modified', 0, null);
+ let info = file.query_info('time::created,time::modified,standard::content-type', 0, null);
+ const contentType = info.get_attribute_string('standard::content-type');
+
+ for (let profile of Recorder.EncodingProfiles) {
+ if (profile.contentType === contentType) {
+ this._extension = profile.extension;
+ break;
+ }
+ }
let timeModified = info.get_attribute_uint64('time::modified');
let timeCreated = info.get_attribute_uint64('time::created');
@@ -55,6 +64,10 @@ var Recording = new GObject.registerClass({
}
}
+ get extension() {
+ return this._extension;
+ }
+
get timeModified() {
return this._timeModified;
}
diff --git a/src/row.js b/src/row.js
index c4076bf..e35b6a9 100644
--- a/src/row.js
+++ b/src/row.js
@@ -65,7 +65,7 @@ var Row = GObject.registerClass({
exportAction.connect('activate', () => {
const dialog = Gtk.FileChooserNative.new(_('Export Recording'), null,
Gtk.FileChooserAction.SAVE, _('_Export'), _('_Cancel'));
- dialog.set_current_name(this._recording.name);
+ dialog.set_current_name(`${this._recording.name}.${this._recording.extension}`);
dialog.connect('response', (_dialog, _response) => {
if (_response === Gtk.ResponseType.ACCEPT) {
const dest = dialog.get_file();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]