本文整理汇总了C#中MediaPortal.Playlists.PlayListItem类的典型用法代码示例。如果您正苦于以下问题:C# PlayListItem类的具体用法?C# PlayListItem怎么用?C# PlayListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayListItem类属于MediaPortal.Playlists命名空间,在下文中一共展示了PlayListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public bool Load(PlayList playlist, string fileName)
{
playlist.Clear();
XmlNodeList nodeEntries;
if (!LoadXml(fileName, out nodeEntries))
return false;
try
{
string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
foreach (XmlNode node in nodeEntries)
{
string file = ReadFileName(node);
if (file == null)
return false;
string infoLine = ReadInfoLine(node, file);
int duration = ReadLength(node);
SetupTv.Utils.GetQualifiedFilename(basePath, ref file);
PlayListItem newItem = new PlayListItem(infoLine, file, duration);
playlist.Add(newItem);
}
return true;
}
catch (Exception)
{
return false;
}
}
示例2: NewlyAddedSongsAreNotMarkedPlayed
public void NewlyAddedSongsAreNotMarkedPlayed()
{
PlayList pl = new PlayList();
PlayListItem item = new PlayListItem("my song", "myfile.mp3");
pl.Add(item);
Assert.IsFalse(pl.AllPlayed());
}
示例3: Add
public void Add(PlayListItem item)
{
_playlist.Add(item);
GUIListItem guiItem = new GUIListItem();
guiItem.Label = item.Description;
_playlistDic.Add(guiItem, item);
playlistControl.Add(guiItem);
}
示例4: GetNextReturnsFileName
public void GetNextReturnsFileName()
{
PlayListPlayer player = new PlayListPlayer();
player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
PlayList playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
PlayListItem item1 = new PlayListItem("apa", "c:\\apa.mp3");
playlist.Add(item1);
Assert.AreEqual("c:\\apa.mp3", player.GetNext());
}
示例5: InsertItemButNotStartPlayingGivesNull
public void InsertItemButNotStartPlayingGivesNull()
{
PlayListPlayer player = new PlayListPlayer();
player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
PlayList playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
PlayListItem item1 = new PlayListItem();
playlist.Add(item1);
Assert.IsNull(player.GetCurrentItem());
}
示例6: RemoveReallyRemovesASong
public void RemoveReallyRemovesASong()
{
PlayList pl = new PlayList();
PlayListItem item = new PlayListItem("my song", "myfile.mp3");
pl.Add(item);
pl.Remove("myfile.mp3");
Assert.AreEqual(0, pl.Count);
}
示例7: PlayMovesCurrentToItem
public void PlayMovesCurrentToItem()
{
PlayListPlayer player = new PlayListPlayer();
player.g_Player = this; //fake g_Player
player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
PlayList playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
PlayListItem item1 = new PlayListItem();
playlist.Add(item1);
player.PlayNext();
Assert.AreEqual(item1, player.GetCurrentItem());
Assert.IsTrue(hasPlayBeenCalled);
}
示例8: AllPlayedReturnsTrueWhenAllArePlayed
public void AllPlayedReturnsTrueWhenAllArePlayed()
{
PlayList pl = new PlayList();
PlayListItem item = new PlayListItem("my song", "myfile.mp3");
item.Played = true;
pl.Add(item);
item = new PlayListItem("my 2:d song", "myfile2.mp3");
item.Played = true;
pl.Add(item);
Assert.IsTrue(pl.AllPlayed());
}
示例9: Load
public bool Load(PlayList playlist, string fileName)
{
playlist.Clear();
try
{
string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
if (doc.DocumentElement == null)
{
return false;
}
XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/asx");
if (nodeRoot == null)
{
return false;
}
XmlNodeList nodeEntries = nodeRoot.SelectNodes("entry");
foreach (XmlNode node in nodeEntries)
{
XmlNode srcNode = node.SelectSingleNode("ref");
if (srcNode != null)
{
XmlNode url = srcNode.Attributes.GetNamedItem("href");
if (url != null)
{
if (url.InnerText != null)
{
if (url.InnerText.Length > 0)
{
fileName = url.InnerText;
if (!(fileName.ToLowerInvariant().StartsWith("http") || fileName.ToLowerInvariant().StartsWith("mms") || fileName.ToLowerInvariant().StartsWith("rtp")))
continue;
PlayListItem newItem = new PlayListItem(fileName, fileName, 0);
newItem.Type = PlayListItem.PlayListItemType.Audio;
playlist.Add(newItem);
}
}
}
}
}
return true;
}
catch (Exception ex)
{
Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
}
return false;
}
示例10: Load
public bool Load(PlayList playlist, string fileName)
{
playlist.Clear();
try
{
string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
if (doc.DocumentElement == null)
{
return false;
}
XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq");
if (nodeRoot == null)
{
return false;
}
XmlNodeList nodeEntries = nodeRoot.SelectNodes("media");
foreach (XmlNode node in nodeEntries)
{
XmlNode srcNode = node.Attributes.GetNamedItem("src");
if (srcNode != null)
{
if (srcNode.InnerText != null)
{
if (srcNode.InnerText.Length > 0)
{
fileName = srcNode.InnerText;
Util.Utils.GetQualifiedFilename(basePath, ref fileName);
PlayListItem newItem = new PlayListItem(fileName, fileName, 0);
newItem.Type = PlayListItem.PlayListItemType.Audio;
string description;
description = Path.GetFileName(fileName);
newItem.Description = description;
playlist.Add(newItem);
}
}
}
}
return true;
}
catch (Exception ex)
{
Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
}
return false;
}
示例11: ResetSetsAllItemsToFalse
public void ResetSetsAllItemsToFalse()
{
PlayList pl = new PlayList();
PlayListItem item = new PlayListItem("my song", "myfile.mp3");
pl.Add(item);
PlayListItem item2 = new PlayListItem("my 2:d song", "myfile2.mp3");
pl.Add(item2);
pl[0].Played = true;
pl[1].Played = true;
pl.ResetStatus();
Assert.IsFalse(pl[0].Played);
Assert.IsFalse(pl[1].Played);
}
示例12: CreatePlaylistItemFromVideoFile
/// <summary>
/// Create playlist item from a file
/// </summary>
/// <param name="file">Path to file</param>
/// <returns>Playlist item</returns>
internal static MediaPortal.Playlists.PlayListItem CreatePlaylistItemFromVideoFile(string file)
{
FileInfo info = new FileInfo(file);
MediaPortal.Playlists.PlayListItem item = new MediaPortal.Playlists.PlayListItem();
item.Description = info.Name;
item.FileName = info.FullName;
item.Type = PlayListItem.PlayListItemType.Video;
//item.Duration
IMDBMovie movie = new IMDBMovie();
int id = VideoDatabase.GetMovieInfo(file, ref movie);
if (id > 0)
{
item.Duration = movie.RunTime;
}
return item;
}
示例13: Load
public bool Load(PlayList playlist, string playlistFileName)
{
playlist.Clear();
try
{
var doc = new XmlDocument();
doc.Load(playlistFileName);
if (doc.DocumentElement == null)
return false;
XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq");
if (nodeRoot == null)
return false;
XmlNodeList nodeEntries = nodeRoot.SelectNodes("media");
if (nodeEntries != null)
foreach (XmlNode node in nodeEntries)
{
XmlNode srcNode = node.Attributes.GetNamedItem("src");
if (srcNode != null)
{
if (srcNode.InnerText != null)
{
if (srcNode.InnerText.Length > 0)
{
var playlistUrl = srcNode.InnerText;
var newItem = new PlayListItem(playlistUrl, playlistUrl, 0)
{
Type = PlayListItem.PlayListItemType.Audio
};
string description = Path.GetFileName(playlistUrl);
newItem.Description = description;
playlist.Add(newItem);
}
}
}
}
return true;
}
catch (Exception e)
{
Log.Error(e.StackTrace);
}
return false;
}
示例14: Load
public bool Load(PlayList playlist, string fileName)
{
playlist.Clear();
XmlNodeList nodeEntries;
if (!LoadXml(fileName, out nodeEntries))
{
return false;
}
try
{
string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
foreach (XmlNode node in nodeEntries)
{
string file = ReadFileName(node);
if (file == null)
{
return false;
}
string infoLine = ReadInfoLine(node, file);
int duration = ReadLength(node);
file = PathUtil.GetAbsolutePath(basePath, file);
PlayListItem newItem = new PlayListItem(infoLine, file, duration);
playlist.Add(newItem);
}
return true;
}
catch (Exception ex)
{
Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
return false;
}
}
示例15: AddItemToPlayList
protected override void AddItemToPlayList(GUIListItem listItem)
{
if (listItem.IsFolder)
{
// recursive
if (listItem.Label == "..")
{
return;
}
List<GUIListItem> itemlist = _virtualDirectory.GetDirectoryUnProtectedExt(listItem.Path, true);
foreach (GUIListItem item in itemlist)
{
AddItemToPlayList(item);
}
}
else
{
if (Util.Utils.IsVideo(listItem.Path) && !PlayListFactory.IsPlayList(listItem.Path))
{
PlayListItem playlistItem = new PlayListItem();
playlistItem.FileName = listItem.Path;
playlistItem.Description = listItem.Label;
playlistItem.Duration = listItem.Duration;
playlistItem.Type = PlayListItem.PlayListItemType.Video;
_playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playlistItem);
}
}
}