コード例 #1
0
        private void ShowSelectedPanel(int p)
        {
            switch (p)
            {
            case 1:
                VideoSource.Stop();
                MusicSource.Stop();

                MusicBox.Visibility    = Visibility.Collapsed;
                PhotoSource.Visibility = Visibility.Visible;
                VideoBox.Visibility    = Visibility.Collapsed;
                break;

            case 2:
                VideoSource.Stop();

                MusicBox.Visibility    = Visibility.Visible;
                PhotoSource.Visibility = Visibility.Collapsed;
                VideoBox.Visibility    = Visibility.Collapsed;

                MusicSource.Play();
                break;

            case 3:
                MusicSource.Stop();
                MusicBox.Visibility    = Visibility.Collapsed;
                PhotoSource.Visibility = Visibility.Collapsed;
                VideoBox.Visibility    = Visibility.Visible;

                VideoSource.Play();
                break;
            }
        }
コード例 #2
0
 void Update()
 {
     if (Input.GetKeyDown(Keycode.Space))
     {
         MusicSource.Play();
     }
 }
コード例 #3
0
 private void OnEnable()
 {
     if (Manager <MusicManager> .instance == null)
     {
         Manager <MusicManager> .instance = this;
         AudioSource[] components = GetComponents <AudioSource>();
         menuSource = new MusicSource
         {
             source = components[0],
             volume = components[0].volume
         };
         gameSource = new MusicSource
         {
             source = components[1],
             volume = components[1].volume
         };
         menuSource.source.volume = 0f;
         menuSource.source.Stop();
         gameSource.source.volume = 0f;
         gameSource.source.Stop();
     }
     else
     {
         UnityEngine.Object.Destroy(base.gameObject);
     }
 }
コード例 #4
0
 async void receiver_SourceChangeRequested(PlayToReceiver sender, SourceChangeRequestedEventArgs args)
 {
     if (args.Stream != null)
     {
         if (args.Stream.ContentType.Contains("image"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 BitmapImage bmp = new BitmapImage();
                 bmp.SetSource(args.Stream);
                 PhotoSource.Source = bmp;
                 ShowSelectedPanel(1);
             });
         }
         else if (args.Stream.ContentType.Contains("video"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 VideoSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(3);
             });
         }
         else if (args.Stream.ContentType.Contains("audio"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 MusicSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(2);
                 MusicSource.Play();
             });
         }
     }
 }
コード例 #5
0
    public IEnumerator setMusicVolume()
    {
        MusicSource bgMusic = gamemanager.getBGMusic();

        if (fadetime == 0)
        {
            bgMusic.realVolume = volume;
        }
        else
        {
            float time = 0;
            float step = (bgMusic.realVolume - volume) / (fadetime / Time.deltaTime);

            while (time < fadetime)
            {
                bgMusic.realVolume = bgMusic.realVolume - step;

                time += Time.deltaTime;
                //time += Time.deltaTime / (fadetime * 100);
                yield return(null);
            }
        }

        bgMusic.realVolume = volume;
        finished           = true;

        if (oneuse)
        {
            Destroy(gameObject);
        }
    }
コード例 #6
0
 void PlayItem(MusicModel item)
 {
     CurrentPlayIndex = MusicSource.IndexOf(item);
     currentName.Text = "当前正在播放歌曲:" + item.Name;
     if (audioPlayer.GetPalyState())
     {
         audioPlayer.Stop();
     }
     audioPlayer.PlayNet(item.Url);
     audioPlayer.Completed += (sender, e) =>
     {
         playImage.Source = new FileImageSource()
         {
             File = "play.png"
         };
         PlayState        = -1;
         CurrentPlayIndex = -1;
         currentName.Text = "当前无正在播放歌曲";
     };
     playImage.Source = new FileImageSource()
     {
         File = "pause.png"
     };
     PlayState      = 1;
     totalTime.Text = $"{ audioPlayer.GetTotalDuration() / 60:d2}:{audioPlayer.GetTotalDuration() % 60:d2}";
     Device.StartTimer(new TimeSpan(1000), () =>
     {
         progress.Progress = audioPlayer.GetCurrentDuration() * 1.0f / audioPlayer.GetTotalDuration();
         currentTime.Text  = $"{audioPlayer.GetCurrentDuration() / 60:d2}:{audioPlayer.GetCurrentDuration() % 60:d2}";
         return(audioPlayer.GetPalyState());
     });
 }
