Exemple #1
0
 public static void Init()
 {
     Inbound       = new List <VoicePlayerInboundItem>();
     PlaybackQueue = new List <VoicePlayerItem>();
     Records       = new List <VoicePlayerItem>();
     State         = VoicePlayerState.Available;
 }
    private void DissonanceComms_OnPlayerJoinedSession(VoicePlayerState player)
    {
        Debug.Log("Player " + player.Name + " Joined session");


        //get all networkplayer
        NetworkPlayer[] networkPlayers = FindObjectsOfType(typeof(NetworkPlayer)) as NetworkPlayer[];
        foreach (var networkplayer in networkPlayers)
        {
            var playerId = networkplayer.gameObject.GetComponent <BeamLiteHlapiPlayer>().PlayerId;
            if (player.Name == playerId)
            {
                player.OnStartedSpeaking += networkplayer.Avatar.GetComponent <AvatarController>().Player_OnStartedSpeaking;
                player.OnStoppedSpeaking += networkplayer.Avatar.GetComponent <AvatarController>().Player_OnStoppedSpeaking;
                break;
            }
        }
        if (Utils.CurrentPlayerType == Utils.PlayerType.HoloLens)
        {
            if (player.Name != DissonanceComms.LocalPlayerName)
            {
                foreach (var networkplayer in networkPlayers)
                {
                    var playerId = networkplayer.gameObject.GetComponent <BeamLiteHlapiPlayer>().PlayerId;
                    if (player.Name == playerId && networkplayer.PlayerType == Utils.PlayerType.HoloLens)
                    {
                        player.IsLocallyMuted = true;
                    }
                }
            }
        }
    }
    private void Start()
    {
        _comms  = FindObjectOfType <DissonanceComms>();
        _player = _comms.FindPlayer(_comms.LocalPlayerName);

        // ReSharper disable once PossibleNullReferenceException
        NameText.text = _player.Name.MeaninglessString();
    }
        private IEnumerator FindPlayerState()
        {
            //Wait until player tracking has initialized
            while (!_player.IsTracking)
            {
                yield return(null);
            }

            //Now ask Dissonance for the object which represents the state of this player
            //The loop is necessary in case Dissonance is still initializing this player into the network session
            while (_state == null)
            {
                _state = FindObjectOfType <DissonanceComms>().FindPlayer(_player.PlayerId);
                yield return(null);
            }
        }
Exemple #5
0
        public static void Tick(Form1 form)
        {
            if (State == VoicePlayerState.Available)
            {
                VoicePlayerItem item = null;

                lock (padlock)
                    if (PlaybackQueue.Count > 0)
                    {
                        item = PlaybackQueue[0];
                        PlaybackQueue.RemoveAt(0);
                    }

                if (item != null)
                {
                    String path    = Path.Combine(Settings.VoicePath, item.FileName + ".wav");
                    int    success = 0;
                    mciSendString("open \"" + path + "\" type mpegvideo alias " + PLAYBACK_DEVICE_NAME, null, 0, IntPtr.Zero);
                    success = mciSendString("set " + PLAYBACK_DEVICE_NAME + " output " + AudioHelpers.GetPlaybackIdent(), null, 0, IntPtr.Zero);
                    success = mciSendString("play " + PLAYBACK_DEVICE_NAME + " notify", null, 0, form.Handle);

                    if (success == 0)
                    {
                        State = VoicePlayerState.Busy;

                        if (item.Auto)
                        {
                            Room room = RoomPool.Rooms.Find(x => x.EndPoint.Equals(item.EndPoint));

                            if (room != null)
                            {
                                room.Panel.ShowVoice(item.Sender, item.ShortCut);
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        private void PlayerGui([NotNull] VoicePlayerState p)
        {
            var message = string.Format("{0} {1} {2} {3}",
                                        p.Name,
                                        p.IsSpeaking ? "(speaking)" : "",
                                        !p.IsConnected ? "(disconnected)" : "",
                                        p.Tracker != null && p.Tracker.IsTracking ? "(positional)" : ""
                                        );

            using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
            {
                bool showListeningRooms;
                bool showSpeakingChannels;

                EditorGUILayout.LabelField(message);
                using (new EditorGUILayout.HorizontalScope())
                {
                    p.IsLocallyMuted = GUILayout.Toggle(p.IsLocallyMuted, new GUIContent("Mute", "Prevent this player from being heard locally"));

                    showListeningRooms = GUILayout.Toggle(_showRoomMembership.Contains(p.Name), new GUIContent("Show Rooms", "Show the set of rooms this player is listening to"));
                    if (showListeningRooms)
                    {
                        _showRoomMembership.Add(p.Name);
                    }
                    else
                    {
                        _showRoomMembership.Remove(p.Name);
                    }

                    showSpeakingChannels = GUILayout.Toggle(_showSpeakingChannels.Contains(p.Name), new GUIContent("Show Channels", "Show the set of channels this player is speaking to the local player through"));
                    if (showSpeakingChannels)
                    {
                        _showSpeakingChannels.Add(p.Name);
                    }
                    else
                    {
                        _showSpeakingChannels.Remove(p.Name);
                    }
                }

                if (showListeningRooms)
                {
                    using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                    {
                        EditorGUILayout.LabelField("Listening To:");
                        foreach (var room in p.Rooms)
                        {
                            EditorGUILayout.LabelField(" - " + room);
                        }
                    }
                }

                if (showSpeakingChannels)
                {
                    using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                    {
                        var l = new List <RemoteChannel>();
                        p.GetSpeakingChannels(l);

                        EditorGUILayout.LabelField("Speaking Through:");
                        foreach (var channel in l.OrderByDescending(a => a.Type))
                        {
                            EditorGUILayout.LabelField(string.Format(" - {0}: {1}", channel.Type, channel.TargetName));
                        }
                    }
                }
            }
        }
Exemple #7
0
 public void Player_OnStartedSpeaking(VoicePlayerState obj)
 {
     TextFieldForPlayerName.color = SpeakingColor;
 }
Exemple #8
0
    private void PlayerJoined(VoicePlayerState player)
    {
        var monitor = Instantiate(PlayerMonitorPrefab, PlayerContainer);

        monitor.PlayerState = player;
    }
Exemple #9
0
 public static void PlaybackCompleted()
 {
     mciSendString("stop " + PLAYBACK_DEVICE_NAME, null, 0, IntPtr.Zero);
     mciSendString("close " + PLAYBACK_DEVICE_NAME, null, 0, IntPtr.Zero);
     State = VoicePlayerState.Available;
 }
 private void DissonanceComms_OnPlayerLeftSession(VoicePlayerState player)
 {
     Debug.Log("Player " + player.Name + " Left session");
 }
Exemple #11
0
 private void StartedSpeaking(VoicePlayerState obj)
 {
     SpeakingIndicator.gameObject.SetActive(true);
 }
Exemple #12
0
 private void StoppedSpeaking(VoicePlayerState obj)
 {
     SpeakingIndicator.gameObject.SetActive(false);
 }
Exemple #13
0
 private void LeftSession(VoicePlayerState obj)
 {
     Destroy(gameObject);
 }