示例#1
0
文件: Sounds.cs 项目: Gillium/spyrun
        public Sounds(Song song1, Song song2, Song song3, SoundEffect blimpEngineSound, SoundEffect explosionSound, SoundEffect failedSound,
            Song gameStartSound, SoundEffect playerEngineSound, SoundEffect rewardSound, SoundEffect shotSound)
        {
            level1Music = song1;
            level2Music = song2;
            level3Music = song3;
            MediaPlayer.IsRepeating = true;

            blimpEngineSE = blimpEngineSound;
            blimpEngineSEI = blimpEngineSE.CreateInstance();
            blimpEngineSEI.IsLooped = true;
            blimpEngineSEI.Pitch = 0.0f;
            blimpEngineSEI.Pan = 0.0f;

            missileEngineSE = blimpEngineSound;
            missileEngineSEI = missileEngineSE.CreateInstance();
            missileEngineSEI.IsLooped = true;
            missileEngineSEI.Pitch = 1.0f;
            missileEngineSEI.Pan = 0.0f;

            playerEngineSE = playerEngineSound;
            playerEngineSEI = playerEngineSE.CreateInstance();
            playerEngineSEI.IsLooped = true;
            playerEngineSEI.Pitch = -1.0f;

            explosionSE = explosionSound;
            failedSE = failedSound;
            gameStart = gameStartSound;
            rewardSE = rewardSound;
            shotSE = shotSound;
        }
        /// <summary>
        /// Call this before using the manager.
        /// </summary>
        public void Initialize()
        {
#if MONOGL && WINDOWS
            //mMainMenuMusic = GameObjectManager.pInstance.pContentManager.Load<Song>("Audio\\Music\\MikeImmonen_Menu_Wave");
            //mGameplayMusic = GameObjectManager.pInstance.pContentManager.Load<Song>("Audio\\Music\\MikeImmonen_Gameplay_Wave");
#else
            mMainMenuMusic = GameObjectManager.pInstance.pContentManager.Load<Song>("Audio\\Music\\MikeImmonen_Menu");
            mGameplayMusic = GameObjectManager.pInstance.pContentManager.Load<Song>("Audio\\Music\\MikeImmonen_Gameplay");
#endif

            // All music in the game repeats.
            MediaPlayer.IsRepeating = true;

            mManualMusicDisabled = false;

#if (WINDOWS_PHONE && DEBUG) || (MONOGL && WINDOWS) || (__ANDROID__ && DEBUG)
            mDebugMusicDisabled = true; // We can't pass command line args to WP.
#else
            mDebugMusicDisabled = CommandLineManager.pInstance["DisableMusic"] != null;
#endif

            GameObjectManager.pInstance.RegisterUpdatePassChangeReceiver(this);

            ChangeMusic();
        }
示例#3
0
        /// <summary>
        /// Play a song music
        /// </summary>
        /// <param name="music"></param>
        /// <param name="repeat"></param>
        private void PlayMusic(Song music, bool repeat)
        {
            StopMusic();

            MediaPlayer.IsRepeating = repeat;
            MediaPlayer.Play(music);
        }
        public void LoadContent(ContentManager content)
        {
            this.sounds["FireMissile"] = new List<SoundEffectInstance>();
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot01").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot02").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot03").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot01").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot02").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot03").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot01").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot02").CreateInstance());
            this.sounds["FireMissile"].Add(content.Load<SoundEffect>("Sounds/Gun_NailRifle_Shot03").CreateInstance());

            this.sounds["MissileBounce"] = new List<SoundEffectInstance>();
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce4").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce5").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce6").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce7").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce4").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce5").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce6").CreateInstance());
            this.sounds["MissileBounce"].Add(content.Load<SoundEffect>("Sounds/Grenade_Bounce7").CreateInstance());

            this.sounds["TankDestroyed"] = new List<SoundEffectInstance>();
            this.sounds["TankDestroyed"].Add(content.Load<SoundEffect>("Sounds/Hit_TruckSuspensionImpact1").CreateInstance());
            this.sounds["TankDestroyed"].Add(content.Load<SoundEffect>("Sounds/Hit_TruckSuspensionImpact2").CreateInstance());
            this.sounds["TankDestroyed"].Add(content.Load<SoundEffect>("Sounds/Hit_TruckSuspensionImpact3").CreateInstance());

            this.sounds["PlayerTankDestroyed"] = new List<SoundEffectInstance>();
            this.sounds["PlayerTankDestroyed"].Add(content.Load<SoundEffect>("Sounds/Robot_Death_Powerdown").CreateInstance());

            this.backgroundMusic = content.Load<Song>("Sounds/Chimera-Derivation-3");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = 0.25f;
        }
        public void LoadContent(ContentManager content)
        {
            this.sounds["Click"] = new List<SoundEffectInstance>();
            this.sounds["Click"].Add(content.Load<SoundEffect>("Sounds/Click").CreateInstance());

            this.backgroundMusic = content.Load<Song>("Sounds/BackgroundMusic");
        }