コード例 #7
0
 public static IMusic[] SearchMusic(MusicSource type, string content)
 {
     try
     {
         if (type == MusicSource.Netease)
         {
             string         url    = "http://blog.ylz1.cn/page/music/api.php";
             byte[]         commit = Encoding.UTF8.GetBytes($"types=search&count=10&source=netease&pages=1&name={content}");
             byte[]         data   = HttpWebClient.Post(url, commit);
             NeteaseMusic[] infos  = JsonConvert.DeserializeObject <NeteaseMusic[]>(Encoding.UTF8.GetString(data));
             return(infos);
         }
         else if (type == MusicSource.Kugou)
         {
             string       url    = "http://blog.ylz1.cn/page/music/api.php";
             byte[]       commit = Encoding.UTF8.GetBytes($"types=search&count=10&source=kugou&pages=1&name={content}");
             byte[]       data   = HttpWebClient.Post(url, commit);
             KugouMusic[] infos  = JsonConvert.DeserializeObject <KugouMusic[]>(Encoding.UTF8.GetString(data));
             return(infos);
         }
         else
         {
             string         url   = $"https://api.qq.jsososo.com/search?key={content}&pageNo=1&pageSize=10";
             byte[]         data  = HttpWebClient.Get(url);
             TencentMusic[] infos = JsonConvert.DeserializeObject <TencentMusic[]>(JObject.Parse(Encoding.UTF8.GetString(data))?["data"]?["list"].ToString());
             return(infos);
         }
     }
     catch (Exception)
     {
         return(new IMusic[0]);
     }
 }
コード例 #8
0
 public void DonePlayingMusicTemporarly()
 {
     TempSource.clip = null;
     TempSource.Stop();
     //Theres no "Check if paused.", so I can't enforce that.
     //Todo: Write a extension method that keeps track of stuff like this.
     MusicSource.UnPause();
 }
コード例 #9
0
 public static void FadeOut(MusicSource source, float time, bool stop)
 {
     if (source.fadeRoutine != null)
     {
         Manager <MusicManager> .instance.targetSource.source.volume = Manager <MusicManager> .instance.targetFromVolume;
         Manager <MusicManager> .instance.StopCoroutine(source.fadeRoutine);
     }
     source.fadeRoutine = Manager <MusicManager> .instance.StartCoroutine(FadeRoutine(source, source.volume, 0f, time, stop));
 }
コード例 #10
0
 async void receiver_PlayRequested(PlayToReceiver sender, object args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
     {
         MusicSource.Play();
         VideoSource.Play();
         receiver.NotifyPlaying();
     });
 }
コード例 #11
0
    public AudioController(GameObject owner)
    {
        this.owner = owner;

        music  = new MusicSource(owner);
        effect = new EffectSource(owner);

        serverController = owner.GetComponent <ServerController>();
    }
コード例 #12
0
ファイル: Source.cs プロジェクト: WindsChaser/test
 public Source(int ID)
 {
     SourceID = ID;
     mapsource = new MapSource(SourceID);
     personsource1 = new PersonSource(0);
     personsource2 = new PersonSource(1);
     bombsource = new BombSource(SourceID);
     musicsource = new MusicSource(SourceID);
 }
コード例 #13
0
 public Source(int ID)
 {
     SourceID      = ID;
     mapsource     = new MapSource(SourceID);
     personsource1 = new PersonSource(0);
     personsource2 = new PersonSource(1);
     bombsource    = new BombSource(SourceID);
     musicsource   = new MusicSource(SourceID);
 }
コード例 #14
0
 public static void FadeIn(MusicSource source, float time)
 {
     if (source.fadeRoutine != null)
     {
         Manager <MusicManager> .instance.targetSource.source.volume = Manager <MusicManager> .instance.targetToVolume;
         Manager <MusicManager> .instance.StopCoroutine(source.fadeRoutine);
     }
     source.source.Play();
     source.fadeRoutine = Manager <MusicManager> .instance.StartCoroutine(FadeRoutine(source, 0f, source.volume, time, stop : false));
 }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        MusicSource source = (MusicSource)target;

        if (GUILayout.Button("Test Play"))
        {
            source.PlayORStop();
        }
    }
