From 7d564a0d18ae3385677021e396a02b9fbedd8f94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 30 Jul 2012 12:02:17 +0200 Subject: [PATCH] Set automatically detected codec on new derivatives. --- .../demoscenemusic/page/admin/AddTrackDerivativePage.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackDerivativePage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackDerivativePage.java index e1a8d0a..620d302 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackDerivativePage.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackDerivativePage.java @@ -29,6 +29,8 @@ import net.pterodactylus.demoscenemusic.core.Core; import net.pterodactylus.demoscenemusic.data.Track; import net.pterodactylus.demoscenemusic.data.TrackDerivative; import net.pterodactylus.demoscenemusic.page.ServletRequest; +import net.pterodactylus.demoscenemusic.utils.AudioCodecs; +import net.pterodactylus.demoscenemusic.utils.AudioCodecs.AudioCodecDescription; import net.pterodactylus.util.database.DatabaseException; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.io.StreamCopier; @@ -122,6 +124,10 @@ public class AddTrackDerivativePage extends AdminBasePage { if (filename.indexOf('.') > filename.lastIndexOf('/')) { derivative.getProperties().set("file/extension", filename.substring(filename.lastIndexOf('.') + 1)); } + AudioCodecDescription audioCodecDescription = AudioCodecs.detect(filename); + if (audioCodecDescription != null) { + derivative.getProperties().set("audio/codec", audioCodecDescription.code); + } /* TODO - identify file type and media information */ getCore().getDataManager().saveTrackDerivate(derivative); -- 2.7.4