Search in sources :

Example 6 with MediaType

use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.

the class NamedMediaType method getFromDescription.

/**
 * Retrieves the named media type for the specified schema uri.
 *
 * This should only be used if you are positive that the media type
 * is already cached for this description OR it is not a default
 * type.
 */
public static NamedMediaType getFromDescription(String description) {
    NamedMediaType type = CACHED_TYPES.get(description);
    if (type != null)
        return type;
    MediaType mt = MediaType.getMediaTypeForSchema(description);
    return getFromMediaType(mt);
}
Also used : MediaType(com.limegroup.gnutella.MediaType)

Example 7 with MediaType

use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.

the class LibraryFilesTransferHandler method canImport.

@Override
public boolean canImport(TransferSupport support) {
    try {
        LibraryNode node = getNodeFromLocation(support.getDropLocation());
        if (!(node instanceof DirectoryHolderNode)) {
            return false;
        }
        DirectoryHolder dirHolder = ((DirectoryHolderNode) node).getDirectoryHolder();
        // dropping folder or folders on file types and finished downloads.
        if (droppingFoldersToAddToLibrary(support, dirHolder, true)) {
            return true;
        }
        if (!(dirHolder instanceof MediaTypeSavedFilesDirectoryHolder)) {
            return false;
        }
        MediaTypeSavedFilesDirectoryHolder mediaTypeSavedFilesDirHolder = (MediaTypeSavedFilesDirectoryHolder) dirHolder;
        MediaType mt = mediaTypeSavedFilesDirHolder.getMediaType();
        return mt.equals(MediaType.getAudioMediaType()) && DNDUtils.supportCanImport(LibraryPlaylistsTableTransferable.ITEM_ARRAY, support, null, false);
    } catch (Throwable e) {
        LOG.error("Error in LibraryFilesTransferHandler processing", e);
    }
    return false;
}
Also used : MediaType(com.limegroup.gnutella.MediaType)

Example 8 with MediaType

use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.

the class LibraryFilesTableMediator method updateTableFiles.

/**
 * Updates the Table based on the selection of the given table.
 * Perform lookups to remove any store files from the shared folder
 * view and to only display store files in the store view
 */
void updateTableFiles(DirectoryHolder dirHolder) {
    if (dirHolder == null) {
        return;
    }
    if (dirHolder instanceof MediaTypeSavedFilesDirectoryHolder) {
        MediaType mediaType = ((MediaTypeSavedFilesDirectoryHolder) dirHolder).getMediaType();
        setMediaType(mediaType);
        if (mediaType.equals(MediaType.getAudioMediaType())) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_AUDIO);
        } else if (mediaType == MediaType.getImageMediaType()) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_PICTURES);
        } else if (mediaType == MediaType.getDocumentMediaType()) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_DOCUMENTS);
        } else if (mediaType == MediaType.getVideoMediaType()) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_VIDEOS);
        } else if (mediaType == MediaType.getTorrentMediaType()) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_TORRENTS);
        } else if (mediaType == MediaType.getProgramMediaType()) {
            UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_APPLICATIONS);
        }
    } else {
        setMediaType(MediaType.getAnyTypeMediaType());
    }
    clearTable();
    List<List<File>> partitionedFiles = split(100, Arrays.asList(dirHolder.getFiles()));
    for (List<File> partition : partitionedFiles) {
        final List<File> fPartition = partition;
        BackgroundExecutorService.schedule(new Runnable() {

            @Override
            public void run() {
                for (final File file : fPartition) {
                    GUIMediator.safeInvokeLater(new Runnable() {

                        public void run() {
                            addUnsorted(file);
                        }
                    });
                }
                GUIMediator.safeInvokeLater(new Runnable() {

                    public void run() {
                        LibraryMediator.instance().getLibrarySearch().addResults(fPartition.size());
                    }
                });
            }
        });
    }
    forceResort();
}
Also used : MediaType(com.limegroup.gnutella.MediaType) List(java.util.List) File(java.io.File)

Example 9 with MediaType

use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.

the class NamedMediaType method getFromExtension.

/**
 * Retrieves the named media type from the specified extension.
 *
 * This should only be used if you are positive that the media type
 * is already cached for this extension.
 */
public static NamedMediaType getFromExtension(String extension) {
    MediaType mt = MediaType.getMediaTypeForExtension(extension);
    if (mt == null)
        return null;
    String description = mt.getMimeType();
    return getFromDescription(description);
}
Also used : MediaType(com.limegroup.gnutella.MediaType)

Aggregations

MediaType (com.limegroup.gnutella.MediaType)9 StreamableSearchResult (com.frostwire.search.StreamableSearchResult)2 File (java.io.File)2 StreamMediaSource (com.frostwire.gui.player.StreamMediaSource)1 YouTubeCrawledStreamableSearchResult (com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult)1 LaunchableProvider (com.limegroup.gnutella.gui.util.GUILauncher.LaunchableProvider)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1