示例#6
0
        public Sound(SuperXbloxGame G)
            : base(G)
        {
            // G.Content.RootDirectory = "Content";
            //mTechno = G.Content.Load<Song>("Songs/tetris");
            RaveParty = G.Content.Load<Song>("Songs/RaveParty");
            TribalTrain = G.Content.Load<Song>("Songs/TribalTrain");
            TechnoRampage = G.Content.Load<Song>("Songs/TechnoRampage!!!");
            //mRock = G.Content.Load<Song>("Songs/tetris2");
            TheFunkyBandit = G.Content.Load<Song>("Songs/TheFunkyBandit");
            mIntro = G.Content.Load<Song>("Songs/RaveParty");
               // sniped=G.Content.Load<SoundEffect>("Sounds/sniped");
            //kaboom = G.Content.Load<SoundEffect>("Sounds/kaboom");
            //scratch = G.Content.Load<SoundEffect>("Sounds/scratch");
            //nextlevel = G.Content.Load<SoundEffect>("Sounds/nextlevel");
            //intro = G.Content.Load<SoundEffect>("Sounds/intro");
            //start = G.Content.Load<SoundEffect>("Sounds/start");
            //stop = G.Content.Load<SoundEffect>("Sounds/stop");
            //rotategrid = G.Content.Load<SoundEffect>("Sounds/rotategrid");
            //reward = G.Content.Load<SoundEffect>("Sounds/reward");
            //move = G.Content.Load<SoundEffect>("Sounds/move");
            //select = G.Content.Load<SoundEffect>("Sounds/select");

            //reload = G.Content.Load<SoundEffect>("Sounds/reload");
            MediaPlayer.Volume = 0.01f * OptionsMenuScreen.musicVolume;
            MediaPlayer.IsRepeating = true;
            //laser = G.Content.Load<SoundEffect>("Sounds/laser");
        }
示例#7
0
        public static void LoadContent()
        {
            MenuTapFX = Stuff.Content.Load<SoundEffect>("Sound\\MenuTap");
              BackgroundSong = Stuff.Content.Load<Song>("Sound\\BackgroundSong");
              EggBreakFX = Stuff.Content.Load<SoundEffect>("Sound\\EggBreak");
            CoinFX = Stuff.Content.Load<SoundEffect>("Sound\\Coin");

            HayFX = Stuff.Content.Load<SoundEffect>("Sound\\hay");

            SoundEffect TmpFX;
            for (int i = 1; i <= 8; i++)
            {
                TmpFX = Stuff.Content.Load<SoundEffect>("Sound\\pig" + i);
                PigFX.Add(TmpFX);
            }

            for (int i = 1; i <= 5; i++)
            {
                TmpFX = Stuff.Content.Load<SoundEffect>("Sound\\Poop" + i);
              PoopFX.Add(TmpFX);
            }
            for (int i = 1; i <= 5; i++)
            {
                TmpFX = Stuff.Content.Load<SoundEffect>("Sound\\Jump" + i);
                JumpFX.Add(TmpFX);
            }
        }
示例#8
0
 public void AddMusic(string name, bool isRepeating, float volume)
 {
     MediaPlayer.IsRepeating = true;
     MediaPlayer.Volume = 0.5f;
     songName = name;
     music = contentManager.Load<Song>(name);
 }
