本文整理汇总了C#中PlaylistItem类的典型用法代码示例。如果您正苦于以下问题:C# PlaylistItem类的具体用法?C# PlaylistItem怎么用?C# PlaylistItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlaylistItem类属于命名空间,在下文中一共展示了PlaylistItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddHighestRatedToPlaylists
private void AddHighestRatedToPlaylists(Task<AlbumList> task)
{
switch (task.Status)
{
case TaskStatus.RanToCompletion:
Dispatcher.Invoke(() =>
{
AlbumList albumList = task.Result;
var tracks = albumList.Album.Where(a => !a.IsDir).ToList();
int duration = tracks.Sum(child => child.Duration);
PlaylistItem newHighestRatedPlaylist = new PlaylistItem
{
Duration = TimeSpan.FromSeconds(duration),
Name = "Highest Rated",
Tracks = tracks.Count,
Playlist = null
};
PlaylistItem currentHighestRatedPlaylist = _playlistItems.FirstOrDefault(p => p.Playlist == null && p.Name == "Highest Rated");
if (currentHighestRatedPlaylist == null)
_playlistItems.Add(newHighestRatedPlaylist);
else
{
_playlistItems.Remove(currentHighestRatedPlaylist);
_playlistItems.Add(newHighestRatedPlaylist);
}
});
break;
}
}
示例2: Update
public void Update(PlaylistItem playlistItem)
{
try
{
NHibernateSessionManager.Instance.BeginTransaction();
playlistItem.ValidateAndThrow();
playlistItem.Video.ValidateAndThrow();
PlaylistItem knownPlaylistItem = PlaylistItemDao.Get(playlistItem.Id);
if (knownPlaylistItem == null)
{
PlaylistItemDao.Update(playlistItem);
}
else
{
PlaylistItemDao.Merge(playlistItem);
}
NHibernateSessionManager.Instance.CommitTransaction();
}
catch (Exception exception)
{
Logger.Error(exception);
NHibernateSessionManager.Instance.RollbackTransaction();
throw;
}
}
示例3: AddItem
public virtual void AddItem(PlaylistItem playlistItem)
{
// Item must be removed from other Playlist before AddItem affects it.
if (playlistItem.Playlist != null && playlistItem.Playlist.Id != Id)
{
string message = string.Format("Item {0} is already a child of Playlist {1}", playlistItem.Title, playlistItem.Playlist.Title);
throw new Exception(message);
}
// Client might set the sequence number.
if (playlistItem.Sequence < 0)
{
if (Items.Any())
{
playlistItem.Sequence = Items.OrderBy(i => i.Sequence).Last().Sequence + 10000;
}
else
{
playlistItem.Sequence = 10000;
}
}
playlistItem.Playlist = this;
Items.Add(playlistItem);
}
示例4: AddLast
public PlaylistItem AddLast(PlaylistItem in_rItem)
{
IntPtr cPtr = AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_AddLast__SWIG_1(swigCPtr, PlaylistItem.getCPtr(in_rItem));
PlaylistItem ret = (cPtr == IntPtr.Zero) ? null : new PlaylistItem(cPtr, false);
return ret;
}
示例5: AddItem
public virtual void AddItem(PlaylistItem playlistItem)
{
// Item must be removed from other Playlist before AddItem affects it.
if (playlistItem.Playlist != null && playlistItem.Playlist.Id != Id)
{
string message = string.Format("Item {0} is already a child of Playlist {1}", playlistItem.Title, playlistItem.Playlist.Title);
throw new Exception(message);
}
if (Items.Count == 0)
{
FirstItem = playlistItem;
playlistItem.NextItem = playlistItem;
playlistItem.PreviousItem = playlistItem;
}
else
{
PlaylistItem firstItem = FirstItem;
PlaylistItem lastItem = firstItem.PreviousItem;
// Adjust our linked list and add the item.
lastItem.NextItem = playlistItem;
playlistItem.PreviousItem = lastItem;
firstItem.PreviousItem = playlistItem;
playlistItem.NextItem = firstItem;
}
playlistItem.Playlist = this;
Items.Add(playlistItem);
}
示例6: Create
public PlaylistDto Create(PlaylistDto playlistDto)
{
PlaylistDto savedPlaylistDto;
using (ITransaction transaction = Session.BeginTransaction())
{
User user = UserManager.Get(playlistDto.UserId);
Playlist playlist = new Playlist(playlistDto.Id);
playlistDto.SetPatchableProperties(playlist);
user.AddPlaylist(playlist);
List<PlaylistItem> playlistItems = new List<PlaylistItem>();
foreach (PlaylistItemDto dto in playlistDto.Items)
{
PlaylistItem playlistItem = new PlaylistItem(dto.Id, dto.Title, dto.Cid, dto.Song.Id, dto.Song.Type, dto.Song.Title, dto.Song.Duration, dto.Song.Author);
dto.SetPatchableProperties(playlistItem);
playlistItems.Add(playlistItem);
}
playlist.AddItems(playlistItems);
PlaylistManager.Save(playlist);
savedPlaylistDto = PlaylistDto.Create(playlist);
transaction.Commit();
}
return savedPlaylistDto;
}
示例7: AddSong
public void AddSong(PlaylistItem playlistItem, bool preventDuplicate = false)
{
if (preventDuplicate && Playlist.Contains(playlistItem))
return;
this.Playlist.Add(playlistItem);
OnSongAdded(playlistItem, new EventArgs());
}
示例8: ShouldMap
public void ShouldMap()
{
var sessionFactory = new NHibernateConfiguration().Configure().BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
var createdUser = new User {GooglePlusId = "some id?", Name = "user name"};
session.Save(createdUser);
var playlist2 = new Playlist("users second playlist")
{
User = createdUser,
Sequence = 200,
};
var video = new Video
{
Id = "some id",
Author = "video author",
Duration = 90,
HighDefinition = true,
Title = "my video",
};
session.Save(video);
var playlistItem = new PlaylistItem
{
Cid = "cid",
Playlist = playlist2,
Video = video,
Sequence = 300,
Title = "My playlist item",
};
playlist2.AddItem(playlistItem);
session.Save(playlist2);
session.Flush();
session.Clear();
var savedPlaylistItem = session.Get<PlaylistItem>(playlistItem.Id);
Assert.That(savedPlaylistItem.Title, Is.EqualTo("My playlist item"));
Assert.That(savedPlaylistItem.Id, Is.Not.EqualTo(Guid.Empty));
Assert.That(savedPlaylistItem.Sequence, Is.EqualTo(300));
Assert.That(savedPlaylistItem.Video, Is.EqualTo(playlistItem.Video));
transaction.Rollback();
}
}
}
示例9: Save
public void Save(PlaylistItem playlistItem)
{
try
{
DoSave(playlistItem);
}
catch (Exception exception)
{
Logger.Error(exception);
throw;
}
}
示例10: AddVideoToPlaylist
public static async Task<PlaylistItem> AddVideoToPlaylist(YouTubeService service, string playlistId, string videoId)
{
// Add a video to the newly created playlist.
var newPlaylistItem = new PlaylistItem();
newPlaylistItem.Snippet = new PlaylistItemSnippet();
newPlaylistItem.Snippet.PlaylistId = playlistId;
newPlaylistItem.Snippet.ResourceId = new ResourceId();
newPlaylistItem.Snippet.ResourceId.Kind = "youtube#video";
newPlaylistItem.Snippet.ResourceId.VideoId = videoId;
var playlistItemInsertReq = service.PlaylistItems.Insert(newPlaylistItem, "snippet");
var item = await playlistItemInsertReq.ExecuteAsync();
return item;
}
示例11: CreateItemInPlaylist
/// <summary>
/// Creates a new Video and PlaylistItem, puts item in the database and then returns
/// the item. Just a nice utility method to keep things DRY.
/// </summary>
public static PlaylistItem CreateItemInPlaylist(Playlist playlist)
{
Video videoNotInDatabase = CreateUnsavedVideoWithId();
// Create a new PlaylistItem and write it to the database.
string title = videoNotInDatabase.Title;
var playlistItem = new PlaylistItem(title, videoNotInDatabase);
playlist.AddItem(playlistItem);
PlaylistItemManager.Save(playlistItem);
return playlistItem;
}
示例12: CreateItemInPlaylist
/// <summary>
/// Creates a new Video and PlaylistItem, puts item in the database and then returns
/// the item. Just a nice utility method to keep things DRY.
/// </summary>
public static PlaylistItem CreateItemInPlaylist(Playlist playlist)
{
Video videoNotInDatabase = CreateUnsavedVideoWithId();
// Create a new PlaylistItem and write it to the database.
string title = videoNotInDatabase.Title;
var playlistItem = new PlaylistItem(title, videoNotInDatabase);
playlist.AddItem(playlistItem);
NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
PlaylistItemManager.Save(playlistItem);
NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
return playlistItem;
}
示例13: writeEntry
private void writeEntry(StreamWriter _swWriter, int counter, PlaylistItem objPlaylistItem, string fileFormat)
{
switch(fileFormat) {
case "m3u":
_swWriter.WriteLine(objPlaylistItem.getFullPath());
break;
case "pls":
_swWriter.WriteLine("File" + (counter + 1) + "=" + objPlaylistItem.getFullPath());
break;
case "xspf":
_swWriter.WriteLine("\t\t<track>");
_swWriter.WriteLine("\t\t\t<location>file://" + objPlaylistItem.getFullPath() + "</location>");
_swWriter.WriteLine("\t\t</track>");
break;
}
}
示例14: Equals_ShouldReturnTrue
public void Equals_ShouldReturnTrue()
{
var playlistItem1 = new PlaylistItem
{
Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } }
};
var playlistItem2 = new PlaylistItem
{
Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } }
};
var comparer = new PlaylistItemEqualityComparer();
Assert.IsTrue(comparer.Equals(playlistItem1, playlistItem2));
Assert.AreEqual(comparer.GetHashCode(playlistItem1), comparer.GetHashCode(playlistItem2));
}
示例15: Copy
public virtual void Copy(Playlist playlist)
{
Title = playlist.Title;
foreach (PlaylistItem playlistItem in playlist.Items)
{
PlaylistItem shareableItemCopy = new PlaylistItem(playlistItem);
AddItem(shareableItemCopy);
// If the old playlist's firstItemId was the currently old item we're iterating over,
// set the current new item as the first item.
if (playlistItem == playlist.FirstItem)
{
FirstItem = shareableItemCopy;
}
}
}