/// <summary> /// Replaces the entire track queue with the contents of a track container. You should check the UserMutatedQueue property before performing a destructive replacement. /// </summary> /// <param name="a">The track container.</param> /// <param name="shuffle">Whether to shuffle the order in which the track container is added.</param> public void ReplaceAllWithTrackContainer(ITrackContainer a, bool shuffle) { Contract.Requires(a != null); Contract.Requires(a.TrackList != null); Contract.Requires(a.TrackList.Count != 0); _trackList.BatchChanges(); Clear(); if (shuffle) { var items = a.TrackList.AsParallel().Select(x => x.UniqueTrack()).OrderBy(x => x.UniqueId); _trackList.Enqueue(items); _trackList.Dequeue(); } else { var items = a.TrackList.AsParallel().AsOrdered().Select(x => x.UniqueTrack()); _trackList.Enqueue(items); _trackList.Dequeue(); } _trackList.FlushChanges(); }
/// <summary> /// Adds a track container to the queue. /// </summary> /// <param name="trackContainer">The track container to add.</param> /// <param name="play">Whether to immediately start playing.</param> public void Add(ITrackContainer trackContainer, bool play) { MutateQueue(() => _queue.Add(trackContainer.TrackList)); if (Status == AudioControllerStatus.Inactive && play) { Play(); } }
private static void CreateWatermark(ITrackContainer tracks, string imageName, double duration) { var videoTrack = tracks.AddTrack(); var clip = videoTrack.AddImage(imageName, 0, duration); clip.AddEffect(0, duration, StandardEffects.CreateAlphaSetterRamp(0.5)); videoTrack.AddTransition(0, duration, StandardTransitions.CreateKey(KeyTransitionType.Rgb, null, null, null, 0x00FFFFFF, null), false); }
public Track(ITrackContainer container, IAMTimeline timeline, IAMTimelineTrack track, string name, int priority) { _container = container; _timeline = timeline; _track = track; _name = name; _priority = priority; int hr = timeline.GetDefaultFPS(out _fps); DESError.ThrowExceptionForHR(hr); }
public Track(ITrackContainer container, IAMTimeline timeline, IAMTimelineTrack track, string name, int priority) { _container = container; _timeline = timeline; _track = track; _name = name; _priority = priority; int hr = timeline.GetDefaultFPS(out _fps); DESError.ThrowExceptionForHR(hr); }
/// <summary> /// Creates a des track, wraps it into an ITrack, adds it to a collection and /// returns the new ITrack wrapper. /// </summary> /// <param name="desTimeline"></param> /// <param name="desComposition"></param> /// <param name="tracks"></param> /// <param name="name"></param> /// <param name="priority"></param> /// <returns></returns> internal static ITrack AddTrackToCollection(ITrackContainer container, IAMTimeline desTimeline, IAMTimelineComp desComposition, AddOnlyList <ITrack> tracks, string name, int priority) { priority = ReorderPriorities(tracks, priority); ITrack track = new Track(container, desTimeline, CreateTrack(desTimeline, desComposition, name, priority), name, priority); tracks.Add(track); return(track); }
/// <summary> /// Adds the voice track /// </summary> /// <param name="tracks">The track container that will hold the new track</param> /// <param name="text">The text that will be converted to speech</param> /// <returns>The new text-to-speech track</returns> private ITrack AddVoiceTrack(ITrackContainer tracks, string text) { var audioTrack = tracks.AddTrack(); var audioFileName = Path.Combine(workArea, "voice.wav"); var voice = CreateVoice(); CreateAudioFile(audioFileName, voice, text); audioTrack.AddAudio(audioFileName); return(audioTrack); }
public async Task ValidateAsync(ITrackContainer trackContainer) { if (trackContainer == null) { throw new ArgumentNullException(nameof(trackContainer)); } var album = await this.GetBy(trackContainer); if (trackContainer.TrackId.HasValue && album == null) { throw new InvalidOperationException($"Album not found by id {trackContainer.TrackId}"); } }
/// <summary> /// Replaces the queue by a track container. /// </summary> /// <param name="trackContainer">The track container to add.</param> /// <param name="shuffle">Whether to shuffle the tracks when adding.</param> /// <param name="play">Whether to immediately start playing.</param> public void ReplaceAll(ITrackContainer trackContainer, bool shuffle, bool play) { Contract.Requires <ArgumentNullException>(trackContainer != null); Contract.Requires <ArgumentException>(trackContainer.TrackList.Count > 0); Stop(); MutateQueue(() => _queue.ReplaceAllWithTrackContainer(trackContainer, shuffle)); if (play) { Play(); } }
/// <summary> /// Adds the sound files in a random order /// </summary> /// <param name="tracks">The track container that will hold the new track</param> /// <param name="soundFiles">The list of sound files to add</param> /// <param name="duration"></param> /// <returns>The new track</returns> private ITrack AddBackgroundMusic(ITrackContainer tracks, IList <string> soundFiles, double duration) { var audioTrack = tracks.AddTrack(); if (soundFiles.Any()) { var shuffled = shuffler.Shuffle(soundFiles); foreach (var soundFile in shuffled) { audioTrack.AddAudio(soundFile, 0, duration); } audioTrack.AddEffect(0, audioTrack.Duration, StandardEffects.CreateAudioEnvelope(0.05)); } return(audioTrack); }
private void AddWatermark(ITrackContainer tracks, string watermarkFile, double duration, int width, int height) { using (var img = Image.FromFile(watermarkFile)) { var watermarkImage = new Bitmap(width, height); using (var g = Graphics.FromImage(watermarkImage)) { g.Clear(Color.Transparent); g.DrawImage(img, 0, height - height / 5, width, height / 5); g.Save(); var imageFileName = Path.Combine(workArea, "wm.gif"); watermarkImage.Save(imageFileName, ImageFormat.Gif); CreateWatermark(tracks, imageFileName, duration); } } }
/// <summary> /// Replaces the entire track queue with a single song, queuing up the other items in the same track container. /// You should check the UserMutatedQueue property before performing a destructive replacement. /// </summary> /// <param name="t">The song.</param> /// <param name="a">The track container that holds the song.</param> public void ReplaceAllWithSong(Track t, ITrackContainer a) { Contract.Requires(t != null); Contract.Requires(a != null); Contract.Requires(a.TrackList != null); Contract.Requires(a.TrackList.Count != 0); _trackList.BatchChanges(); Clear(); var items = a.TrackList.AsParallel().AsOrdered().Select(x => x.UniqueTrack()); _trackList.Enqueue(items); int trackOffset = Math.Max(0, a.IndexOf(t)); _trackList.Dequeue(trackOffset); _trackList.FlushChanges(); }
/// <summary> /// Replaces the entire track queue with a single song, queuing up the other items in the same track container. /// You should check the UserMutatedQueue property before performing a destructive replacement. /// </summary> /// <param name="t">The song.</param> /// <param name="a">The track container that holds the song.</param> public void ReplaceAllWithSong(Track t, ITrackContainer a) { Contract.Requires(t != null); Contract.Requires(a != null); Contract.Requires(a.TrackList != null); Contract.Requires(a.TrackList.Count != 0); _trackList.BatchChanges(); Clear(); var items = a.TrackList.AsParallel().AsOrdered().Select(x => x.UniqueTrack()); _trackList.Enqueue(items); int trackOffset = Math.Max(0, a.IndexOf(t)); _trackList.Dequeue(trackOffset); _trackList.FlushChanges(); }
private Task <Track> GetBy(ITrackContainer departmentContainer) { return(this.TrackDataAccess.GetByAsync(departmentContainer)); }
public async Task <Track> GetByAsync(ITrackContainer track) { return(track.TrackId.HasValue ? this.Mapper.Map <Track>(await this.Context.Track.FirstOrDefaultAsync(x => x.Id == track.TrackId)) : null); }
/// <summary> /// Like OnNavigatedTo(), but runs after the whole UI has already been prepared. /// Place any loading code here that requires the UI to be completely loaded. /// </summary> private async void page_Loaded(object sender, RoutedEventArgs e) { // Initialize the controller if necessary if (AudioController.Default.Status == AudioControllerStatus.NotReady) { DependencyObject rootGrid = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(Window.Current.Content, 0); MediaElement rootMediaElement = (MediaElement)Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(rootGrid, 0); AudioController.Default.Ready(rootMediaElement); } // Initialize animations VisualStateManager.GoToState(this, "NoOverlayAlbum", false); VisualStateManager.GoToState(this, "NoOverlayQueue", false); VisualStateManager.GoToState(this, "NoOverlayMessage", false); Type pageMode = typeof(Album); double scroll = 0d; ITrackContainer navigationContainer = null; Track navigationItem = null; if (_navigationParameter.HasValue && LibraryItemToken.VerifyToken(_navigationParameter.Value)) { var navigationParameter = LibraryItemToken.GetItem(_navigationParameter.Value); // If there is a navigationParameter, use it, and ignore the pageState! if (navigationParameter is Album) { pageMode = typeof(Album); navigationContainer = navigationParameter as ITrackContainer; } else if (navigationParameter is Playlist) { pageMode = typeof(Playlist); navigationContainer = navigationParameter as ITrackContainer; } else if (navigationParameter is Track) { pageMode = typeof(Album); navigationItem = navigationParameter as Track; if (navigationItem != null) { navigationContainer = navigationItem.ContainingAlbum; } } } else if (_pageState != null) { // If no navigationParameter but pageState available, modify UI according to pageState if (_pageState.ContainsKey("PageMode")) { pageMode = Type.GetType((string)_pageState["PageMode"]); } if (_pageState.ContainsKey("AlbumScroll")) { scroll = (double)_pageState["AlbumScroll"]; } } PageMode = pageMode; _pageState = null; _navigationParameter = null; if (navigationContainer != null) { IsAlbumOverlayShown = true; // Delay scrolling after animation await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { CurrentSelection = navigationContainer; albumGridView.ScrollIntoView(CurrentSelection); if (navigationItem != null) { albumDetailListView.SelectedIndex = navigationContainer.IndexOf(navigationItem); albumDetailListView.ScrollIntoView(albumDetailListView.SelectedItem); } }); } else if (scroll > double.Epsilon) // Don't scroll if scroll is negative or less than Epsilon { // Delay scrolling after animation await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { FindVisualChild <ScrollViewer>(albumGridView).ScrollToHorizontalOffset(scroll); }); } }
/// <summary> /// Replaces the entire track queue with the contents of a track container. You should check the UserMutatedQueue property before performing a destructive replacement. /// </summary> /// <param name="a">The track container.</param> /// <param name="shuffle">Whether to shuffle the order in which the track container is added.</param> public void ReplaceAllWithTrackContainer(ITrackContainer a, bool shuffle) { Contract.Requires(a != null); Contract.Requires(a.TrackList != null); Contract.Requires(a.TrackList.Count != 0); _trackList.BatchChanges(); Clear(); if (shuffle) { var items = a.TrackList.AsParallel().Select(x => x.UniqueTrack()).OrderBy(x => x.UniqueId); _trackList.Enqueue(items); _trackList.Dequeue(); } else { var items = a.TrackList.AsParallel().AsOrdered().Select(x => x.UniqueTrack()); _trackList.Enqueue(items); _trackList.Dequeue(); } _trackList.FlushChanges(); }
/// <summary> /// Replaces the queue by a single track. /// </summary> /// <param name="t">The track to add.</param> /// <param name="trackContainer">A track container that contains the track <paramref name="t"/>.</param> /// <param name="play">Whether to immediately start playing.</param> public void ReplaceAll(Track t, ITrackContainer trackContainer, bool play) { Contract.Requires<ArgumentException>(t != null); Contract.Requires<ArgumentNullException>(trackContainer != null); Contract.Requires<ArgumentException>(trackContainer.TrackList.Count > 0); Stop(); MutateQueue(() => _queue.ReplaceAllWithSong(t, trackContainer)); if (play) Play(); }
/// <summary> /// Adds a track container to the queue. /// </summary> /// <param name="trackContainer">The track container to add.</param> /// <param name="play">Whether to immediately start playing.</param> public void Add(ITrackContainer trackContainer, bool play) { MutateQueue(() => _queue.Add(trackContainer.TrackList)); if (Status == AudioControllerStatus.Inactive && play) Play(); }