本文整理汇总了C#中MediaPortal.TagReader.MusicTag类的典型用法代码示例。如果您正苦于以下问题:C# MusicTag类的具体用法?C# MusicTag怎么用?C# MusicTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MusicTag类属于MediaPortal.TagReader命名空间,在下文中一共展示了MusicTag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MusicTag
/// <summary>
/// copy constructor
/// </summary>
/// <param name="tag"></param>
public MusicTag(MusicTag tag)
{
if (tag == null) return;
Artist = tag.Artist;
Album = tag.Album;
Genre = tag.Genre;
Title = tag.Title;
Comment = tag.Comment;
Year = tag.Year;
Duration = tag.Duration;
Track = tag.Track;
TimesPlayed = tag.m_TimesPlayed;
Rating = tag.Rating;
BitRate = tag.BitRate;
Composer = tag.Composer;
CoverArtImageBytes = tag.CoverArtImageBytes;
AlbumArtist = tag.AlbumArtist;
Lyrics = tag.Lyrics;
Comment = tag.Comment;
ReplayGainTrack = tag.ReplayGainTrack;
ReplayGainTrackPeak = tag.ReplayGainTrackPeak;
ReplayGainAlbum = tag.ReplayGainAlbum;
ReplayGainAlbumPeak = tag.ReplayGainAlbumPeak;
DateTimePlayed = tag.DateTimePlayed;
DateTimeModified = tag.DateTimeModified;
}
开发者ID:Eddie-Jee,项目名称:MediaPortal-1,代码行数:31,代码来源:MusicTag.cs
示例2: FolderThumbCreator
// Filename is a full path+file
public FolderThumbCreator(string Filename, MusicTag FileTag)
{
lock (_filename)
{
_filename = Filename;
_filetag = FileTag;
work = new Work(new DoWorkHandler(this.PerformRequest));
work.ThreadPriority = ThreadPriority.Lowest;
GlobalServiceProvider.Get<IThreadPool>().Add(work, QueuePriority.Low);
}
}
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:13,代码来源:FolderThumbCreator.cs
示例3: GetTrackTags
private void GetTrackTags()
{
if (CurrentTrackTag != null)
{
PreviousTrackTag = CurrentTrackTag;
}
bool isInternetStream = Util.Utils.IsAVStream(CurrentTrackFileName) && !Util.Utils.IsLastFMStream(CurrentTrackFileName);
if (isInternetStream && _usingBassEngine)
{
NextTrackTag = null;
return;
}
PlayListItem currentItem = PlaylistPlayer.GetCurrentItem();
PlayListItem nextItem = PlaylistPlayer.GetNextItem();
if (currentItem != null)
{
CurrentTrackTag = (MusicTag)currentItem.MusicTag;
}
else
{
CurrentTrackTag = null;
}
if (nextItem != null)
{
NextTrackTag = (MusicTag)nextItem.MusicTag;
}
else
{
NextTrackTag = null;
}
}
开发者ID:cmendozac,项目名称:MediaPortal-1,代码行数:35,代码来源:GUIMusicPlayingNow.cs
示例4: UpdateSimilarTrackWorker
private void UpdateSimilarTrackWorker(string filename, MusicTag tag)
{
if (tag == null) return;
lstSimilarTracks.Clear();
List<LastFMSimilarTrack> tracks;
try
{
Log.Debug("GUIMusicPlayingNow: Calling Last.FM to get similar Tracks");
tracks = LastFMLibrary.GetSimilarTracks(tag.Title, tag.Artist);
}
catch (Exception ex)
{
Log.Error("Error getting similar tracks in now playing");
Log.Error(ex);
return;
}
Log.Debug("GUIMusicPlayingNow: Number of similar tracks returned from Last.FM: {0}", tracks.Count);
var dbTracks = GetSimilarTracksInDatabase(tracks);
for (var i = 0; i < 3; i++)
{
if (dbTracks.Count > 0)
{
var trackNo = Randomizer.Next(0, dbTracks.Count);
var song = dbTracks[trackNo];
var t = song.ToMusicTag();
var item = new GUIListItem
{
AlbumInfoTag = song,
MusicTag = tag,
IsFolder = false,
Label = song.Title,
Path = song.FileName
};
item.AlbumInfoTag = song;
item.MusicTag = t;
GUIMusicBaseWindow.SetTrackLabels(ref item, MusicSort.SortMethod.Album);
dbTracks.RemoveAt(trackNo); // remove song after adding to playlist to prevent the same sone being added twice
if (g_Player.currentFileName != filename) return; // track has changed since request so ignore
lstSimilarTracks.Add(item);
}
}
Log.Debug("GUIMusicPlayingNow: Tracks returned after matching Last.FM results with database tracks: {0}", lstSimilarTracks.Count);
}
开发者ID:cmendozac,项目名称:MediaPortal-1,代码行数:52,代码来源:GUIMusicPlayingNow.cs
示例5: GetStreamTags
/// <summary>
/// Returns the Tags of an AV Stream
/// </summary>
/// <returns></returns>
public MusicTag GetStreamTags()
{
MusicTag tag = new MusicTag();
if (_tagInfo == null)
{
return tag;
}
// So let's filter it out ourself
string title = _tagInfo.title;
int streamUrlIndex = title.IndexOf("';StreamUrl=");
if (streamUrlIndex > -1)
{
title = _tagInfo.title.Substring(0, streamUrlIndex);
}
tag.Album = _tagInfo.album;
tag.Artist = _tagInfo.artist;
tag.Title = title;
tag.Genre = _tagInfo.genre;
try
{
tag.Year = Convert.ToInt32(_tagInfo.year);
}
catch (FormatException)
{
tag.Year = 0;
}
return tag;
}
开发者ID:cmendozac,项目名称:MediaPortal-1,代码行数:34,代码来源:BassAudioEngine.cs
示例6: GetMultipleValueFieldValue
/// <summary>
/// Returns the field value out of the MusicTag
/// </summary>
/// <param name="tag"></param>
/// <param name="field"></param>
/// <returns></returns>
private string GetMultipleValueFieldValue(MusicTag tag, string field)
{
if (field == "artist")
{
return tag.Artist;
}
else if (field == "albumartist")
{
return tag.AlbumArtist;
}
else if (field == "genre")
{
return tag.Genre;
}
else if (field == "composer")
{
return tag.Composer;
}
return "";
}
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:26,代码来源:MusicDatabase.Updates.cs
示例7: ExtractCoverArt
private void ExtractCoverArt(MusicTag tag)
{
string formattedAlbum = tag.Album.Trim(trimChars);
// Mantis 3078: Filename for Multiple Artists should not contain a semicolon, cause it wouldn't be found later on
int i = 0;
string formattedArtist = "";
string[] strArtistSplit = tag.Artist.Split(new char[] {';', '|'});
foreach (string strArtist in strArtistSplit)
{
string s = strArtist.Trim();
if (_stripArtistPrefixes)
{
Util.Utils.StripArtistNamePrefix(ref s, true);
}
// Concatenate multiple Artists with " _ "
// When we search for multiple artists Covers: "artist a | artist b", the string " | " gets replaced by " _ ",
// so we need to build the file accordingly
if (i > 0)
{
formattedArtist += " _ ";
}
formattedArtist += s.Trim();
i++;
}
string tagAlbumName = string.Format("{0}-{1}", formattedArtist, formattedAlbum);
string smallThumbPath = Util.Utils.GetCoverArtName(Thumbs.MusicAlbum, Util.Utils.MakeFileName(tagAlbumName));
string largeThumbPath = Util.Utils.GetLargeCoverArtName(Thumbs.MusicAlbum, Util.Utils.MakeFileName(tagAlbumName));
// Get the cover image directly out of the mp3 file's ID3 tag
if (_extractEmbededCoverArt)
{
try
{
if (tag.CoverArtImageBytes != null)
{
bool extractFile = false;
if (!Util.Utils.FileExistsInCache(smallThumbPath))
{
extractFile = true;
}
else
{
// Prevent creation of the thumbnail multiple times, when all songs of an album contain coverart <-- that's ugly (rtv)
try
{
DateTime fileDate = File.GetLastWriteTime(smallThumbPath);
TimeSpan span = _currentDate - fileDate;
if (span.Days > 0)
{
extractFile = true;
}
}
catch (Exception)
{
extractFile = true;
}
}
if (extractFile)
{
try
{
string mp3TagImage = tag.CoverArtFile;
if (!String.IsNullOrEmpty(mp3TagImage))
{
if (
!Util.Picture.CreateThumbnail(mp3TagImage, smallThumbPath, (int)Thumbs.ThumbResolution,
(int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsSmall))
{
Log.Info("MusicDatabase: Could not extract thumbnail from {0}", tag.FileName);
}
if (
!Util.Picture.CreateThumbnail(mp3TagImage, largeThumbPath, (int)Thumbs.ThumbLargeResolution,
(int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsLarge))
{
Log.Info("MusicDatabase: Could not extract thumbnail from {0}", tag.FileName);
}
Util.Utils.FileDelete(mp3TagImage); // clean up the temp file directly
}
}
catch (Exception)
{
Log.Warn("MusicDatabase: Invalid cover art image found in {0}-{1}! {2}", tag.Artist, tag.Title,
tag.FileName);
}
}
}
}
catch (Exception) {}
}
// Scan folders only one time per song
if (string.IsNullOrEmpty(_previousNegHitDir) || (Path.GetDirectoryName(tag.FileName) != _previousNegHitDir))
{
string sharefolderThumb;
//.........这里部分代码省略.........
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:101,代码来源:MusicDatabase.Updates.cs
示例8: ShowSong
private void ShowSong(string filename)
{
GUIDialogNotify dlg = (GUIDialogNotify) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_NOTIFY);
if (dlg == null)
{
return;
}
//get albumart
string albumart = g_Player.CurrentFile;
int e = albumart.LastIndexOf(@"\") + 1;
albumart = albumart.Remove(e);
if (_slideList[_currentSlideIndex].Contains(albumart))
{
albumart = string.Empty;
}
else
{
albumart = Util.Utils.GetFolderThumbForDir(albumart);
if (!Util.Utils.FileExistsInCache(albumart))
{
albumart = string.Empty;
}
}
// get Song-info
// hwahrmann 2006-11-22 Using the Tagreader caused a COM exception in Win Media SDK, when reading WMA files
// Accessing the Music Database instead of using the Tagreader.
//MediaPortal.TagReader.MusicTag tag = MediaPortal.TagReader.TagReader.ReadTag(g_Player.CurrentFile);
Song song = new Song();
MusicTag currentSong = new MusicTag();
// If we don't have a tag in the db, we use the filename without the extension as song.title
if (!mDB.GetSongByFileName(g_Player.CurrentFile, ref song))
{
try
{
// try Tagreader method to parse information
var pl = PlayListPlayer.SingletonPlayer.GetPlaylist(PlayListPlayer.SingletonPlayer.CurrentPlaylistType);
var plI = pl.First(plItem => plItem.FileName == filename);
if (plI != null || plI.MusicTag != null)
{
currentSong = (MusicTag)plI.MusicTag;
}
}
catch (Exception)
{
// Catch the COM execption but continue code with Music Database instead.
}
}
// Show Dialog
dlg.Reset();
dlg.Dispose();
dlg.SetImage(albumart);
dlg.SetHeading(4540);
if (currentSong == null || string.IsNullOrEmpty(currentSong.Title) ||
(string.IsNullOrEmpty(currentSong.Artist) && string.IsNullOrEmpty(currentSong.AlbumArtist)))
{
song.Title = Path.GetFileNameWithoutExtension(g_Player.CurrentFile);
dlg.SetText(song.Title + "\n" + song.Artist + "\n" + song.Album);
}
else
{
dlg.SetText(currentSong.Title + "\n" + currentSong.Artist + "\n" + currentSong.Album);
}
dlg.TimeOut = 5;
dlg.DoModal(GUIWindowManager.ActiveWindow);
}
开发者ID:edalex86,项目名称:MediaPortal-1,代码行数:69,代码来源:GUISlideShow.cs
示例9: ToMusicTag
public MusicTag ToMusicTag()
{
MusicTag tmpTag = new MusicTag();
tmpTag.Title = this.Title;
tmpTag.Album = this.Album;
tmpTag.DiscID = this.DiscId;
tmpTag.DiscTotal = this.DiscTotal;
tmpTag.AlbumArtist = this.AlbumArtist;
tmpTag.Artist = this.Artist;
tmpTag.Duration = this.Duration;
tmpTag.Genre = this.Genre;
tmpTag.Composer = this.Composer;
tmpTag.Conductor = this.Conductor;
tmpTag.Track = this.Track;
tmpTag.TrackTotal = this.TrackTotal;
tmpTag.Year = this.Year;
tmpTag.Rating = this.Rating;
tmpTag.TimesPlayed = this.TimesPlayed;
tmpTag.Lyrics = this.Lyrics;
tmpTag.DateTimeModified = this.DateTimeModified;
tmpTag.DateTimePlayed = this.DateTimePlayed;
tmpTag.Comment = this.Comment;
tmpTag.FileType = this.FileType;
tmpTag.Codec = this.Codec;
tmpTag.BitRateMode = this.BitRateMode;
tmpTag.BPM = this.BPM;
tmpTag.BitRate = this.BitRate;
tmpTag.Channels = this.Channels;
tmpTag.SampleRate = this.SampleRate;
tmpTag.HasAlbumArtist = string.IsNullOrEmpty(this.AlbumArtist);
return tmpTag;
}
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:34,代码来源:Song.cs
示例10: GetCoverArt
public static string GetCoverArt(bool isfolder, string filename, MusicTag tag)
{
string strAlbumName = string.Empty;
string strArtistName = string.Empty;
if (tag != null)
{
if (!string.IsNullOrEmpty(tag.Album))
{
strAlbumName = tag.Album;
}
if (!string.IsNullOrEmpty(tag.Artist))
{
strArtistName = tag.Artist;
}
}
// attempt to pick up album thumb if already scanned
string strThumb = Util.Utils.GetAlbumThumbName(strArtistName, strAlbumName);
if (Util.Utils.FileExistsInCache(strThumb))
{
if (_createMissingFolderThumbs && _createMissingFolderThumbCache)
{
string folderThumb = Util.Utils.GetFolderThumb(filename);
if (!Util.Utils.FileExistsInCache(folderThumb))
{
FolderThumbCreator thumbCreator = new FolderThumbCreator(filename, tag);
}
}
return strThumb;
}
// attempt to load folder.jpg
if (!Util.Utils.IsAVStream(filename))
{
string strFolderThumb = string.Empty;
if (isfolder)
{
strFolderThumb = Util.Utils.GetLocalFolderThumbForDir(filename);
}
else
{
strFolderThumb = Util.Utils.GetLocalFolderThumb(filename);
}
if (Util.Utils.FileExistsInCache(strFolderThumb))
{
return strFolderThumb;
}
else
{
if (_createMissingFolderThumbCache)
{
FolderThumbCacher thumbworker = new FolderThumbCacher(filename, false);
}
}
}
//TODO: consider lookup of embedded artwork
return string.Empty;
}
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:61,代码来源:GUIMusicBaseWindow.cs
示例11: LoadPlayList
protected void LoadPlayList(string strPlayList, bool startPlayback, bool isAsynch, bool defaultLoad)
{
IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
if (loader == null)
{
return;
}
PlayList playlist = new PlayList();
if (!Util.Utils.FileExistsInCache(strPlayList))
{
Log.Info("Playlist: Skipping non-existing Playlist file: {0}", strPlayList);
return;
}
if (!loader.Load(playlist, strPlayList))
{
if (isAsynch && defaultLoad) // we might not be in GUI yet! we have asynch and default load because we might want to use asynch loading from gui button too, later!
throw new Exception(string.Format("Unable to load Playlist file: {0}", strPlayList)); // exception is handled in backgroundworker
else
TellUserSomethingWentWrong();
return;
}
if (_autoShuffleOnLoad)
{
playlist.Shuffle();
}
playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
if (playlist.Count == 1 && startPlayback)
{
Log.Info("GUIMusic:Play: play single playlist item - {0}", playlist[0].FileName);
// Default to type Music, when a playlist has been selected from My Music
g_Player.Play(playlist[0].FileName, g_Player.MediaType.Music);
return;
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
// clear current playlist
//playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();
Song song = new Song();
PlayList newPlaylist = new PlayList();
// add each item of the playlist to the playlistplayer
for (int i = 0; i < playlist.Count; ++i)
{
if (null != bw && isAsynch && bw.CancellationPending)
return;
PlayListItem playListItem = playlist[i];
m_database.GetSongByFileName(playListItem.FileName, ref song);
MusicTag tag = new MusicTag();
tag = song.ToMusicTag();
playListItem.MusicTag = tag;
if (Util.Utils.FileExistsInCache(playListItem.FileName) ||
playListItem.Type == PlayListItem.PlayListItemType.AudioStream)
{
newPlaylist.Add(playListItem);
}
else
{
Log.Info("Playlist: File {0} no longer exists. Skipping item.", playListItem.FileName);
}
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
ReplacePlaylist(newPlaylist);
if (startPlayback)
StartPlayingPlaylist();
}
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:78,代码来源:GUIMusicBaseWindow.cs
示例12: ShowAlbumInfo
public void ShowAlbumInfo(int parentWindowID, string artistName, string albumName, string strPath, MusicTag tag)
{
Log.Debug("Searching for album: {0} - {1}", albumName, artistName);
var dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
var pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
var errorEncountered = true;
var album = new AlbumInfo();
var albumInfo = new MusicAlbumInfo();
if (m_database.GetAlbumInfo(albumName, artistName, ref album))
{
// we already have album info in database so just use that
albumInfo.Set(album);
errorEncountered = false;
}
else
{// lookup details. start with artist
if (null != pDlgOK && !Win32API.IsConnectedToInternet())
{
pDlgOK.SetHeading(703);
pDlgOK.SetLine(1, 703);
pDlgOK.SetLine(2, string.Empty);
pDlgOK.DoModal(GetID);
return;
}
// show dialog box indicating we're searching the album
if (dlgProgress != null)
{
dlgProgress.Reset();
dlgProgress.SetHeading(326);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetPercentage(0);
dlgProgress.StartModal(GetID);
dlgProgress.Progress();
dlgProgress.ShowProgressBar(true);
}
var scraper = new AllmusicSiteScraper();
List<AllMusicArtistMatch> artists;
var selectedMatch = new AllMusicArtistMatch();
if (scraper.GetArtists(artistName, out artists))
{
if (null != dlgProgress)
{
dlgProgress.SetPercentage(20);
dlgProgress.Progress();
}
if (artists.Count == 1)
{
// only have single match so no need to ask user
Log.Debug("Single Artist Match Found");
selectedMatch = artists[0];
}
else
{
// need to get user to choose which one to use
Log.Debug("Muliple Artist Match Found ({0}) prompting user", artists.Count);
var pDlg = (GUIDialogSelect2) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_SELECT2);
if (null != pDlg)
{
pDlg.Reset();
pDlg.SetHeading(GUILocalizeStrings.Get(1303));
foreach (var i in artists.Select(artistMatch => new GUIListItem
{
Label = artistMatch.Artist + " - " + artistMatch.Genre,
Label2 = artistMatch.YearsActive,
Path = artistMatch.ArtistUrl,
IconImage = artistMatch.ImageUrl
}))
{
pDlg.Add(i);
}
pDlg.DoModal(GetID);
// and wait till user selects one
var iSelectedMatch = pDlg.SelectedLabel;
if (iSelectedMatch < 0)
{
return;
}
selectedMatch = artists[iSelectedMatch];
}
if (null != dlgProgress)
{
dlgProgress.Reset();
dlgProgress.SetHeading(326);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetPercentage(40);
dlgProgress.StartModal(GetID);
dlgProgress.ShowProgressBar(true);
dlgProgress.Progress();
}
//.........这里部分代码省略.........
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:101,代码来源:GUIMusicBaseWindow.cs
示例13: FindCoverArt
public void FindCoverArt(bool isFolder, string artistName, string albumName, string strPath, MusicTag tag,
int albumId)
{
GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
if (null != pDlgOK && !Win32API.IsConnectedToInternet())
{
pDlgOK.SetHeading(703);
pDlgOK.SetLine(1, 703);
pDlgOK.SetLine(2, string.Empty);
pDlgOK.DoModal(GetID);
//throw new Exception("no internet");
return;
}
else if (!Win32API.IsConnectedToInternet())
{
//throw new Exception("no internet");
return;
}
bool bDisplayErr = false;
GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
AlbumInfo albuminfo = new AlbumInfo();
MusicAlbumInfo album = new MusicAlbumInfo();
GUICoverArtGrabberResults guiCoverGrabberResults =
(GUICoverArtGrabberResults)GUIWindowManager.GetWindow((int)Window.WINDOW_MUSIC_COVERART_GRABBER_RESULTS);
if (null != guiCoverGrabberResults)
{
guiCoverGrabberResults.SearchMode = GUICoverArtGrabberResults.SearchDepthMode.Album;
GUIDialogProgress dlgProgress =
(GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
if (dlgProgress != null)
{
dlgProgress.Reset();
dlgProgress.SetHeading(185);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetLine(3, string.Empty);
dlgProgress.StartModal(GetID);
}
guiCoverGrabberResults.GetAlbumCovers(artistName, albumName, strPath, GetID, true);
guiCoverGrabberResults.DoModal(GetID);
albuminfo = guiCoverGrabberResults.SelectedAlbum;
if (GUICoverArtGrabberResults.CancelledByUser)
{
string line1Text = GUILocalizeStrings.Get(4507);
if (line1Text.Length == 0)
{
line1Text = "Cover art grabber aborted by user";
}
string caption = GUILocalizeStrings.Get(4511);
if (caption.Length == 0)
{
caption = "Cover Art Grabber Done";
}
if (null != dlgOk)
{
dlgOk.SetHeading(caption);
dlgOk.SetLine(1, line1Text);
dlgOk.SetLine(2, string.Empty);
dlgOk.DoModal(GetID);
}
}
else if (albuminfo != null)
{
// the GUICoverArtGrabberResults::SelectedAlbum AlbumInfo object contains
// the Artist and Album name returned by the Amazon Webservice which may not
// match our original artist and album. We want to use the original artist
// and album name...
albuminfo.Artist = artistName;
albuminfo.Album = albumName;
SaveCoverArtImage(albuminfo, strPath, true, true);
facadeLayout.RefreshCoverArt();
}
else
{
bDisplayErr = true;
}
}
if (bDisplayErr)
{
if (null != dlgOk)
{
dlgOk.SetHeading(187);
dlgOk.SetLine(1, 187);
//.........这里部分代码省略.........
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:101,代码来源:GUIMusicBaseWindow.cs
示例14: BuildAutoDJFilter
private static string BuildAutoDJFilter(string filterMask, MusicTag tag)
{
var filter = filterMask;
try
{
if (!string.IsNullOrEmpty(tag.Genre))
{
filter = filter.Replace("{genre}", "'" + tag.Genre + "'");
}
if (!string.IsNullOrEmpty(tag.Album))
{
filter = filter.Replace("{album}", "'" + tag.Album + "'");
}
if (!string.IsNullOrEmpty(tag.AlbumArtist))
{
filter = filter.Replace("{albumartist}", "'" + tag.AlbumArtist + "'");
}
if (!string.IsNullOrEmpty(tag.Artist))
{
filter = filter.Replace("{albumartist}", "'" + tag.Artist + "'");
}
if (tag.Year > 0)
{
filter = filter.Replace("{year}", tag.Year.ToString(CultureInfo.InvariantCulture));
}
if (tag.Rating > 0)
{
filter = filter.Replace("{rating}", tag.Rating.ToString(CultureInfo.InvariantCulture));
}
if (tag.BPM > 0)
{
filter = filter.Replace("{BPM}", tag.BPM.ToString(CultureInfo.InvariantCulture));
}
}
catch (Exception ex)
{
Log.Debug("Applying filter failed: {0}, exception {1}", filter, ex);
}
return filter;
}
开发者ID:rameshsankar,项目名称:MediaPortal-1,代码行数:41,代码来源:LastFMScrobbler.cs
示例15: AddMultipleValueFields
private void AddMultipleValueFields(MusicTag tag)
{
try
{
string strSQL;
string strMultiValueFieldValue = "";
foreach (string field in _multipleValueFields)
{
// split up the multiple value field
strMultiValueFieldValue = GetMultipleValueFieldValue(tag, field).Trim(new char[] {'|', ' '});
string[] splittedFields = strMultiValueFieldValue.Split(new char[] {';', '|'});
foreach (string s in splittedFields)
{
// ATTENTION: We need to use the 'like' operator instead of '=' to have case insensitive searching
strSQL = String.Format("select {0} from {1} where {0} like '{2}'", GetMultipleValueField(field),
GetMultipleValueTable(field), s == "" ? " " : s.Trim());
if (DirectExecute(strSQL).Rows.Count < 1)
{
// Insert the Artist
strSQL = String.Format("insert into {1} ({0}) values ('{2}')", GetMultipleValueField(field),
GetMultipleValueTable(field), s == "" ? " " : s.Trim());
DirectExecute(strSQL);
}
}
}
}
catch (Exception ex)
{
Log.Error("Musicdatabase: Exception adding multiple field value: {0} stack: {1}", ex.Message, ex.StackTrace);
Open();
}
}
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:33,代码来源:MusicDatabase.Updates.cs
示例16: ToMusicTag
public MusicTag ToMusicTag()
{
var tmpTag = new MusicTag
{
Title = this.Title,
Album = this.Album,
DiscID = this.DiscId,
DiscTotal = this.DiscTotal,
AlbumArtist = this.AlbumArtist,
Artist = this.Artist,
Duration = this.Duration,
Genre = this.Genre,
Composer = this.Composer,
Conductor = this.Conductor,
Track = this.Track,
TrackTotal = this.TrackTotal,
Year = this.Year,
Rating = this.Rating,
TimesPlayed = this.TimesPlayed,
Lyrics = this.Lyrics,
DateTimeModified = this.DateTimeModified,
DateTimePlayed = this.DateTimePlayed,
Comment = this.Comment,
FileType = this.FileType,
Codec = this.Codec,
BitRateMode = this.BitRateMode,
BPM = this.BPM,
BitRate = this.BitRate,
Channels = this.Channels,
SampleRate = this.SampleRate,
HasAlbumArtist = string.IsNullOrEmpty(this.AlbumArtist)
};
return tmpTag;
}
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:35,代码来源:Song.cs
示例17: UpdateVariousArtist
private void UpdateVariousArtist(MusicTag tag)
{
string currentDir = Path.GetDirectoryName(tag.FileName);
// on first cal, set the directory name
if (_previousDirectory == null)
{
_previousDirectory = currentDir;
}
if (_previousMusicTag == null)
{
_previousMusicTag = tag;
}
if (_previousDirectory.ToLowerInvariant() == currentDir.ToLowerInvariant())
{
// already have detected Various artists in this folder. no further checking needed
if (_foundVariousArtist)
{
return;
}
// Is the Artist different and also no different AlbumArtist set?
if (_previousMusicTag.Artist != tag.Artist && !tag.HasAlbumArtist)
{
_foundVariousArtist = true;
return;
}
}
else
{
if (_foundVariousArtist)
{
// Let's add the "Various Artist" to the albumArtist table
string varArtist = "| Various Artists | ";
strSQL = string.Format("insert into albumartist (strAlbumArtist) values('{0}')", varArtist);
DirectExecute(strSQL);
List<SongMap> songs = new List<SongMap>();
GetSongsByPath(_previousDirectory, ref songs);
foreach (SongMap map in songs)
{
int id = map.m_song.Id;
strSQL = string.Format("update tracks set strAlbumArtist = '| Various Artists | ' where idTrack={0}", id);
DirectExecute(strSQL);
// Now we need to remove the Artist of the song from the AlbumArtist table,
// if he's not an AlbumArtist in a different album
Song song = map.m_song as Song;
string[] strAlbumArtistSplit = song.AlbumArtist.Split(new char[] {'|'});
foreach (string strTmp in strAlbumArtistSplit)
{
string strAlbumArtist = strTmp.Trim(trimChars);
DatabaseUtility.RemoveInvalidChars(ref strAlbumArtist);
strSQL = string.Format("select strAlbumArtist from tracks where strAlbumArtist like '%| {0} |%'",
strAlbumArtist);
if (DirectExecute(strSQL).Rows.Count < 1)
{
// No AlbumArtist entry found, so let's remove this artist from albumartist
strSQL = String.Format("delete from albumartist where strAlbumArtist like '%{0}%'", strAlbumArtist);
DirectExecute(strSQL);
}
}
}
}
_previousMusicTag = tag;
_previousDirectory = currentDir;
_foundVariousArtist = false;
}
}
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:73,代码来源:MusicDatabase.Updates.cs
示例18: ScrobbleTrack
/// <summary>
/// Scrobble track to last.fm
/// </summary>
/// <param name="tag">tag details of track to scrobble</param>
/// <param name="stoptime">how long song had played for</param>
/// <exception cref="ArgumentNullException">Tag must be provided</exception>
public static void ScrobbleTrack(MusicTag tag, int stoptime)
{
if (tag == null)
{
throw new ArgumentNullException("tag");
}
if (string.IsNullOrEmpty(tag.Title))
{
Log.Info("Unable to scrobble: {0}", tag.FileName);
Log.Info("No title for track");
return;
}
var artist = tag.Artist;
if (string.IsNullOrEmpty(artist))
{
if (string.IsNullOrEmpty(tag.AlbumArtist))
{
Log.Info("Unable to scrobble: {0}", tag.FileName);
Log.Info("No artist or album artist found");
return;
}
artist = tag.AlbumArtist;
}
if (tag.Duration < 30)
{ // last.fm say not to scrobble songs that last less than 30 seconds
return;
}
if (stoptime < 120 && stoptime < (tag.Duration / 2))
{ // last.fm say only to scrobble is more than 2 minutes has been listned to or
// at least hald the duration of the song
return;
}
try
{
using (var client = new WebClient())
using (var stream = client.OpenRead("http://www.google.com"))
{
Log.Debug("internet connection detected. to scrobble: {0} - {1}", tag.Title, artist);
}
}
catch
{
CacheScrobble(tag, DateTime.UtcNow);
Log.Info("No internet connection so unable to scrobble: {0} - {1}", tag.Title, artist);
Log.Info("Scrobble has been cached");
return;
}
try
{
LastFMLibrary.Scrobble(artist, tag.Title, tag.Album);
Log.Info("Last.fm scrobble: {0} - {1}", tag.Title, artist);
}
catch (LastFMException ex)
{
if (ex.LastFMError == LastFMException.LastFMErrorCode.ServiceOffline ||
ex.LastFMError == LastFMException.LastFMErrorCode.ServiceUnavailable)
{
CacheScrobble(tag, DateTime.UtcNow);
Log.Info("Unable to scrobble: {0} - {1}", tag.Title, artist);
Log.Info("Scrobble has been cached");
}
else
{
Log.Error("Unable to scrobble: {0} - {1}", tag.Title, artist);
Log.Error(ex);
}
}
}
开发者ID:rameshsankar,项目名称:MediaPortal-1,代码行数:80,代码来源:LastFMScrobbler.cs
示例19: AddRandomSongToPlaylist
private bool AddRandomSongToPlaylist(ref Song song)
{
//check duplication
PlayList playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
for (int i = 0; i < playlist.Count; i++)
{
PlayListItem item = playlist[i];
if (item.FileName == song.FileName)
{
return false;
}
}
//add to playlist
PlayListItem playlistItem = new PlayListItem();
playlistItem.Type = PlayListItem.PlayListItemType.Audio;
StringBuilder sb = new StringBuilder();
playlistItem.FileName = song.FileName;
sb.Append(song.Track);
sb.Append(". ");
sb.Append(song.Artist);
sb.Append(" - ");
sb.Append(song.Title);
playlistItem.Description = sb.ToString();
playlistItem.Duration = song.Duration;
MusicTag tag = new MusicTag();
tag = song.ToMusicTag();
playlistItem.MusicTag = tag;
playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Add(playlistItem);
return true;
}
开发者ID:akhilgt,项目名称:MediaPortal-1,代码行数:35,代码来源:GUIMusicPlaylist.cs
示例20: CacheScrobble
/// <summary>
/// Cache scrobble to submit to last.fm later
/// </summary>
/// <param name="tag">tag details of track being scrobbled</param>
/// <param name="dtPlayed">When track was played</param>
public static void CacheScrobble(MusicTag tag, DateTime dtPlayed)
{
var artist = tag.Artist ?? tag.AlbumArtist;
CacheScrobble(artist, tag.Title, tag.Album, true, DateTime.UtcNow);
}
开发者ID:rameshsankar,项目名称:MediaPortal-1,代码行数:10,代码来源:LastFMScrobbler.cs
注:本文中的MediaPortal.TagReader.MusicTag类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License |
请发表评论