示例#9
0
        public static void LoadContent(ContentManager Content)
        {
            //personnage
            joueur = Content.Load<Texture2D>("Sprite/Llama/llama");
            // menu
            jouer1 = Content.Load<Texture2D>("Sprite/Menu/jouer1");
            jouer2 = Content.Load<Texture2D>("Sprite/Menu/jouer2");
            options1 = Content.Load<Texture2D>("Sprite/Menu/Options1");
            options2 = Content.Load<Texture2D>("Sprite/Menu/Options2");
            quit1 = Content.Load<Texture2D>("Sprite/Menu/Quitter1");
            quit2 = Content.Load<Texture2D>("Sprite/Menu/Quitter2");
            fondMenu = Content.Load<Texture2D>("Sprite/Menu/fond");//ajouter un fond
            imageQuit = Content.Load<Texture2D>("Sprite/End");

            //options
            fondOptions = Content.Load<Texture2D>("Sprite/Background/OptionsBackground");
            marchearret = Content.Load<Texture2D>("Sprite/elementsOptions/marchearret");
            //Map
            grass = Content.Load<Texture2D>("Sprite/Background/grass");
            // Son
            song = Content.Load<Song>("Sons/menusong");
            effect = Content.Load<SoundEffect>("Sons/effectmenu");
            quiteffect = Content.Load<SoundEffect>("Sons/quiteffect");
            songtest = Content.Load<Song>("Sons/test");
        }
示例#10
0
        /// <summary>
        /// Sets the background music to the sound with the given name.
        /// </summary>
        /// <param name="name">The name of the music to play.</param>
        public static void PlayMusic(string name)
        {
            currentSong = null;

            try
            {
                currentSong = content.Load<Song>(name);
            }
            catch (Exception e)
            {
            #if ZUNE
            //on the Zune we can go through the MediaLibrary to attempt
            //to find a matching song name. this functionality doesn't
            //exist on Windows or Xbox 360 at this time
            MediaLibrary ml = new MediaLibrary();
            foreach (Song song in ml.Songs)
                if (song.Name == name)
                    currentSong = song;
            #endif

                //if we didn't find the song, rethrow the exception
                if (currentSong == null)
                    throw e;
            }

            MediaPlayer.Play(currentSong);
        }
示例#11
0
 public static void StopMusic(Song song)
 {
     if (currentSong != song)
     {
         MediaPlayer.Stop();
     }
 }
示例#12
0
		void CustomInitialize()
		{
            this.EscogerChar.Visible = false;
            this.Sprite1.Visible = false;
            this.Sprite2.Visible = false;
            if (GlobalData.AI == false)
            {
                Entities.Kursor P1 = new Entities.Kursor(ContentManagerName);
                Entities.Kursor P2 = new Entities.Kursor(ContentManagerName);
                Cursores.Add(P1);
                Cursores.Add(P2);
            }
            else
            {
                Entities.Kursor P1 = new Entities.Kursor(ContentManagerName);
                Cursores.Add(P1);
            }
            seleccion1 = false;
            seleccion2 = false;

            Microsoft.Xna.Framework.Media.MediaPlayer.IsRepeating = true;
            song =
  FlatRedBallServices.Load<Song>(@"Content/intro", ContentManagerName);
            Microsoft.Xna.Framework.Media.MediaPlayer.Play(song);
           

		}
        public void charger()
        {
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_1"));
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_2"));
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_3"));
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_4"));
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_5"));
            Lpas.Add(jeu.Content.Load<SoundEffect>("walk_6"));

            Lroule.Add(jeu.Content.Load<SoundEffect>("cart_1"));
            Lroule.Add(jeu.Content.Load<SoundEffect>("cart_2"));
            Lroule.Add(jeu.Content.Load<SoundEffect>("cart_3"));
            Lroule.Add(jeu.Content.Load<SoundEffect>("cart_4"));

            Lcri.Add(jeu.Content.Load<SoundEffect>("scream_01"));
            Lcri.Add(jeu.Content.Load<SoundEffect>("scream_02"));
            Lcri.Add(jeu.Content.Load<SoundEffect>("scream_03"));

            Ltoucher.Add(jeu.Content.Load<SoundEffect>("punch_1"));
            Ltoucher.Add(jeu.Content.Load<SoundEffect>("punch_2"));
            Ltoucher.Add(jeu.Content.Load<SoundEffect>("punch_3"));

            Splash = jeu.Content.Load<SoundEffect>("smash_dirty");
            theme = jeu.Content.Load<Song>("theme");

            SplashSound = jeu.Content.Load<Song>("music_intro");
            OverSound = jeu.Content.Load<SoundEffect>("game_over");
        }
