bool GlobalSwitch.IListener.OnSwitch(GlobalSwitch.Switch _switch) { for (int i = 0; i < _componentInstances.Length; i++) { ComponentInstance componentInstance = _componentInstances[i]; if (componentInstance == null) { continue; } GlobalSwitchContainer globalSwitchContainer = GetGlobalSwitchContainer(_switch); if (globalSwitchContainer == null) { continue; } Fabric.Component component = globalSwitchContainer._components[0]; if (!(component != null) || !(component != _selectedComponent)) { continue; } bool isComponentActive = _isComponentActive; if (_selectedComponent != null) { _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f); } _selectedComponent = component; if (_startOnSwitch && isComponentActive && !IsMusicSyncEnabled()) { _componentInstance._instance.ResetPlayScheduled(); _selectedComponent.PlayInternal(_componentInstance, 0f, 0.5f); if (_componentStatus == ComponentStatus.Stopping) { StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve); } } if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSwitch, _selectedComponent); } } return(true); }
public void OnMidiHandler(Fabric.Component component, MidiEvent midiEvent, double offset) { if (component != null) { if (midiEvent.midiChannelEvent == MidiHelper.MidiChannelEvent.Note_On) { _componentInstance._instance.SetPlayScheduled(offset, 0.0); _componentInstance._instance.SetMIDIEvent(midiEvent); component.PlayInternal(_componentInstance, 0f, 0.5f); } else if (midiEvent.midiChannelEvent == MidiHelper.MidiChannelEvent.Note_Off && !_ignoreNoteOff) { component.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, offset); } } }
private bool PlayNextEntry(double offset = 0.0, double scheduledStop = 0.0) { if (_playlist != null && _playlist.Length > 0) { int num = _playlist.Length - 1; if (_playingComponentIndex > num) { if (_sequencePlayMode != SequenceComponentPlayMode.Loop) { return(false); } _playingComponentIndex = 0; if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSequenceEnd, this); } } if (_currentlyPlayingComponent != null && _sequenceType == SequenceComponentType.PlayOnAdvance) { _currentlyPlayingComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, scheduledStop); } _prevPlayingComponentIndex = _playingComponentIndex; _currentlyPlayingComponent = _playlist[_playingComponentIndex++]; if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSequenceNextEntry, _currentlyPlayingComponent); } } if (_currentlyPlayingComponent != null && _componentInstance != null) { _currentlyPlayingComponent.PlayInternal(_componentInstance, 0f, 0.5f); if (_componentStatus == ComponentStatus.Stopping && _onlyStopOnce && _sequenceType != SequenceComponentType.PlayOnAdvance) { StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve); _onlyStopOnce = false; } } return(true); }