コード例 #1
0
 public SignInService(IOpenSynoSettings openSynoSettings, IEventAggregator eventAggregator, INotificationService notificationService, ILogService logService, IVersionDependentResourcesProvider versionDependentResourcesProvider)
 {
     _openSynoSettings    = openSynoSettings;
     _eventAggregator     = eventAggregator;
     _notificationService = notificationService;
     _logService          = logService;
     _versionDependentResourcesProvider = versionDependentResourcesProvider;
 }
コード例 #2
0
 public AudioStationSession(IVersionDependentResourcesProvider versionDependentResourcesProvider, DsmVersions dsmVersion) : this()
 {
     this.DsmVersion = dsmVersion;
     this.versionDependentResourcesProvider = versionDependentResourcesProvider;
 }
コード例 #3
0
 public AudioStationSession(IVersionDependentResourcesProvider versionDependentResourcesProvider, DsmVersions dsmVersion)
     : this()
 {
     this.DsmVersion = dsmVersion;
     this.versionDependentResourcesProvider = versionDependentResourcesProvider;
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaybackService"/> class.
        /// </summary>
        /// <param name="audioStationSession"></param>
        /// <param name="audioTrackFactory"></param>
        public PlaybackService(IAudioStationSession audioStationSession, IAudioTrackFactory audioTrackFactory, IVersionDependentResourcesProvider versionDependentResourceProvider)
        {
            _logService = IoC.Container.Get <ILogService>();

            _audioStationSession = audioStationSession;
            _audioTrackFactory   = audioTrackFactory;
            _versionDependentResourceProvider = versionDependentResourceProvider;

            // We need an observable collection so we can serialize the items to IsolatedStorage in order to get the background rendering service to read it from disk, since the background Agent is not running in the same process.
            //PlayqueueItems = new ObservableCollection<ISynoTrack>();

            this._tracksToGuidMapping = new List <GuidToTrackMapping>();

            using (var userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (
                    IsolatedStorageFileStream asciiUriFixes = userStoreForApplication.OpenFile(
                        "AsciiUriFixes.xml", FileMode.OpenOrCreate))
                {
                    DataContractSerializer dcs = new DataContractSerializer(typeof(List <AsciiUriFix>));
                    //var xs = new XmlSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));

                    try
                    {
                        _asciiUriFixes = (List <AsciiUriFix>)dcs.ReadObject(asciiUriFixes);
                    }
                    catch (Exception e)
                    {
                        // could not deserialize XML for playlist : let's build an empty list.
                        _asciiUriFixes = new List <AsciiUriFix>();
                    }
                }

                PlayqueueInterProcessCommunicationTransporter deserialization = null;
                using (
                    IsolatedStorageFileStream playQueueFile = userStoreForApplication.OpenFile(
                        "playqueue.xml", FileMode.OpenOrCreate))
                {
                    DataContractSerializer dcs =
                        new DataContractSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));
                    //var xs = new XmlSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));

                    try
                    {
                        deserialization = (PlayqueueInterProcessCommunicationTransporter)dcs.ReadObject(playQueueFile);

                        foreach (GuidToTrackMapping pair in deserialization.Mappings)
                        {
                            this._tracksToGuidMapping.Add(pair);
                        }
                    }
                    catch (Exception e)
                    {
                        // could not deserialize XML for playlist : let's keep it empty.
                    }
                }
            }


            //this.PlayqueueItems.CollectionChanged += this.OnPlayqueueItemsChanged;

            BackgroundAudioPlayer.Instance.PlayStateChanged += new EventHandler(this.BackgroundPlayerPlayStateChanged);

            this._progressUpdater = new Timer(
                e =>
            {
                var backgroundAudioPlayer = BackgroundAudioPlayer.Instance;
                if (this.TrackCurrentPositionChanged != null && backgroundAudioPlayer.Track != null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        TrackCurrentPositionChangedEventArgs trackCurrentPositionChangedEventArgs = new TrackCurrentPositionChangedEventArgs();

                        trackCurrentPositionChangedEventArgs.LoadPercentComplete = backgroundAudioPlayer.BufferingProgress;
                        double totalSeconds = 0;
                        TimeSpan position   = new TimeSpan();

                        try
                        {
                            position = backgroundAudioPlayer.Position;
                        }
                        catch (SystemException)
                        {
                            _progressUpdater.Change(-1, 0);
                            // swallow exception : we get an HRESULT error, when no valid position could be retrieved. Maybe a beta behavior that will change in the future. since we can ignore the error and set the duration to 0 ( maybe the track hasn't been loaded yet ) we'll just swallow the exception.
                        }

                        try
                        {
                            totalSeconds = backgroundAudioPlayer.Position.TotalSeconds;
                        }
                        catch (SystemException)
                        {
                            // swallow exception : we get an HRESULT error, when no valid duration could be retrieved. Maybe a beta behavior that will change in the future. since we can ignore the error and set the duration to 0 ( maybe the track hasn't been loaded yet ) we'll just swallow the exception.
                        }

                        if (position.TotalSeconds == 0)
                        {
                            // avoid zero-division
                            trackCurrentPositionChangedEventArgs.PlaybackPercentComplete = 0;
                        }
                        else
                        {
                            trackCurrentPositionChangedEventArgs.PlaybackPercentComplete = totalSeconds / backgroundAudioPlayer.Track.Duration.TotalSeconds;
                            trackCurrentPositionChangedEventArgs.Position = position;
                        }

                        this.TrackCurrentPositionChanged(this, trackCurrentPositionChangedEventArgs);
                    });
                }
            },
                null,
                0,
                200);
            //(o, e) =>
            //{
            //    _backgroundAudioRenderingService.OnPlayqueueItemsChanged(e.NewItems, e.OldItems);
            //};
        }