示例#14
0
        // start playing a track
        public void startTrack(String trackname, int fadeMS)
        {
            if (loadedTracks.ContainsKey(trackname))
            {
                // set to next track
                nextTrack = loadedTracks[trackname];
                fadelength = fadeMS;
                fadestartTime = DateTime.Now;

                // if a previous track exists, fade out
                if (prevTrack)
                {
                    fade = Fade.OUT;
                }
                else
                {
                    // otherwise start fade in
                    fade = Fade.IN;
                    MediaPlayer.Play(nextTrack);
                    MediaPlayer.IsRepeating = true;
                    nextTrack = null;
                    prevTrack = true;
                }
            }
        }
示例#15
0
        public static void LoadContent(ContentManager content)
        {
            //Picture
            path = content.Load<Texture2D>("path");
            grass = content.Load<Texture2D>("grass");
            basicEnnemi = content.Load<Texture2D>("basicEnnemi");
            fastEnnemi = content.Load<Texture2D>("grass");
            armorEnnemi = content.Load<Texture2D>("grass");
            buttonTowerBasic = content.Load<Texture2D>("bouton basic tourelle");
            buttonTowerPower = content.Load<Texture2D>("bouton power tourelle");
            buttonTowerRange = content.Load<Texture2D>("bouton range tourelle");
            towerBasic = content.Load<Texture2D>("basicTower");
            towerPower = content.Load<Texture2D>("powerTower");
            towerRange = content.Load<Texture2D>("rangeTower");
            MainMenu = content.Load<Texture2D>("MainMenu");
            bullet = content.Load<Texture2D>("bullet");
            gold = content.Load<Texture2D>("gold");
            select = content.Load<Texture2D>("select");
            personnage = content.Load<Texture2D>("player");
            vieChateau = content.Load<Texture2D>("vie");
            chateau = content.Load<Texture2D>("chateau");
            Map = content.Load<Texture2D>("Map");

            //Font
            write = content.Load<SpriteFont>("Write");
            vie = content.Load<SpriteFont>("Write");
            gameOver = content.Load<SpriteFont>("GameOver");

            //Song
            ambiance = content.Load<Song>("01");
        }
示例#16
0
 public SoundManager(ContentManager content)
 {
     this.content = content;
       this.background = content.Load<Song>(@"sounds\background");
       this.hurt = content.Load<SoundEffect>(@"sounds\hurt");
       this.bounce = content.Load<SoundEffect>(@"sounds\bounce");
       this.collide = content.Load<SoundEffect>(@"sounds\collide");
 }
示例#17
0
 public static void lancer_musique(ref bool lancer, Song musique)
 {
     if (!lancer)
     {
         MediaPlayer.Play(musique);
         lancer = true;
     }
 }
示例#18
0
 /// <summary>
 /// 播放音乐
 /// </summary>
 public void PlaySong(Song song)
 {
     if (MediaPlayer.State == MediaState.Stopped)
     {
         MediaPlayer.IsRepeating = true;
         MediaPlayer.Play(song);
     }
 }
示例#19
0
 public override void Close()
 {
     if (mSong != null)
     {
         mSong.Dispose();
         mSong = null;
     }
 }
示例#20
0
		void CustomInitialize()
		{
            this.Alternativas.Visible = false;
            Microsoft.Xna.Framework.Media.MediaPlayer.IsRepeating = true;
            song =
            FlatRedBallServices.Load<Song>(@"Content/intro", ContentManagerName);
            Microsoft.Xna.Framework.Media.MediaPlayer.Play(song);
		}
示例#21
0
        public static void Initialize(ContentManager _content)
        {
            content = _content;

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = MusicVolume;
            bgSong = content.Load<Song>("Sounds/fightMusic");
        }
