/** * copy constructor * * @param mdosong {@link MDOSong} * @param album {@link Album} this is not an {@link MDOAlbum} to avoid cross references */ public Song( MDOSong mdosong, Album album ) { setSid( mdosong.getSid() ); setTrack( mdosong.getTrack() ); setName( mdosong.getName() ); setAlbum( album ); setFileName( mdosong.getLocation() ); setRate( mdosong.getRate() ); setVolume( mdosong.getVolume() ); }
public void playSong( String username, long sidSong, int clientQueuePosition ) throws IOException { MDOSong song = daoSong.get( username, sidSong ); if ( song != null ) { MessicRadioPlugin mrp = getPlugin(); File mp3song = new File( song.calculateAbsolutePath( daoSettings.getSettings() ) ); if ( mp3song.exists() ) { MessicRadioSong mrs = new MessicRadioSong(); mrs.songFile = mp3song; mrs.authorName = song.getAlbum().getAuthor().getName(); mrs.albumName = song.getAlbum().getName(); mrs.albumyear = song.getAlbum().getYear(); MDOAlbumResource mar = song.getAlbum().getCover(); if ( mar != null ) { mrs.coverImage = new File( mar.calculateAbsolutePath( daoSettings.getSettings() ) ); } mrs.songSid = song.getSid(); mrs.songName = song.getName(); mrs.trackNumber = song.getTrack(); mrs.albumGenre = ( song.getAlbum().getGenre() != null ? song.getAlbum().getGenre().getName() : "" ); mrs.albumComments = song.getAlbum().getComments(); mrs.clientQueuePosition = clientQueuePosition; mrp.castSong( mrs ); } } }
public byte[] getAlbumCover( Integer preferredWidth, Integer preferredHeight ) throws SidNotFoundMessicException, ResourceNotFoundMessicException, IOException { long songSid = getInfo().songSid; if ( songSid > 0 ) { MDOSong song = daoSong.get( songSid ); if ( song != null ) { return apialbum.getAlbumCover( new User( song.getOwner() ), song.getAlbum().getSid(), preferredWidth, preferredHeight ); } } return null; }
/** * Obtain the theorical filename of a song, i mean, the location that sould be, based on the track number and song * name (the location is the filename for songs) * * @param song {@link MDOSong} song to get the theorical file name * @param extension {@link String} extension for the fileName * @return {@link String} the theorical location */ public final String calculateSongTheoricalFileName( String extension, char illegalCharacterReplacement ) { String result = Util.leftZeroPadding( getTrack(), 2 ) + "-" + getName(); result = Util.replaceIllegalFilenameCharactersNew( result, illegalCharacterReplacement ); String resultExtension = Util.replaceIllegalFilenameCharactersNew( extension, illegalCharacterReplacement ); result = result + "." + resultExtension; return result; }
String entryName = song.getLocation(); if ( songs.get( entryName ) == null ) ZipEntry ze = new ZipEntry( entryName ); zos.putNextEntry( ze ); FileInputStream in = new FileInputStream( song.calculateAbsolutePath( daoSettings.getSettings() ) ); int len; byte buffer[] = new byte[1024];
MDOUser user = song.getOwner(); String token = loginDLNA( user.getLogin(), user.getPassword() ); ai.setAlbum( song.getAlbum().getName() ); ai.setArtists( new PersonWithRole[] { new PersonWithRole( song.getAlbum().getAuthor().getName() ) } ); ai.setDate( "" + song.getAlbum().getYear() ); List<DescMeta> listdm = new ArrayList<DescMeta>(); ai.setDescMetadata( listdm ); ai.setRefID( "" + song.getSid() ); ai.setRights( new String[] {} ); ai.setCreator( song.getAlbum().getAuthor().getName() ); ai.setGenres( new String[] { song.getAlbum().getGenre().getName() } ); ai.setParentID( song.getOwner().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getAuthor().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getSid() ); ai.setId( song.getOwner().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getAuthor().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getSid() + MessicContainer.SEPARATOR + song.getSid() ); ai.setTitle( song.getName() ); ai.setOriginalTrackNumber( song.getTrack() ); + "/messic/services/songs/" + song.getSid() + "/dlna?messic_token=" + token );
MDOSong mdoSong = new MDOSong(); File fnew = null; mdoSong.setStatistics( ss ); mdoSong.setTrack( song.getTrack() ); mdoSong.setName( song.getName() ); String secureExtension = song.calculateSecureExtension( replacementChar ); String theoricalFileName = mdoSong.calculateSongTheoricalFileName( secureExtension, replacementChar ); mdoSong.setLocation( theoricalFileName ); mdoSong.setVolume( song.getVolume() ); mdoSong.setOwner( mdouser ); mdoSong.setAlbum( mdoAlbum ); fnew = new File( currentAlbumPath + mdoSong.calculateVolumePath() + File.separatorChar + mdoSong.getLocation() ); fnew = new File( currentAlbumPath + mdoSong.calculateVolumePath() + File.separatorChar + mdoSong.getLocation() ); mdoSong.setTrack( song.getTrack() ); mdoSong.setName( song.getName() ); ( flagExistingAlbum ? mdoSong.calculateAbsolutePath( oldAlbumPath, oldVolumes ) : mdoSong.calculateAbsolutePath( settings ) ); String theoricalFileName = mdoSong.calculateSongTheoricalFileName( mdoSong.getExtension(), replacementChar ); mdoSong.setLocation( theoricalFileName );
if ( mdosong != null ) String oldLocation = mdosong.calculateAbsolutePath( daoSettings.getSettings() ); boolean nameChanged = !song.getName().equals( mdosong.getName() ); mdosong.setName( song.getName() ); mdosong.setRate( song.getRate() ); mdosong.setTrack( song.getTrack() ); String newLocation = mdosong.calculateAbsolutePath( daoSettings.getSettings() ); File fOld = new File( oldLocation ); if ( fOld.exists() )
for ( MDOSong mdoSong : songs ) String absPath = mdoSong.calculateAbsolutePath( settings ); File fnew = new File( absPath ); if ( fnew.exists() ) ssong.track = mdoSong.getTrack(); ssong.name = mdoSong.getName();
MDOSongStatistics statistics = song.getStatistics(); if ( statistics == null ) statistics = daoSongStatistics.getStatistics( user.getLogin(), song.getSid() ); song.setStatistics( statistics ); String filePath = song.calculateAbsolutePath( settings ); File fsong = new File( filePath ); if ( fsong.exists() )
String entryName = song.getLocation(); if ( songs.get( entryName ) == null ) r.setLocation( song.getLocation() ); r.setName( song.getName() ); resources.add( r ); FileInputStream in = new FileInputStream( song.calculateAbsolutePath( daoSettings.getSettings() ) ); int len; byte buffer[] = new byte[1024];
for ( MDOSong mdoSong : results ) finalResult.put( mdoSong.getSid(), mdoSong );
String path = song.calculateAbsolutePath( daoSettings.getSettings() ); File fpath = new File( path ); fpath.delete();
/** * copy constructor * * @param mdosong {@link MDOSong} */ public Song( MDOSong mdosong, boolean includeAlbumInfo, boolean includeAuthorInfo ) { if ( mdosong != null ) { setSid( mdosong.getSid() ); setTrack( mdosong.getTrack() ); setName( mdosong.getName() ); setVolume( mdosong.getVolume() ); if ( includeAlbumInfo ) { Album album = new Album( mdosong.getAlbum(), includeAuthorInfo, false, false ); setAlbum( album ); } setFileName( mdosong.getLocation() ); setRate( mdosong.getRate() ); } }