コード例 #1
0
        protected static MediaItem CreateMediaItem(BassUtils.AudioTrack track, char drive, int numTracks, string systemId, string title = null, string artist = null, string album = null, string albumArtist = null, string cdDbId = null, string upc = null, string irsc = null)
        {
            IDictionary <Guid, IList <MediaItemAspect> > aspects = new Dictionary <Guid, IList <MediaItemAspect> >();
            MediaItemAspect providerResourceAspect = MediaItemAspect.CreateAspect(aspects, ProviderResourceAspect.Metadata);

            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_INDEX, 0);
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_TYPE, ProviderResourceAspect.TYPE_PRIMARY);
            MediaItemAspect mediaAspect = MediaItemAspect.GetOrCreateAspect(aspects, MediaAspect.Metadata);
            MediaItemAspect audioAspect = MediaItemAspect.GetOrCreateAspect(aspects, AudioAspect.Metadata);

            if (!string.IsNullOrEmpty(irsc))
            {
                MediaItemAspect.AddOrUpdateExternalIdentifier(aspects, ExternalIdentifierAspect.SOURCE_ISRC, ExternalIdentifierAspect.TYPE_TRACK, irsc);
            }
            if (!string.IsNullOrEmpty(cdDbId))
            {
                MediaItemAspect.AddOrUpdateExternalIdentifier(aspects, ExternalIdentifierAspect.SOURCE_CDDB, ExternalIdentifierAspect.TYPE_ALBUM, cdDbId);
            }
            if (!string.IsNullOrEmpty(upc))
            {
                MediaItemAspect.AddOrUpdateExternalIdentifier(aspects, ExternalIdentifierAspect.SOURCE_UPCEAN, ExternalIdentifierAspect.TYPE_ALBUM, upc);
            }

            // TODO: Collect data from internet for the current audio CD
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH,
                                                AudioCDResourceProvider.ToResourcePath(drive, track.TrackNo).Serialize());
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemId);
            mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, GetTrackTitle(album, (int)track.TrackNo, title));
            audioAspect.SetAttribute(AudioAspect.ATTR_TRACK, (int)track.TrackNo);
            audioAspect.SetAttribute(AudioAspect.ATTR_DURATION, (long)track.Duration);
            audioAspect.SetAttribute(AudioAspect.ATTR_ENCODING, "PCM");
            audioAspect.SetAttribute(AudioAspect.ATTR_BITRATE, 1411); // 44.1 kHz * 16 bit * 2 channel
            audioAspect.SetAttribute(AudioAspect.ATTR_CHANNELS, 2);
            audioAspect.SetAttribute(AudioAspect.ATTR_NUMTRACKS, numTracks);

            if (!string.IsNullOrEmpty(album))
            {
                audioAspect.SetAttribute(AudioAspect.ATTR_ALBUM, album);
            }
            if (!string.IsNullOrEmpty(title))
            {
                audioAspect.SetAttribute(AudioAspect.ATTR_TRACKNAME, title);
            }
            if (!string.IsNullOrEmpty(artist))
            {
                audioAspect.SetCollectionAttribute(AudioAspect.ATTR_ARTISTS, new string[] { artist });
            }
            if (!string.IsNullOrEmpty(albumArtist))
            {
                audioAspect.SetCollectionAttribute(AudioAspect.ATTR_ALBUMARTISTS, new string[] { albumArtist });
            }

            return(new MediaItem(Guid.Empty, aspects));
        }
コード例 #2
0
        protected static MediaItem CreateMediaItem(BassUtils.AudioTrack track, char drive, int numTracks, string systemId)
        {
            IDictionary <Guid, MediaItemAspect> aspects = new Dictionary <Guid, MediaItemAspect>();
            MediaItemAspect providerResourceAspect      = MediaItemAspect.GetOrCreateAspect(aspects, ProviderResourceAspect.Metadata);
            MediaItemAspect mediaAspect = MediaItemAspect.GetOrCreateAspect(aspects, MediaAspect.Metadata);
            MediaItemAspect audioAspect = MediaItemAspect.GetOrCreateAspect(aspects, AudioAspect.Metadata);

            // TODO: Collect data from internet for the current audio CD
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH,
                                                AudioCDResourceProvider.ToResourcePath(drive, track.TrackNo).Serialize());
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemId);
            mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, "Track " + track.TrackNo);
            audioAspect.SetAttribute(AudioAspect.ATTR_TRACK, (int)track.TrackNo);
            audioAspect.SetAttribute(AudioAspect.ATTR_DURATION, (long)track.Duration);
            audioAspect.SetAttribute(AudioAspect.ATTR_ENCODING, "PCM");
            audioAspect.SetAttribute(AudioAspect.ATTR_BITRATE, 1411200); // 44.1 kHz * 16 bit * 2 channel
            audioAspect.SetAttribute(AudioAspect.ATTR_NUMTRACKS, numTracks);

            return(new MediaItem(Guid.Empty, aspects));
        }