From: David ‘Bombe’ Roden Date: Mon, 30 Jul 2012 10:02:17 +0000 (+0200) Subject: Set automatically detected codec on new derivatives. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7d564a0d18ae3385677021e396a02b9fbedd8f94;p=demoscenemusic.git Set automatically detected codec on new derivatives. --- 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);