Exemplo n.º 1
0
        protected override void OnStart()
        {
            _audioWatcher        = new audioWatcher(this.CreateBusAttachment(ref _audioBusAttachment));
            _audioWatcher.Added += this.audioWatcher_Added;
            _audioWatcher.Start();

            _channelWatcher        = new channelWatcher(this.CreateBusAttachment(ref _channelBusAttachment));
            _channelWatcher.Added += this.channelWatcher_Added;
            _channelWatcher.Start();

            _powerSwitchWatcher        = new binaryWatcher(this.CreateBusAttachment(ref _powerSwitchBusAttachment));
            _powerSwitchWatcher.Added += this.powerSwitchWatcher_Added;
            _powerSwitchWatcher.Start();
        }
Exemplo n.º 2
0
        private async void audioWatcher_Added(audioWatcher watcher, AllJoynServiceInfo args)
        {
            if (_audioConsumer == null && args.ObjectPath.Contains(_expectedBusObjectPath))
            {
                var joinResult = await audioConsumer.JoinSessionAsync(args, watcher);

                if (joinResult.Status == AllJoynStatus.Ok)
                {
                    _audioConsumer              = joinResult.Consumer;
                    _audioConsumer.SessionLost += this.Consumer_SessionLost;

                    // subscribe to value changes
                    _audioConsumer.MuteChanged   += this.audioConsumer_MuteChanged;
                    _audioConsumer.VolumeChanged += this.audioConsumer_VolumeChanged;

                    // populate initial values
                    var muteResult = await _audioConsumer.GetMuteAsync();

                    if (muteResult.Status != AllJoynStatus.Ok)
                    {
                        return;
                    }
                    this.Mute = muteResult.Mute;

                    var volumeResult = await _audioConsumer.GetVolumeAsync();

                    if (volumeResult.Status != AllJoynStatus.Ok)
                    {
                        return;
                    }
                    this.Volume = volumeResult.Volume;

                    this.IsConnected = true;
                }
            }
        }