This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final Transformation mirror = new Transformation() { | |
@Override | |
public Bitmap transform(Bitmap source) { | |
Matrix m = new Matrix(); | |
m.preScale(-1, 1); | |
Bitmap src = source; | |
Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false); | |
dst.setDensity(DisplayMetrics.DENSITY_DEFAULT); | |
src.recycle(); | |
return dst; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"music": [ | |
{ | |
"title": "Jazz in Paris", | |
"album": "Jazz & Blues", | |
"artist": "Media Right Productions", | |
"genre": "Jazz & Blues", | |
"source": "Jazz_In_Paris.mp3", | |
"image": "album_art.jpg", | |
"trackNumber": 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
fun main(args: Array<String>) { | |
File(args[0]) | |
.walk() | |
.forEach { sourceFile -> | |
println("Reading $sourceFile") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
File(args[0]) | |
.walk() | |
.filter { it.isFile && it.extension.equals("mp3", ignoreCase = true) } | |
.forEach { sourceFile -> | |
println("Reading $sourceFile") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jaudiotagger.audio.AudioFileIO | |
import java.io.File | |
fun main(args: Array<String>) { | |
File(args[0]) | |
.walk() | |
.filter { it.isFile && it.extension.equals("mp3", ignoreCase = true) } | |
.forEach { sourceFile -> | |
val audioFile = AudioFileIO.read(sourceFile) | |
println("Reading $audioFile") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun extractMetadataOrNull(audioFile: AudioFile): JsonObject? { | |
val js = JsonObject() | |
with(audioFile.tag ?: return null) { | |
js["title"] = getFirst(FieldKey.TITLE) ?: return null | |
js["artist"] = getFirst(FieldKey.ARTIST) ?: getFirst(FieldKey.ALBUM_ARTIST) ?: return null | |
js["album"] = getFirst(FieldKey.ALBUM) ?: return null | |
js["genre"] = if (getFirst(FieldKey.GENRE).isNullOrBlank()) "unknown" else getFirst(FieldKey.GENRE) | |
js["source"] = audioFile.file.absolutePath | |
js["image"] = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun readAudioFileOrNull(file: File): AudioFile? = | |
try { AudioFileIO.read(file) } catch (e: Exception) { null } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
File(args[0]) | |
.walk() | |
.mapNotNull { file -> | |
readAudioFileOrNull(file) | |
} | |
.mapNotNull { audioFile -> | |
extractMetadataOrNull(audioFile) | |
} | |
.forEach { println(it) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val manifestWriter = System.out.writer() | |
manifestWriter.use { | |
sourceDirectory | |
.walk() | |
.filter { | |
it.isFile && it.extension.equals("mp3", ignoreCase = true) | |
} | |
.mapNotNull { file -> | |
readAudioFileOrNull(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sourceDirectory = File(args.getOrNull(0) ?: System.getProperty("user.dir")) |
OlderNewer