private static void ProcessUri(string uri, Message message)
        {
            if (Clients.Keys.Any(_ => uri.Contains(_)))
            {
                try
                {
                    IClient client = Clients.First(_ => uri.Contains(_.Key)).Value;
                    if (client != null)
                    {
                        IMusic parsedMusic = client.ParseUri(uri);
                        Bot.Client.SendTextMessageAsync(message.Chat.Id, parsedMusic.ToString( ));
                        string reply = client.SearchMusic(parsedMusic) ??
                                       Messages.MusicNotFound.GetLocalized(message.From.LanguageCode);

                        Bot.Client.SendTextMessageAsync(message.Chat.Id, reply);
                    }
                }
                catch (InvalidOperationException)
                {
                    Log.Error("Uri received, but parser not found");
                    Bot.Client.SendTextMessageAsync(message.Chat.Id,
                                                    "Либо это не ссылка на музыку, либо я не умею работать с этим сервисом");
                }
                catch (NullReferenceException)
                {
                    Log.Error("Parser failed");
                    Bot.Client.SendTextMessageAsync(message.Chat.Id,
                                                    "Музыка не распознана");
                }
            }
        }
Пример #2
0
 public InputMusicInformation(long aTimeStampTicks, bool aIsSelected, IMusic aMusic, double aProgress)
 {
     timeStampTicks = aTimeStampTicks;
     isSelected     = aIsSelected;
     music          = aMusic;
     progress       = aProgress;
 }
Пример #3
0
        public GameOptions()
        {
            gameVersion = GameVersion.Version109;
            gameMode    = GameMode.Commercial;
            missionPack = MissionPack.Doom2;

            players = new Player[Player.MaxPlayerCount];
            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                players[i] = new Player(i);
            }
            players[0].InGame = true;
            consolePlayer     = 0;

            episode = 1;
            map     = 1;
            skill   = GameSkill.Medium;

            demoPlayback = false;
            netGame      = false;

            deathmatch      = 0;
            fastMonsters    = false;
            respawnMonsters = false;
            noMonsters      = false;

            intermissionInfo = new IntermissionInfo();

            random = new DoomRandom();

            video     = NullVideo.GetInstance();
            sound     = NullSound.GetInstance();
            music     = NullMusic.GetInstance();
            userInput = NullUserInput.GetInstance();
        }
 public PlayMusicInformation(long aTimeStampTicks, bool aIsSelected, IMusic aMusic, LoopInformation aLoopPoint)
 {
     timeStampTicks = aTimeStampTicks;
     isSelected     = aIsSelected;
     music          = aMusic;
     loopPoint      = aLoopPoint;
 }
Пример #5
0
 public static void LoadMusicInfoFromJson(IMusic m, dynamic obj)
 {
     var type = m.Type.ToString();
     m.Name = Get(obj,  type + "_name", "name" );
     m.Id = Get(obj, type + "_id", "id" );
     m.Logo = StringHelper.EscapeUrl(Get(obj, type + "_logo", "logo","album_logo" ));
 }
Пример #6
0
        private MusicViewModel createViewModel(IMusic music, bool toFront)
        {
            MusicViewModel s = null;

            switch (music.Type)
            {
            case EnumMusicType.album:
                s = new AlbumViewModel(music as Album);
                break;

            case EnumMusicType.artist:
                s = new ArtistViewModel(music as Artist);
                break;

            case EnumMusicType.collect:
                s = new CollectViewModel(music as Collection);
                break;

            default:
                s = SongViewModel.Get(music as Song);
                break;
            }

            return(s);
        }
Пример #7
0
        void addItem(IMusic music, bool toFront)
        {
            MusicViewModel s = createViewModel(music, toFront);

            if (s == null)
            {
                return;
            }
            UIHelper.WaitOnUI(() =>
            {
                if (s is SongViewModel)
                {
                    var dup = this.IndexOf(s);
                    if (dup != -1)
                    {
                        Move(dup, toFront ? 0 : this.Count - 1);
                        return;
                    }
                }
                if (toFront)
                {
                    Insert(0, s);
                }
                else
                {
                    Add(s);
                }
            });
        }
Пример #8
0
        public static IMusic CreateFromJson(dynamic obj, EnumMusicType type)
        {
            IMusic res = null;

            switch (type)
            {
            case EnumMusicType.album:
                res = new Album();
                break;

            case EnumMusicType.artist:
                res = new Artist();
                break;

            case EnumMusicType.collect:
                res = new Collection();
                break;

            case EnumMusicType.song:
                res = new Song();
                break;

            default:
                break;
            }
            if (res != null)
            {
                res.CreateFromJson(obj);
            }
            return(res);
        }
