private ITag createFileMeta ( ) { log . debug ( "createFileMeta" ) ; // create tag for onMetaData event IoBuffer in = IoBuffer . allocate ( 1024 ) ; in . setAutoExpand ( true ) ; Output out = new Output ( in ) ; out . writeString ( "onMetaData" ) ; Map < Object , Object > props = new HashMap < Object , Object > ( ) ; props . put ( "audiocodecid" , IoConstants . FLAG_FORMAT_MP3 ) ; props . put ( "canSeekToEnd" , true ) ; // set id3 meta data if it exists if ( metaData != null ) { if ( metaData . artist != null ) { props . put ( "artist" , metaData . artist ) ; } if ( metaData . album != null ) { props . put ( "album" , metaData . album ) ; } if ( metaData . songName != null ) { props . put ( "songName" , metaData . songName ) ; } if ( metaData . genre != null ) { props . put ( "genre" , metaData . genre ) ; } if ( metaData . year != null ) { props . put ( "year" , metaData . year ) ; } if ( metaData . track != null ) { props . put ( "track" , metaData . track ) ; } if ( metaData . comment != null ) { props . put ( "comment" , metaData . comment ) ; } if ( metaData . duration != null ) { props . put ( "duration" , metaData . duration ) ; } if ( metaData . channels != null ) { props . put ( "channels" , metaData . channels ) ; } if ( metaData . sampleRate != null ) { props . put ( "samplerate" , metaData . sampleRate ) ; } if ( metaData . hasCoverImage ( ) ) { Map < Object , Object > covr = new HashMap <> ( 1 ) ; covr . put ( "covr" , new Object [ ] { metaData . getCovr ( ) } ) ; props . put ( "tags" , covr ) ; } //clear meta for gc metaData = null ; } log . debug ( "Metadata properties map: {}" , props ) ; // check for duration if ( ! props . containsKey ( "duration" ) ) { // generate it from framemeta if ( frameMeta != null ) { props . put ( "duration" , frameMeta . timestamps [ frameMeta . timestamps . length - 1 ] / 1000.0 ) ; } else { log . debug ( "Frame meta was null" ) ; } } // set datarate if ( dataRate > 0 ) { props . put ( "audiodatarate" , dataRate ) ; } out . writeMap ( props ) ; in . flip ( ) ; // meta-data ITag result = new Tag ( IoConstants . TYPE_METADATA , 0 , in . limit ( ) , null , prevSize ) ; result . setBody ( in ) ; return result ; }
Creates file metadata object