当前位置: 首页>>代码示例>>C#>>正文


C# TrackInfo.HasAttribute方法代码示例

本文整理汇总了C#中Banshee.Collection.TrackInfo.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TrackInfo.HasAttribute方法的具体用法?C# TrackInfo.HasAttribute怎么用?C# TrackInfo.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Banshee.Collection.TrackInfo的用法示例。


在下文中一共展示了TrackInfo.HasAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTrackPath

        private string GetTrackPath (TrackInfo track, string ext)
        {
            string file_path = null;

            if (track.HasAttribute (TrackMediaAttributes.Podcast)) {
                string album = FileNamePattern.Escape (track.DisplayAlbumTitle);
                string title = FileNamePattern.Escape (track.DisplayTrackTitle);
                file_path = System.IO.Path.Combine ("Podcasts", album);
                file_path = System.IO.Path.Combine (file_path, title);
            } else if (track.HasAttribute (TrackMediaAttributes.VideoStream)) {
                string album = FileNamePattern.Escape (track.DisplayAlbumTitle);
                string title = FileNamePattern.Escape (track.DisplayTrackTitle);
                file_path = System.IO.Path.Combine (album, title);
            } else if (ms_device == null || !ms_device.GetTrackPath (track, out file_path)) {
                // If the folder_depth property exists, we have to put the files in a hiearchy of
                // the exact given depth (not including the mount point/audio_folder).
                if (FolderDepth != -1) {
                    int depth = FolderDepth;
                    string album_artist = FileNamePattern.Escape (track.DisplayAlbumArtistName);
                    string track_album  = FileNamePattern.Escape (track.DisplayAlbumTitle);
                    string track_number = FileNamePattern.Escape (String.Format ("{0:00}", track.TrackNumber));
                    string track_title  = FileNamePattern.Escape (track.DisplayTrackTitle);

                    if (depth == 0) {
                        // Artist - Album - 01 - Title
                        string track_artist = FileNamePattern.Escape (track.DisplayArtistName);
                        file_path = String.Format ("{0} - {1} - {2} - {3}", track_artist, track_album, track_number, track_title);
                    } else if (depth == 1) {
                        // Artist - Album/01 - Title
                        file_path = String.Format ("{0} - {1}", album_artist, track_album);
                        file_path = System.IO.Path.Combine (file_path, String.Format ("{0} - {1}", track_number, track_title));
                    } else if (depth == 2) {
                        // Artist/Album/01 - Title
                        file_path = album_artist;
                        file_path = System.IO.Path.Combine (file_path, track_album);
                        file_path = System.IO.Path.Combine (file_path, String.Format ("{0} - {1}", track_number, track_title));
                    } else {
                        // If the *required* depth is more than 2..go nuts!
                        for (int i = 0; i < depth - 2; i++) {
                            if (i == 0) {
                                file_path = album_artist.Substring (0, Math.Min (i+1, album_artist.Length)).Trim ();
                            } else {
                                file_path = System.IO.Path.Combine (file_path, album_artist.Substring (0, Math.Min (i+1, album_artist.Length)).Trim ());
                            }

                        }

                        // Finally add on the Artist/Album/01 - Track
                        file_path = System.IO.Path.Combine (file_path, album_artist);
                        file_path = System.IO.Path.Combine (file_path, track_album);
                        file_path = System.IO.Path.Combine (file_path, String.Format ("{0} - {1}", track_number, track_title));
                    }
                } else {
                    file_path = MusicLibrarySource.MusicFileNamePattern.CreateFromTrackInfo (track);
                }
            }

            if (track.HasAttribute (TrackMediaAttributes.VideoStream)) {
              file_path = System.IO.Path.Combine (WritePathVideo, file_path);
            } else {
              file_path = System.IO.Path.Combine (WritePath, file_path);
            }
            file_path += ext;

            return file_path;
        }
开发者ID:allquixotic,项目名称:banshee-gst-sharp-work,代码行数:66,代码来源:MassStorageSource.cs

示例2: GetFolderForTrack

 private Folder GetFolderForTrack (TrackInfo track)
 {
     if (track.HasAttribute (TrackMediaAttributes.VideoStream)) {
         return mtp_device.VideoFolder;
     } else if (track.HasAttribute (TrackMediaAttributes.Podcast)) {
         return mtp_device.PodcastFolder;
     } else {
         return mtp_device.MusicFolder;
     }
 }
开发者ID:fatman2021,项目名称:gnome-apps,代码行数:10,代码来源:MtpSource.cs

示例3: ImportPlaylistToLibrary

        public static void ImportPlaylistToLibrary (string path, PrimarySource source, DatabaseImportManager importer)
        {
            try {
                SafeUri uri = new SafeUri (path);
                PlaylistParser parser = new PlaylistParser ();
                string relative_dir = System.IO.Path.GetDirectoryName (uri.LocalPath);
                if (relative_dir[relative_dir.Length - 1] != System.IO.Path.DirectorySeparatorChar) {
                    relative_dir = relative_dir + System.IO.Path.DirectorySeparatorChar;
                }
                parser.BaseUri = new Uri (relative_dir);
                if (parser.Parse (uri)) {
                    List<string> uris = new List<string> ();
                    foreach (PlaylistElement element in parser.Elements) {
                        uris.Add (element.Uri.LocalPath);
                    }

                    if (source == null) {
                        if (uris.Count > 0) {
                            // Get the media attribute of the 1st Uri in Playlist 
                            // and then determine whether the playlist belongs to Video or Music
                            SafeUri uri1 = new SafeUri (uris[0]);
                            var track = new TrackInfo ();
                            StreamTagger.TrackInfoMerge (track, uri1);

                            if (track.HasAttribute (TrackMediaAttributes.VideoStream))
                                source = ServiceManager.SourceManager.VideoLibrary;
                            else
                                source = ServiceManager.SourceManager.MusicLibrary;
                        }
                    }

                    // Give source a fallback value - MusicLibrary when it's null
                    if (source == null)
                        source = ServiceManager.SourceManager.MusicLibrary;
                    
                    // Only import an non-empty playlist
                    if (uris.Count > 0) {
                        ImportPlaylistWorker worker = new ImportPlaylistWorker (
                            parser.Title,
                            uris.ToArray (), source, importer);
                        worker.Import ();
                    }
                }
            } catch (Exception e) {
                Hyena.Log.Exception (e);
            }
        }