Пример #9
0
        public async Task <int> UpdateAsync(IMusic entity)
        {
            DbContext.Musics.Remove(await DbContext.Musics.FindAsync(entity.MusicPartId));
            await DbContext.SaveChangesAsync();

            return(await _repository.UpdateAsync(AutoMapper.Mapper.Map <Music>(entity)));
        }
Пример #10
0
        public GameOptions()
        {
            this.players = new Player[Player.MaxPlayerCount];

            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                this.players[i] = new Player(i);
            }

            this.players[0].InGame = true;
            this.consolePlayer     = 0;

            this.episode = 1;
            this.map     = 1;
            this.skill   = GameSkill.Medium;

            this.netGame = false;

            this.deathmatch      = 0;
            this.fastMonsters    = false;
            this.respawnMonsters = false;
            this.noMonsters      = false;

            this.intermissionInfo = new IntermissionInfo();

            this.renderer  = null;
            this.sound     = NullSound.GetInstance();
            this.music     = NullMusic.GetInstance();
            this.userInput = NullUserInput.GetInstance();
        }
Пример #11
0
 public static void load(SampleGame sampleGame)
 {
     // TODO Auto-generated method stub
     theme = sampleGame.getAudio().createMusic(Prefix + "menutheme.mp3");
     theme.setLooping(true);
     theme.setVolume(0.85f);
     theme.play();
 }
Пример #12
0
 public static void load(SampleGame sampleGame)
 {
     // TODO Auto-generated method stub
     theme = sampleGame.getAudio().createMusic(Prefix + "menutheme.mp3");
     theme.setLooping(true);
     theme.setVolume(0.85f);
     theme.play();
 }
Пример #13
0
 /// <summary>
 /// 在当前播放列表加入
 /// </summary>
 /// <param name="music"></param>
 public static void Add(IMusic music, bool play = true)
 {
     Musics.Add(music);
     if (play)
     {
         index = Musics.Count - 1;
     }
 }
Пример #14
0
 /// <summary>
 /// 在当前播放歌曲后插入
 /// </summary>
 /// <param name="music"></param>
 public static void Insert(IMusic music, bool play = true)
 {
     Musics.Insert(index, music);
     if (play)
     {
         index++;
     }
 }
 public static void PlayOverWorldTheme(){
     StopAllBackgroundThemes();
     if(HUDManager.RemainingTime() > SoundConstants.HURRYUPTIME)
         overworld = new MarioOverworldTheme();
     else
         overworld = new RushedOverworldTheme();
     overworld.PlayTheme();
 }
Пример #16
0
        public MusicViewer(IMusic music)
        {
            InitializeComponent();
            _music = music;

            artistsList.Items.AddRange(_music.GetArtists().ToArray());
            musicName.Text = _music.Name;
        }
Пример #17
0
 public MusicViewModel(IMusic m)
 {
     music = m;
     if (m.Logo != null)
     {
         m.Logo = m.Logo.Replace("_1.jpg", ".jpg");
     }
 }
Пример #18
0
 public static string Get(this IMusic m, params string[] props)
 {
     if (m == null)
     {
         return(null);
     }
     return(Get(m.JsonObject, props));
 }
Пример #19
0
        public MusicViewer(IMusic music)
        {
            InitializeComponent();
            _music = music;

            artistsList.Items.AddRange(_music.GetArtists().ToArray());
            musicName.Text = _music.Name;
        }
Пример #20
0
    public static void LoadMusicInfoFromJson(IMusic m, dynamic obj)
    {
        var type = m.Type.ToString();

        m.Name       = Get(obj, type + "_name", "name", "title");
        m.Id         = Get(obj, type + "_id", "id", "obj_id");
        m.Logo       = StringHelper.EscapeUrl(Get(obj, type + "_logo", "logo", "album_logo"));
        m.JsonObject = obj;
    }
Пример #21
0
        public void AddFile(string file)
        {
            IMusic temp = MusicFactory.GetMusic(new FileInfo(file), control);

            if (temp != null)
            {
                FileList.Add(temp);
            }
        }
        private void ListView_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var    music         = Library.LoadMusic(listview.SelectedItem.ToString());
            IMusic selectedMusic = listview.SelectedItem as IMusic;

            MessageBox.Show(selectedMusic.Title);

            Player.Play(selectedMusic);
        }