コード例 #16
0
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);
    }
コード例 #17
0
    /// <summary>
    /// Plays a music clip.
    /// </summary>
    /// <param name="music">The music to play.</param>
    /// <param name="volume">The relative volume to play the clip at.</param>
    /// <param name="replayIfSame">If true, will play the clip even if it's the same music is currently being played.</param>
    public void PlayMusic(AudioClip music, float volume = 1f, bool replayIfSame = false)
    {
        if (replayIfSame == false && MusicSource.clip == music && MusicSource.isPlaying == true)
        {
            return;
        }

        MusicSource.clip = music;
        //Multiply this volume by the global music volume to get a relative volume
        MusicSource.volume = volume * musicVolume;
        MusicSource.Play();
    }
コード例 #18
0
 // Use this for initialization
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
コード例 #19
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
 }
コード例 #20
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #21
0
 void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     if (e.SelectedItem != null)
     {
         (sender as ListView).SelectedItem = null;
         var model = e.SelectedItem as MusicModel;
         if (MusicSource.IndexOf(model) == CurrentPlayIndex)
         {
             return;
         }
         model.State = 1;
         PlayItem(model);
     }
 }
コード例 #22
0
ファイル: AudioManager.cs プロジェクト: Jrns1/bullet-hell
    private IEnumerator FadeOutCo(MusicSource sound, float time)
    {
        float t = time;
        float originalVolume = sound.volume;

        while (t > 0)
        {
            sound.CurrentVolume = originalVolume * t / time;
            t -= Time.deltaTime;
            yield return(null);
        }

        sound.Stop();
    }
コード例 #23
0
ファイル: AudioManager.cs プロジェクト: Jrns1/bullet-hell
    private IEnumerator FadeInCo(MusicSource sound, float time)
    {
        float t = 0;
        float originalVolume = sound.volume;

        while (t < time)
        {
            sound.CurrentVolume = originalVolume * t / time;
            t += Time.deltaTime;
            yield return(null);
        }

        sound.CurrentVolume = originalVolume;
    }
コード例 #24
0
    public void playBGMusic(float playvolume)
    {
        if (bgmusic != newbgmusic)
        {
            bgmusic.Stop();
            bgmusic = newbgmusic;
        }

        playercontroller.setBGMusic(bgmusic.audio);

        //bgmusic.volume = playvolume * music_volume;
        bgmusic.realVolume   = playvolume;
        bgmusic.audio.volume = bgmusic.realVolume * music_volume;
        bgmusic.Play();
    }
コード例 #25
0
    void OnTriggerEnter2D(Collider2D collidedObject)
    {
        if (collidedObject.tag == "Player")
        {
            collidedObject.SendMessage("hitDeathTrigger");
            player.resetStatus();

            if (MusicSource.MUSIC_OBJECT == null)
            {
                MusicSource.buscarObjetoMusica(); //BUSCO EL OBJETO QUE CONTIENE LA MUSICA DE FONDO
            }

            new ControlMusica(MusicSource.MUSIC_OBJECT).pararMusica(); //PARO LA MUSICA
            GetComponent <AudioSource>().Play();
        }
    }
コード例 #26
0
ファイル: GameManager.cs プロジェクト: tesh144/tesh-samuel
    // Use this for initialization
    void Awake()
    {
        //SetValues();
        MusicSource ms = FindObjectOfType <MusicSource>();

        if (ms != null)
        {
            music = ms.audioS; specialMeter.AS = music; gameOverScreen.Music = music;
        }
        dpManager.gameObject.SetActive(false);
        gameOverScreen.gameObject.SetActive(false); scoreMultiplied.SetActive(false);

        ChangeChar();
        CollectChildren();
        Target = cells[(int)(Dino.transform.position.x) / 2, (int)(Dino.transform.position.z) / 2].transform;
        Dino.transform.position = Target.transform.position;
    }