示例#22
0
 public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager Content)
 {
     Background.LoadContent(Content);
     Image.LoadConent(Content);
     this.backgroundMusic = Content.Load<Song>("sounds/backgroundMusic");
     MediaPlayer.Play(this.backgroundMusic);
     base.LoadContent(Content);
 }
示例#23
0
        public override void Dispose()
        {
            if (music == null)
                return;

            music.Dispose();
            music = null;
        }
示例#24
0
        public void playMusic(string asset)
        {
            current = null;

            if (songList.TryGetValue(asset, out current))
            {
                MediaPlayer.Play(current);
            }
        }
        //----------------------//------------------------//

        public static void Initialize()
        {
            _cancelSe = LoadSe("Cancel");
            _confirmSe = LoadSe("Confirm");
            _selectSe = LoadSe("Select");
            _nonMapSong = LoadBgm("AchaidhCheide");
            _mapSong = LoadBgm("AngevinB");
            MediaPlayer.IsRepeating = true;
        }
 public void Play(Song sound)
 {
     if (!isPlaying)
     {
         MediaPlayer.Play(sound);
         MediaPlayer.IsRepeating = true;
         isPlaying = true;
     }
 }
示例#27
0
 public Player(List<BingoTile> playerTiles, int playerID, Game game)
 {
     this.PlayerTiles = playerTiles;
     AnsweredTiles = new bool[playerTiles.Count];
     this.PlayerID = playerID;
     WinnerMessage = game.Content.Load<SpriteFont>("Comic");
     Highlight = game.Content.Load<Texture2D>("BingoEnvironment/Highlight");
     BingoSound = game.Content.Load<Microsoft.Xna.Framework.Media.Song>("BingoEnvironment/BingoSound");
 }
示例#28
0
 public void PlayMusic(MusicEnum music)
 {
     if (!Settings.Instance.MyAppSettings.GameSettings.IsMusicOn)
         return;
     m_songInstance = m_musics[music];
     MediaPlayer.Play(m_songInstance);
     MediaPlayer.Volume = Settings.Instance.MyAppSettings.GameSettings.MusicVolume;
     MediaPlayer.IsRepeating = true;
 }
示例#29
0
        public Music(DisposableI parent, string fileName)
            : base(parent)
        {
            audio = parent.FindParentOrSelfWithException<Audio>();
            audio.UpdateCallback += Update;

            song = parent.FindParentOrSelfWithException<RootDisposable>().Content.Load<Song>(Streams.StripFileExt(fileName));
            MediaPlayer.IsRepeating = true;
        }
        public BetterMediaPlayer(List<Song> songs)
        {
            this.songs = songs;
            currentSongIndex = 0;
            activeSong = songs.ElementAtOrDefault<Song>(currentSongIndex);

            using (MediaLibrary library = new MediaLibrary())
            {
                collectionSongs = library.Songs.ToList();
            }

            MediaPlayer.ActiveSongChanged += (s, e) =>
                {
                    if (MediaPlayer.Queue.ActiveSong == nextSong)
                    {
                        MoveNext();
                    }
                    else if (MediaPlayer.Queue.ActiveSong == prevSong)
                    {
                        MovePrev();
                    }

                };

            MediaPlayer.MediaStateChanged += (s, e) =>
            {
                if (MediaPlayer.State == MediaState.Stopped)
                {
                    MoveNext();
                }

                if (MediaPlayer.State == MediaState.Playing)
                {
                    timer.Change(0, 500);
                }
                else
                {
                    timer.Change(Timeout.Infinite, Timeout.Infinite);
                }
                RaisePropertyChanged(StatePropertyName);
            };

            timer = new Timer(
                x => RaisePropertyChanged(PlayPositionPropertyName),
                null, Timeout.Infinite, Timeout.Infinite);

            // Needed, otherwise our counting logic is completely thrown off
            // because the order is not maintained between the collection passed
            // to MediaPlayer.Play and MediaPlayer.Queue
            MediaPlayer.IsShuffled = false;

            // TODO Ask the user to take over the music
            // TODO Figure out how to clear existing playlist
            MediaPlayer.Stop();

            // TODO Stop music when they quit the app
        }