Пример #23
0
        private void UpdateFileList(object sender, FileSystemEventArgs e)
        {
            string[]      lFilePathArray   = PoolFilePath.Get(directoryInfo);
            List <string> lFilePathNewList = new List <string>();

            // Check New File.
            for (int i = 0; i < lFilePathArray.Length; i++)
            {
                string lFilePath       = lFilePathArray[i];
                long   lTimeStampTicks = File.GetLastWriteTime(lFilePath).Ticks;

                if (timeStampTicksDictionary.ContainsKey(lFilePath) == false)
                {
                    timeStampTicksDictionary.Add(lFilePath, lTimeStampTicks);
                    lFilePathNewList.Add(lFilePath);
                }
                else if (lTimeStampTicks != timeStampTicksDictionary[lFilePath])
                {
                    timeStampTicksDictionary[lFilePath] = lTimeStampTicks;
                    lFilePathNewList.Add(lFilePath);
                }
            }

            for (int i = 0; i < lFilePathNewList.Count; i++)
            {
                string lFilePath = lFilePathNewList[i];
                //Logger.BreakDebug( "Input:" + lFilePath );

                if (Path.GetExtension(lFilePath) == ".meta")
                {
                    continue;
                }

                try
                {
                    IMusic lMusic = ConstructorCollection.ConstructMusic(lFilePath);

                    if (lMusic != null)
                    {
                        if (musicInformationDictionary.ContainsKey(lFilePath) == false)
                        {
                            filePathList.Add(lFilePath);
                            musicInformationDictionary.Add(lFilePath, new InputMusicInformation(timeStampTicksDictionary[lFilePath], false, lMusic, 0.0d));
                        }
                        else
                        {
                            musicInformationDictionary[lFilePath] = new InputMusicInformation(timeStampTicksDictionary[lFilePath], false, lMusic, 0.0d);
                        }
                    }
                }
                catch (Exception aExpection)
                {
                    Logger.BreakError("LoopPlaylist Exception:" + aExpection.ToString() + ":" + lFilePath);
                }
            }
        }
Пример #24
0
 /// <summary>
 /// 设置当前播放音乐
 /// </summary>
 /// <param name="music"></param>
 public static void SetCurrentMusic(IMusic music)
 {
     for (int i = 0; i < Musics.Count; i++)
     {
         if (Musics[i] == music)
         {
             index = i;
         }
     }
 }
Пример #25
0
 public static void Main(string[] args)
 {
     // custom dependency injection & sql data connection
     // performing migrations on startup
     Data = new IData(new IDataSqlite());
     Data.MigrateDatabase();
     Music = new IMusic(new IMusicFileDirectory());
     Task.Run(() => { Music.GenerateMusicData(); });
     CreateHostBuilder(args).Build().Run();
 }
 public static void PlayStarTheme()
 {
     GetPreviousTheme();
     StopAllBackgroundThemes();
     if (HUDManager.RemainingTime() > SoundConstants.HURRYUPTIME)
         starMan = new StarTheme();
     else
         starMan = new RushedStarTheme();
     starMan.PlayTheme();
 }
Пример #27
0
 public MusicInfoModel(IMusic music)
 {
     Id         = music.Id;
     Artists    = music.Artists;
     Name       = music.Name;
     Album      = music.Album;
     SourceName = music.SourceName;
     Origin     = music.Origin;
     CoverId    = music.CoverId;
 }
Пример #28
0
 /// <summary>
 /// Retourne l'indice de la première Music matchant celle passée en paramètre
 /// </summary>
 /// <param name="currentlyPlaying"> Music à rechercher </param>
 /// <returns> L'indice de la première occurence matchant celle passée en paramètre </returns>
 public int Index(IMusic currentlyPlaying)
 {
     try
     {
         return(PlaylistProperty.IndexOf(PlaylistProperty.First(x => x.Equals(currentlyPlaying))));
     }
     catch
     {
         throw new NullReferenceException();
     }
 }
Пример #29
0
        public bool Equals(IMusic other)
        {
            if (!(other is Artist))
            {
                return(false);
            }

            Artist otherArtist = ( Artist )other;

            return(string.Equals(_name, otherArtist.Name, StringComparison.OrdinalIgnoreCase) &&
                   _sampleAlbum.Equals(otherArtist.SampleAlbum));
        }
