本文整理汇总了C#中PlayList类的典型用法代码示例。如果您正苦于以下问题:C# PlayList类的具体用法?C# PlayList怎么用?C# PlayList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayList类属于命名空间,在下文中一共展示了PlayList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getPlayList
/// <summary>
/// Parse the Playlist items
/// </summary>
/// <param name="playlist">PlayList playlist</param>
/// <returns></returns>
public PlayList getPlayList(string playlist)
{
if (playlist.Contains("#EXTM3U"))
{
_playlist = parsePlaylist(playlist, PlayListType.m3u);
}
if (playlist.Contains("<playlist version=\"1\" xmlns"))
{
_playlist = parsePlaylist(playlist, PlayListType.xspf);
}
if (playlist.Contains("[playlist]"))
{
_playlist = parsePlaylist(playlist, PlayListType.pls);
}
if (playlist.Contains("<ASX version=\"3\">"))
{
_playlist = parsePlaylist(playlist, PlayListType.asx);
}
//if (playlist.Contains("&clipinfo=\"title="))
//{
// RAMParser ramparser = new RAMParser();
// ramparser.Parse(playlist);
// playlistitem = ramparser.PlayListe;
//}
if (_playlist.Count == 0)
{
throw new Exception("Can not parse Playlist");
}
return _playlist;
}
示例2: Serialize
public void Serialize(string path, PlayList playList)
{
using (var stream = new FileStream(path, FileMode.Create))
{
Serialize(stream, playList);
}
}
示例3: Save
public bool Save(PlayList playlist, string fileName)
{
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(fileName, settings))
{
writer.WriteStartElement("WinampXML");
writer.WriteStartElement("playlist");
writer.WriteAttributeString("num_entries", playlist.Count.ToString());
writer.WriteAttributeString("label", playlist.Name);
foreach (PlayListItem item in playlist)
{
writer.WriteStartElement("entry");
writer.WriteAttributeString("Playstring", "file:" + item.FileName);
writer.WriteElementString("Name", item.Description);
writer.WriteElementString("Length", item.Duration.ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
}
return true;
}
catch (Exception e)
{
Log.Info("failed to save a playlist {0}. err: {1} stack: {2}", fileName, e.Message, e.StackTrace);
return false;
}
}
示例4: NoSelection4MusicHasPriority1
public void NoSelection4MusicHasPriority1()
{
var musicA = new Music("A") { Priority = 1 };
var musicB = new Music("B") { Priority = 1 };
var musicC = new Music("C") { Priority = 1 };
var musicD = new Music("D") { Priority = 1 };
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
var playList = new PlayList(_musicLibrary) {"A","B","C","D"};
playList.UpdateProbability();
const double unitProbability = 1d / 4d;
Assert.AreEqual(unitProbability, playList["A"].Probability);
Assert.AreEqual(unitProbability, playList["B"].Probability);
Assert.AreEqual(unitProbability, playList["C"].Probability);
Assert.AreEqual(unitProbability, playList["D"].Probability);
Assert.AreEqual(unitProbability * 1, playList["A"].CumulativeProbability);
Assert.AreEqual(unitProbability * 2, playList["B"].CumulativeProbability);
Assert.AreEqual(unitProbability * 3, playList["C"].CumulativeProbability);
Assert.AreEqual(unitProbability * 4, playList["D"].CumulativeProbability);
}
示例5: NoSelection4Music2Classic
public void NoSelection4Music2Classic()
{
var musicA = new Music("A") { Priority = 1 };
musicA[Constants.Tags.Genre] = "Classic";
var musicB = new Music("B") { Priority = 2 };
var musicC = new Music("C") { Priority = 3 };
musicC[Constants.Tags.Genre] = "Classic";
var musicD = new Music("D") { Priority = 4 };
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
var playList = new PlayList(_musicLibrary) { "A", "B", "C", "D" };
playList.UpdateProbability();
const double totalPriority = 10d;
const double unitProbability = 1d / totalPriority;
_store.VerifyAll();
AreEqual(unitProbability * musicA.Priority, playList["A"].Probability);
AreEqual(unitProbability * musicB.Priority, playList["B"].Probability);
AreEqual(unitProbability * musicC.Priority, playList["C"].Probability);
AreEqual(unitProbability * musicD.Priority, playList["D"].Probability);
AreEqual(unitProbability * 1, playList["A"].CumulativeProbability);
AreEqual(unitProbability * 3, playList["B"].CumulativeProbability);
AreEqual(unitProbability * 6, playList["C"].CumulativeProbability);
AreEqual(unitProbability * 10, playList["D"].CumulativeProbability);
}
示例6: addToPlButton_Click
private void addToPlButton_Click(object sender, EventArgs e)
{
try
{
string plName = PlBox.Text;
Int32 selectedRowCount =
plContentGrid.Rows.GetRowCount(DataGridViewElementStates.Selected);
int[] row = new int[selectedRowCount];
for (int i = 0; i < selectedRowCount; ++i)
{
row[i] = plContentGrid.SelectedRows[i].Index;
}
PlayList pl;
for (int i = 0; i < selectedRowCount; ++i)
{
pl = new PlayList(plName, Album.GetAlbumId(_pelems[row[i]].AlbumName),
Artist.CheckArtist(_pelems[row[i]].ArtistName),
TrackList.GetTrackId(_pelems[row[i]].TrackName));
pl.Create();
}
MessageBox.Show("Done!^_^", "TheResult");
}
catch
{
MessageBox.Show("Something bad has happened =(", "Whoops!");
}
}
示例7: Play
public void Play()
{
selectedList = new PlayList(0, null);
if (selectedModels.Count == 0)
selectedList = playlist;
else
{
foreach(Composition comp in selectedModels)
{
selectedList.AddComposition(comp);
}
}
// ButtonEnabled = false;
selectedList.IsStop = false;
NotifyPropertyChanged("ButtonEnabled");
selectedList.Complete += Stop;
selectedList.GetProcessLength += Process;
selectedList.Step += Step;
selectedList.Reset += Reset;
thread = new Thread(selectedList.Play);
thread.IsBackground = true;
thread.Start();
PlayCommand = new Command(action => Pause());
NotifyPropertyChanged("PlayCommand");
PlayButtonContent = "Pause";
NotifyPropertyChanged("PlayButtonContent");
}
示例8: 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;
}
}
示例9: Player
public Player(PlayList playList)
{
if (playList == null)
throw new ArgumentNullException("playList");
_playList = playList;
_track = _playList.GetFirstTrack();
State = PlayerStop.Instance;
}
示例10: NewlyAddedSongsAreNotMarkedPlayed
public void NewlyAddedSongsAreNotMarkedPlayed()
{
PlayList pl = new PlayList();
PlayListItem item = new PlayListItem("my song", "myfile.mp3");
pl.Add(item);
Assert.IsFalse(pl.AllPlayed());
}
示例11: LoadB4S
public void LoadB4S()
{
PlayList playlist = new PlayList();
IPlayListIO loader = new PlayListB4sIO();
Assert.IsTrue(loader.Load(playlist, "Core\\Playlists\\TestData\\exampleList.b4s"));
Assert.AreEqual(@"E:\Program Files\Winamp3\demo.mp3", playlist[0].FileName);
Assert.AreEqual(@"E:\Program Files\Winamp3\demo2.mp3", playlist[1].FileName);
Assert.AreEqual(2, playlist.Count);
}
示例12: 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);
}
示例13: RaiseContentChangeWhenAddItemToPlayList
public void RaiseContentChangeWhenAddItemToPlayList()
{
var newItem = new PlayListItem(new ImageId(30), "");
var playListListener = MockRepository.GenerateMock<PlayListListener>();
playListListener.Expect(l => l.ContentChanged(new PlayListContent(0, "", new []{newItem})));
var playList = new PlayList(new PlayListContent(0, "", new PlayListItem[0]), null);
playList.AddListener(playListListener);
playList.AddItem(newItem);
}
示例14: UpdateListViewWhenContentOfPlayListChange
public void UpdateListViewWhenContentOfPlayListChange()
{
var playList = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null);
m_Model.SelectedPlayListChanged(playList);
var newItem = new PlayListItem(new ImageId(33), "trentatre");
playList.AddItem(newItem);
Assert.That(GetPlayListItemsInListView(), Is.EquivalentTo(new[] {newItem}));
}
示例15: LoadM3U
public void LoadM3U()
{
PlayList playlist = new PlayList();
IPlayListIO loader = new PlayListM3uIO();
Assert.IsTrue(loader.Load(playlist, "Core\\Playlists\\TestData\\exampleList.m3u"), "playlist could not even load!");
Assert.IsTrue(playlist[0].FileName.EndsWith("Bob Marley - 01 - Judge Not.mp3"));
Assert.IsTrue(playlist[1].FileName.EndsWith("Bob Marley - 02 - One Cup of Coffee.mp3"));
Assert.IsTrue(playlist[2].FileName.EndsWith("Bob Marley - 03 - Simmer Down.mp3"));
Assert.IsTrue(playlist[3].FileName.EndsWith("Bob Marley - 05 - Guava Jelly.mp3"));
}