开发者ID:gclark916,项目名称:banshee,代码行数:47,代码来源:PlaylistFileUtil.cs

示例4: HandleOpen

        private void HandleOpen(TrackInfo track)
        {
            var uri = track.Uri;
            if (current_state != PlayerState.Idle && current_state != PlayerState.NotReady && current_state != PlayerState.Contacting) {
                Close (false);
            }

            try {
                CurrentTrackTimeStamp = DateTime.Now;
                current_track = track;
                OnStateChanged (PlayerState.Loading);
                OpenUri (uri, track.HasAttribute (TrackMediaAttributes.VideoStream) || track is UnknownTrackInfo);
            } catch (Exception e) {
                Close (true);
                OnEventChanged (new PlayerEventErrorArgs (e.Message));
            }
        }
开发者ID:ptrimble,项目名称:banshee,代码行数:17,代码来源:PlayerEngine.cs

示例5: HandleNextTrack

        private void HandleNextTrack(TrackInfo track)
        {
            pending_track = track;
            if (current_state != PlayerState.Playing) {
                // Pre-buffering the next track only makes sense when we're currently playing
                // Instead, just open.
                if (track != null && track.Uri != null) {
                    HandleOpen (track);
                    Play ();
                }
                return;
            }

            try {
                // Setting the next track doesn't change the player state.
                SetNextTrackUri (track == null ? null : track.Uri,
                    track == null || track.HasAttribute (TrackMediaAttributes.VideoStream) || track is UnknownTrackInfo);
            } catch (Exception e) {
                Log.Exception ("Failed to pre-buffer next track", e);
            }
        }
开发者ID:ptrimble,项目名称:banshee,代码行数:21,代码来源:PlayerEngine.cs

示例6: DownloadLyrics

        public string DownloadLyrics(TrackInfo track)
        {
            if (track == null) {
                return null;
            }

            //check if the network is up
            if (!ServiceManager.Get<Banshee.Networking.Network> ().Connected) {
                throw new NetworkUnavailableException ("You don't seem to be connected to internet. Check your network connection.");
            }

            if (!track.HasAttribute (TrackMediaAttributes.Music)) {
                throw new InvalidFileException ("You can only download lyrics for a music track.");
            }

            //download the lyrics
            string lyrics = null;
            foreach (var source in GetSources (SourceData.LyricsSelector)) {
                bool found = false;
                try {
                    lyrics = source.Source.GetLyrics (track.ArtistName, track.TrackTitle);
                    found = IsLyricsOk (lyrics);
                } catch (Exception e) {
                    Log.Warning (e);
                    continue;
                } finally {
                    source.IncrementLyrics (found);
                }

                if (found) {
                    lyrics = AttachFooter (Utils.ToNormalString(lyrics), source.Source.Credits);
                    Log.DebugFormat ("Fetched lyrics from {0} for {1} - {2}",
                        source.Source.Name, track.ArtistName, track.TrackTitle);
                    return lyrics;
                }
            }

            Log.DebugFormat ("Couldn't find lyrics for {0} - {1}", track.ArtistName, track.TrackTitle);
            return null;
        }
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:40,代码来源:LyricsManager.cs

示例7: FindTrackMediaAttributes

        private static void FindTrackMediaAttributes (TrackInfo track, TagLib.File file)
        {
            if ((file.Properties.MediaTypes & TagLib.MediaTypes.Audio) != 0) {
                track.MediaAttributes |= TrackMediaAttributes.AudioStream;
            }

            if ((file.Properties.MediaTypes & TagLib.MediaTypes.Video) != 0) {
                track.MediaAttributes |= TrackMediaAttributes.VideoStream;
            }

            if (file.Tag.FirstGenre == "Podcast" || file.Tag.Album == "Podcast") {
                track.MediaAttributes |= TrackMediaAttributes.Podcast;
            }

            // TODO: Actually figure out, if possible at the tag/file level, if
            // the file is actual music, podcast, audiobook, movie, tv show, etc.
            // For now just assume that if it's only audio and not podcast, it's
            // music, since that's what we've just historically assumed on any media type
            if (!track.HasAttribute (TrackMediaAttributes.VideoStream) &&
                !track.HasAttribute (TrackMediaAttributes.Podcast)) {
                track.MediaAttributes |= TrackMediaAttributes.Music;
            } else {
                // If it was already set, unset it
                track.MediaAttributes &= ~TrackMediaAttributes.Music;
            }
        }
开发者ID:kelsieflynn,项目名称:banshee,代码行数:26,代码来源:StreamTagger.cs


注:本文中的Banshee.Collection.TrackInfo.HasAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。