Пример #30
0
        public void AddItems(List <IMusic> inlist, bool toFront = false)
        {
            int count = inlist.Count();

            if (count == 0)
            {
                return;
            }
            count = Math.Min(slowCount, count);
            int s = 1000 / count;

            Task.Run(() =>
            {
                try
                {
                    foreach (var item in inlist)
                    {
                        queue.Enqueue(item);
                    }
                    for (int i = 0; i < count; i++)
                    {
                        IMusic item = null;
                        if (!queue.TryDequeue(out item))
                        {
                            break;
                        }
                        addItem(item, toFront);
                        Thread.Sleep(s);
                    }
                    int buffer = 0;
                    while (true)
                    {
                        IMusic item = null;
                        if (!queue.TryDequeue(out item))
                        {
                            break;
                        }
                        addItem(item, toFront);
                        buffer++;
                        if (buffer == 10000)
                        {
                            Thread.Sleep(100);
                            buffer = 0;
                        }
                    }
                }
                catch (System.Exception e)
                {
                    var x = e.StackTrace;
                }
            });
        }
Пример #31
0
        public void Crossfade(IMusic music, int length)
        {
            if (currentSong == null) {
                // TODO: Fade in music
                Play(music);
            } else {
                crossfadeTargetSong = music as Music;
                crossfadeStepSize = length / 100;

                crossfadeTargetSong.SFMusic.Volume = 0f;
                crossfadeTargetSong.SFMusic.Play();
            }
        }
Пример #32
0
        public bool Equals(IMusic other)
        {
            if (!(other is Album))
            {
                return(false);
            }

            Album otherAlbum = ( Album )other;

            return((_title.Contains(otherAlbum.Title, StringComparison.OrdinalIgnoreCase) ||
                    otherAlbum.Title.Contains(_title, StringComparison.OrdinalIgnoreCase)) &&
                   string.Equals(_artist, otherAlbum.Artist, StringComparison.OrdinalIgnoreCase));
        }
Пример #33
0
        private void PrepareDownload()
        {
            //Instantiate IFileWritter to handle writting downloaded data to file system
            var myWriter = Music.GetFileWriter(myWriterType, DownloadDir);

            //Instantiate new Music object to handle downloads
            _music = new Music(myWriter);

            //Add each song selected by the user to _music.Songs
            GetSelectedSongs()
            .ForEach(selectedSong =>
                     _music.Songs.Add(Music.GetSong(mySongType, RapGeniusUrl, selectedSong)));
        }
Пример #34
0
        private void PrepareDownload()
        {
            //Instantiate IFileWritter to handle writting downloaded data to file system
            var myWriter = Music.GetFileWriter(myWriterType, DownloadDir);

            //Instantiate new Music object to handle downloads
            _music = new Music(myWriter);

            //Add each song selected by the user to _music.Songs
            GetSelectedSongs()
                .ForEach(selectedSong =>
                    _music.Songs.Add(Music.GetSong(mySongType, RapGeniusUrl, selectedSong)));
        }
Пример #35
0
        public bool Equals(IMusic other)
        {
            if (!(other is Track))
            {
                return(false);
            }

            Track otherTrack = ( Track )other;

            return((_title.Contains(otherTrack.Title, StringComparison.OrdinalIgnoreCase) ||
                    otherTrack.Title.Contains(_title, StringComparison.OrdinalIgnoreCase)) &&
                   (_album.Contains(otherTrack.Album, StringComparison.OrdinalIgnoreCase) ||
                    otherTrack.Album.Contains(_album, StringComparison.OrdinalIgnoreCase)) &&
                   string.Equals(_artist, otherTrack.Artist, StringComparison.OrdinalIgnoreCase));
        }
Пример #36
0
        public void AddDirectory(string directory)
        {
            FileList = new List <IMusic>();
            DirectoryInfo directoryInfo = new DirectoryInfo(directory);

            FileInfo[] Files = directoryInfo.GetFiles();
            foreach (var file in Files)
            {
                IMusic temp = MusicFactory.GetMusic(file, control);
                if (temp != null)
                {
                    FileList.Add(temp);
                }
            }
        }