コード例 #5
0
ファイル: AudioTrackFactory.cs プロジェクト: salfab/open-syno
 public AudioTrackFactory(IVersionDependentResourcesProvider versionDependentResourcesProvider)
 {
     this.versionDependentResourcesProvider = versionDependentResourcesProvider;
 }
コード例 #6
0
ファイル: AudioTrackFactory.cs プロジェクト: salfab/open-syno
 public AudioTrackFactory(IVersionDependentResourcesProvider versionDependentResourcesProvider)
 {
     this.versionDependentResourcesProvider = versionDependentResourcesProvider;
 }
コード例 #7
0
ファイル: PlaybackService.cs プロジェクト: salfab/open-syno
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaybackService"/> class.
        /// </summary>
        /// <param name="audioStationSession"></param>
        /// <param name="audioTrackFactory"></param>
        public PlaybackService(IAudioStationSession audioStationSession, IAudioTrackFactory audioTrackFactory, IVersionDependentResourcesProvider versionDependentResourceProvider)
        {
            _logService = IoC.Container.Get<ILogService>();

            _audioStationSession = audioStationSession;
            _audioTrackFactory = audioTrackFactory;
            _versionDependentResourceProvider = versionDependentResourceProvider;

            // We need an observable collection so we can serialize the items to IsolatedStorage in order to get the background rendering service to read it from disk, since the background Agent is not running in the same process.
            //PlayqueueItems = new ObservableCollection<ISynoTrack>();

            this._tracksToGuidMapping = new List<GuidToTrackMapping>();

            using (var userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
            {

                using (
                    IsolatedStorageFileStream asciiUriFixes = userStoreForApplication.OpenFile(
                        "AsciiUriFixes.xml", FileMode.OpenOrCreate))
                {

                    DataContractSerializer dcs = new DataContractSerializer(typeof(List<AsciiUriFix>));
                    //var xs = new XmlSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));

                    try
                    {
                        _asciiUriFixes = (List<AsciiUriFix>)dcs.ReadObject(asciiUriFixes);
                    }
                    catch (Exception e)
                    {
                        // could not deserialize XML for playlist : let's build an empty list.
                        _asciiUriFixes = new List<AsciiUriFix>();
                    }
                }

                PlayqueueInterProcessCommunicationTransporter deserialization = null;
                using (
                    IsolatedStorageFileStream playQueueFile = userStoreForApplication.OpenFile(
                        "playqueue.xml", FileMode.OpenOrCreate))
                {

                    DataContractSerializer dcs =
                        new DataContractSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));
                    //var xs = new XmlSerializer(typeof(PlayqueueInterProcessCommunicationTransporter));

                    try
                    {
                        deserialization = (PlayqueueInterProcessCommunicationTransporter)dcs.ReadObject(playQueueFile);

                        foreach (GuidToTrackMapping pair in deserialization.Mappings)
                        {
                            this._tracksToGuidMapping.Add(pair);
                        }
                    }
                    catch (Exception e)
                    {
                        // could not deserialize XML for playlist : let's keep it empty.

                    }
                }
            }

            //this.PlayqueueItems.CollectionChanged += this.OnPlayqueueItemsChanged;

            BackgroundAudioPlayer.Instance.PlayStateChanged += new EventHandler(this.BackgroundPlayerPlayStateChanged);

            this._progressUpdater = new Timer(
                e =>
                {
                    var backgroundAudioPlayer = BackgroundAudioPlayer.Instance;
                    if (this.TrackCurrentPositionChanged != null && backgroundAudioPlayer.Track != null)
                    {

                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                TrackCurrentPositionChangedEventArgs trackCurrentPositionChangedEventArgs = new TrackCurrentPositionChangedEventArgs();

                                trackCurrentPositionChangedEventArgs.LoadPercentComplete = backgroundAudioPlayer.BufferingProgress;
                                double totalSeconds = 0;
                                TimeSpan position = new TimeSpan();

                                try
                                {
                                    position = backgroundAudioPlayer.Position;
                                }
                                catch (SystemException)
                                {
                                    _progressUpdater.Change(-1, 0);
                                    // swallow exception : we get an HRESULT error, when no valid position could be retrieved. Maybe a beta behavior that will change in the future. since we can ignore the error and set the duration to 0 ( maybe the track hasn't been loaded yet ) we'll just swallow the exception.
                                }

                                try
                                {
                                    totalSeconds = backgroundAudioPlayer.Position.TotalSeconds;
                                }
                                catch (SystemException)
                                {
                                    // swallow exception : we get an HRESULT error, when no valid duration could be retrieved. Maybe a beta behavior that will change in the future. since we can ignore the error and set the duration to 0 ( maybe the track hasn't been loaded yet ) we'll just swallow the exception.
                                }

                                if (position.TotalSeconds == 0)
                                {
                                    // avoid zero-division
                                    trackCurrentPositionChangedEventArgs.PlaybackPercentComplete = 0;
                                }
                                else
                                {
                                    trackCurrentPositionChangedEventArgs.PlaybackPercentComplete = totalSeconds / backgroundAudioPlayer.Track.Duration.TotalSeconds;
                                    trackCurrentPositionChangedEventArgs.Position = position;
                                }

                                this.TrackCurrentPositionChanged(this, trackCurrentPositionChangedEventArgs);
                            });
                    }
                },
                null,
                0,
                200);
            //(o, e) =>
            //{
            //    _backgroundAudioRenderingService.OnPlayqueueItemsChanged(e.NewItems, e.OldItems);
            //};
        }