コード例 #27
0
 private static IEnumerator FadeRoutine(MusicSource source, float fromVolume, float toVolume, float totalTime, bool stop)
 {
     Manager <MusicManager> .instance.targetSource     = source;
     Manager <MusicManager> .instance.targetFromVolume = fromVolume;
     Manager <MusicManager> .instance.targetToVolume   = toVolume;
     for (float time = 0f; time < totalTime; time += Time.unscaledDeltaTime)
     {
         source.source.volume = Mathf.Lerp(fromVolume, toVolume, time / totalTime);
         yield return(new WaitForEndOfFrame());
     }
     source.source.volume = toVolume;
     if (stop)
     {
         Stop(source);
     }
     source.fadeRoutine = null;
 }
コード例 #28
0
    public void PlayMusicTemporarly(AudioClip music, float atVolume)
    {
        //Don't interupt the music.
        MusicSource.Pause();
        TempSource.clip = music;

        //Enforce volume standards.
        if (!(0 >= atVolume && 1 <= atVolume))
        {
            Debug.LogWarning("Recieved volume is not within the acceptable volume ranges. Clamping it..", gameObject);
        }

        atVolume = Mathf.Clamp(atVolume, 0, 1);

        TempSource.volume = atVolume;
        TempSource.Play();
    }
コード例 #29
0
    private IEnumerator resurrecion()
    {
        yield return(new WaitForSeconds(resurrect_time));

        transform.position = playerRespawnPoint.transform.position; //posicio: la de PlayerRespawnPoint
        transform.rotation = Quaternion.identity;                   //rotacio: cap
        GetComponent <Rigidbody2D>().velocity = Vector2.zero;       //velocitat lineal: zero

        //GESTIONO QUE LA MUSICA VUELVA A SONAR
        if (MusicSource.MUSIC_OBJECT == null)
        {
            MusicSource.buscarObjetoMusica();                     //BUSCO EL OBJETO QUE CONTIENE LA MUSICA DE FONDO
        }
        new ControlMusica(MusicSource.MUSIC_OBJECT).playMusica(); //REANUDO LA MUSICA

        PlayerStateController.muerto = false;
        Jump.plataformaTocada        = true;
        playerWalkSpeed = playerSpeedAuxiliar;
    }
コード例 #30
0
    public void PlayMusic(AudioClip music, float atVolume)
    {
        if (MusicSource.isPlaying)
        {
            MusicSource.Stop();
        }

        //Enforce volume standards.
        if (!(0 >= atVolume && 1 <= atVolume))
        {
            Debug.LogWarning("Recieved volume is not within the acceptable volume ranges. Clamping it..", gameObject);
        }

        atVolume = Mathf.Clamp(atVolume, 0, 1);

        MusicSource.volume = atVolume;
        MusicSource.clip   = music;
        MusicSource.Play();
    }
コード例 #31
0
ファイル: SoundManager.cs プロジェクト: nova666/I-HERO
    public static void PlaySFX(string TypeOfSound, Transform position)
    {
        AudioSource MusicSource;

        MusicSource = Instantiate(prefabAudioSource, position.position, Quaternion.identity);

        if (TypeOfSound == "Spawn")
        {
            MusicSource.clip = SoundVFX[0];
            MusicSource.Play();
        }
        if (TypeOfSound == "Shoot")
        {
            MusicSource.clip   = SoundVFX[1];
            MusicSource.volume = 0.1f;
            MusicSource.Play();
        }
        if (TypeOfSound == "Die")
        {
            MusicSource.clip = SoundVFX[2];
            MusicSource.Play();
        }
        if (TypeOfSound == "SpawnCry")
        {
            MusicSource.clip = SoundVFX[3];
            MusicSource.Play();
        }
        if (TypeOfSound == "Step")
        {
            MusicSource.clip = SoundVFX[4];
            MusicSource.Play();
        }
        if (TypeOfSound == "Despawn")
        {
            MusicSource.clip = SoundVFX[5];
            MusicSource.Play();
        }
        if (TypeOfSound == "Item")
        {
            MusicSource.clip = SoundVFX[6];
            MusicSource.Play();
        }
    }