示例#31
0
文件: Song.cs 项目: JordanFisher/WAL
        protected override void LoadSong(string name)
        {
            //song = GameClass.Game.Content.LoadTillSuccess<XnaMedia.Song>("Music\\" + name);

            try
            {
                song = GameClass.Game.Content.Load <XnaMedia.Song>("Music\\" + name);
            }
            catch (Exception e)
            {
                song = null;
            }
        }
示例#32
0
        private void PlatformLoad(Action <int> progressCallback)
        {
            Task.Run(async() =>
            {
                if (musicFolder == null)
                {
                    musicFolder = KnownFolders.MusicLibrary;
                }

                var files = new List <StorageFile>();
                await this.GetAllFiles(musicFolder, files);

                var songList  = new List <Song>();
                var albumList = new List <Album>();

                var artists = new Dictionary <string, Artist>();
                var albums  = new Dictionary <string, Album>();
                var genres  = new Dictionary <string, Genre>();

                var cache = new Dictionary <string, MusicProperties>();

                // Read cache
                var cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.OpenIfExists);
                using (var stream = new BinaryReader(await cacheFile.OpenStreamForReadAsync()))
                    try
                    {
                        for (; stream.BaseStream.Position < stream.BaseStream.Length;)
                        {
                            var entry = MusicProperties.Deserialize(stream);
                            cache.Add(entry.Path, entry);
                        }
                    }
                    catch { }

                // Write cache
                cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.ReplaceExisting);
                using (var stream = new BinaryWriter(await cacheFile.OpenStreamForWriteAsync()))
                {
                    int prevProgress = 0;

                    for (int i = 0; i < files.Count; i++)
                    {
                        var file = files[i];
                        try
                        {
                            MusicProperties properties;
                            if (!(cache.TryGetValue(file.Path, out properties) && properties.TryMatch(file)))
                            {
                                properties = new MusicProperties(file);
                            }
                            properties.Serialize(stream);

                            if (string.IsNullOrWhiteSpace(properties.Title))
                            {
                                continue;
                            }

                            Artist artist;
                            if (!artists.TryGetValue(properties.Artist, out artist))
                            {
                                artist = new Artist(properties.Artist);
                                artists.Add(artist.Name, artist);
                            }

                            Artist albumArtist;
                            if (!artists.TryGetValue(properties.AlbumArtist, out albumArtist))
                            {
                                albumArtist = new Artist(properties.AlbumArtist);
                                artists.Add(albumArtist.Name, albumArtist);
                            }

                            Genre genre;
                            if (!genres.TryGetValue(properties.Genre, out genre))
                            {
                                genre = new Genre(properties.Genre);
                                genres.Add(genre.Name, genre);
                            }

                            Album album;
                            if (!albums.TryGetValue(properties.Album, out album))
                            {
                                var thumbnail = Task.Run(async() => await properties.File.GetThumbnailAsync(ThumbnailMode.MusicView, 300, ThumbnailOptions.ResizeThumbnail)).Result;
                                album         = new Album(new SongCollection(), properties.Album, albumArtist, genre, thumbnail.Type == ThumbnailType.Image ? thumbnail : null);
                                albums.Add(album.Name, album);
                                albumList.Add(album);
                            }

                            var song = new Song(album, artist, genre, properties);
                            song.Album.Songs.Add(song);
                            songList.Add(song);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("MediaLibrary exception: " + e.Message);
                        }

                        int progress = 100 * i / files.Count;
                        if (progress > prevProgress)
                        {
                            prevProgress = progress;
                            if (progressCallback != null)
                            {
                                progressCallback.Invoke(progress);
                            }
                        }
                    }
                }

                if (progressCallback != null)
                {
                    progressCallback.Invoke(100);
                }

                albumCollection = new AlbumCollection(albumList);
                songCollection  = new SongCollection(songList);
            }).Wait();
        }
示例#33
0
 internal void Add(Song song)
 {
     songs.Add(song);
 }
示例#34
0
 private static void PlaySong(Song song)
 {
     song.Volume = IsMuted ? 0.0f : Volume;
     song.Play();
     State = MediaState.Playing;
 }
示例#35
0
 public void LoadRes(Microsoft.Xna.Framework.Content.ContentManager cm)
 {
     song = cm.Load <XNAVanillaSong>(resname);
 }