Example #1
0
 public AudioEvent(
     AudioEventConfiguration configuration,
     IAudioHub audioHub,
     IAudioPlayer audioPlayer
     )
 {
     Configuration = configuration;
     AudioHub      = audioHub;
     AudioPlayer   = audioPlayer;
 }
Example #2
0
        public PlaylistPlayback(IAudioHub audioHub, IPlaybackInfoProvider playbackInfoProvider, IList <ITrackInfo> tracks = null)
        {
            _audioHub             = audioHub;
            _playbackInfoProvider = playbackInfoProvider;

            Id     = Guid.NewGuid().ToString();
            Tracks = tracks ?? new List <ITrackInfo>();
            OutgoingConnections = new HashSet <IOutputAudioDevice>();

            Task.Factory.StartNew(FillPlaybackInfos, TaskCreationOptions.LongRunning);
        }
Example #3
0
        /// <summary>
        /// Creates new thread with playing audio file
        /// </summary>
        /// <returns></returns>
        public static Task Play(this IAudioHub audioHub, Uri uri)
        {
            var playback = audioHub.CreatePlayback(uri);

            //if (playback.Duration.HasValue)
            //    throw new Exception();

            playback.AddOutgoingConnections(audioHub.Devices.OfType <IOutputAudioDevice>());
            playback.Play();

            var taskCompletionSource = new TaskCompletionSource <object>();

            playback.Ended += (sender, args) =>
            {
                taskCompletionSource.SetResult(null);

                var disposable = playback as IDisposable;
                disposable?.Dispose();
            };

            return(taskCompletionSource.Task);
        }
Example #4
0
 public static IOutputAudioDevice[] DefaultOutputs(this IAudioHub audioHub)
 {
     // mow all inputs is default, because there is no default flag in API
     return(audioHub.Outputs());
 }
Example #5
0
 public static IOutputAudioDevice[] Outputs(this IAudioHub audioHub)
 {
     return(audioHub.Devices
            .OfType <IOutputAudioDevice>()
            .ToArray());
 }
Example #6
0
 public PlaylistPlayback(IAudioHub audioHub, IPlaybackInfoProvider playbackInfoProvider, IList <Uri> tracks)
     : this(audioHub, playbackInfoProvider, tracks.ToTrackInfos())
 {
 }
 public AudioPlayer(IAudioHub audioHub)
 {
     AudioHub  = audioHub;
     Playbacks = new List <IPlayback>();
 }