Пример #37
0
Файл: ID3.cs Проект: scbj/musixx
        public static async void ExtractTagsFromBuffer(IBuffer buffer, IMusic music)
        {
            using (var stream = new MemoryStream(buffer.ToArray()))
            {
                TagLib.File file = TagLib.File.Create(new StreamFileAbstraction(music.File.Name, stream, stream));
                Tag         tag  = file.GetTag(TagTypes.Id3v2);

                if (!String.IsNullOrWhiteSpace(tag.Title))
                {
                    music.Title = tag.Title;
                }

                if (!String.IsNullOrWhiteSpace(tag.FirstPerformer))
                {
                    music.Artist = tag.FirstPerformer;
                }

                if (!String.IsNullOrWhiteSpace(tag.Album))
                {
                    music.Album = tag.Album;
                }

                if (tag.Pictures.Length > 0)
                {
                    StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                    var           item        = await localFolder.TryGetItemAsync(music.File.Id + ".jpg");

                    if (item != null)
                    {
                        music.CoverUri = new Uri(item.Path);
                    }
                    else
                    {
                        StorageFile storageFile = await localFolder.CreateFileAsync(music.File.Id + ".jpg");

                        await FileIO.WriteBytesAsync(storageFile, tag.Pictures[0].Data.Data);

                        music.CoverUri = new Uri(storageFile.Path);
                    }
                    Debug.WriteLine(music.CoverUri);
                }

                int bitrate = file.Properties.AudioBitrate * 125;
                music.Duration = TimeSpan.FromSeconds(music.File.Size / bitrate);
            }
        }
 public static void PlayBuckeyeOverworldTheme()
 {
     StopAllBackgroundThemes();
     buckeyeOverworld = new BuckeyeOverworldTheme();
     buckeyeOverworld.PlayTheme();
 }
 public static void PlayFlagPoleVictoryTheme()
 {
     StopAllBackgroundThemes();
     flagPoleVictory = new FlagPoleVictoryTheme();
     flagPoleVictory.PlayTheme();
 }
 public static void PlayIntroTheme()
 {
     StopAllBackgroundThemes();
     intro = new IntroTheme();
     intro.PlayTheme();
 }
Пример #41
0
 public bool IsTagMatches(IMusic music, IMusicTag tag)
 {
     return this[tag.Id] != string.Empty && music[tag.Id] != string.Empty && this[tag.Id] == music[tag.Id];
 }
 public static void PlayPacManEndTheme()
 {
     StopAllBackgroundThemes();
     pacEndTheme = new PacMarioEndTheme();
     pacEndTheme.PlayTheme();
 }
 private static void GetPreviousTheme()
 {
     if (overworld.IsPlaying())
         prePowerUpTheme = overworld;
     else if (flagPoleVictory.IsPlaying())
         prePowerUpTheme = flagPoleVictory;
     else if (buckeyeOverworld.IsPlaying())
         prePowerUpTheme = buckeyeOverworld;
     else if (pacLevel.IsPlaying())
         prePowerUpTheme = pacLevel;
 }
Пример #44
0
 public MusicViewModel(IMusic m)
 {
     music = m;
     if (m.Logo != null)
         m.Logo = m.Logo.Replace("_1.jpg", ".jpg");
 }
 public static void PlayPacManLevelTheme()
 {
     StopAllBackgroundThemes();
     pacLevel = new PacManLevelTheme();
     pacLevel.PlayTheme();
 }
 public static void PlayPacMarioDeathTheme()
 {
     StopAllBackgroundThemes();
     pacDeath = new PacMarioDeadTheme();
     pacDeath.PlayTheme();
 }
Пример #47
0
 public void Crossfade(IMusic music, int length)
 {
     throw new NotImplementedException();
 }
Пример #48
0
 public MusicInPlayList(IMusic music)
 {
     _music = music;
 }
Пример #49
0
 public void Add(IMusic music)
 {
     _store.Add(music);
     AllMusicPlayList.Add(music.Id);
 }
Пример #50
0
 public bool IsTagMatches(IMusic music, IMusicTag musicTag)
 {
     return _music.IsTagMatches(music, musicTag);
 }
Пример #51
0
        public void Play(IMusic music)
        {
            currentSong = music as Music;

            currentSong.SFMusic.Play();
        }
Пример #52
0
 public void Play(IMusic music)
 {
     throw new NotImplementedException();
 }
 public static void PlayDeathTheme()
 {
     StopAllBackgroundThemes();
     death = new DeathTheme();
     death.PlayTheme();
 }
Пример #54
0
 public void Add(IMusic music)
 {
     _adapter.OpenDatabase();
     _adapter.ExecuteNonQuery(string.Format(Constants.Sql.InsertMusic, music.Id, music.Priority));
     _adapter.Close();
 }
 public static void PlayCarmenTheme()
 {
     StopAllBackgroundThemes();
     carmen = new CarmenTheme();
     carmen.PlayTheme();
 }
Пример #56
0
 public MusicViewModel(IMusic m)
 {
     music = m;
 }