Пример #1
0
        /// <summary>
        /// Initialize the track.
        /// </summary>
        /// <param name="assetManager">the global Asset Manager</param>
        /// <param name="capi">The Core Client API</param>
        /// <param name="musicEngine"></param>
        public void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)
        {
            this.capi        = capi;
            this.musicEngine = musicEngine;

            OnPlayLists = OnPlayList.Split('|');
            for (int i = 0; i < OnPlayLists.Length; i++)
            {
                OnPlayLists[i] = OnPlayLists[i].ToLowerInvariant();
            }

            selectMinMaxHour();

            Location.Path = "music/" + Location.Path.ToLowerInvariant() + ".ogg";

            if (!initialized)
            {
                globalCooldownUntilMs = (long)(1000 * (AnySongCoolDowns[MusicFrequency][0] / 4 + rand.NextDouble() * AnySongCoolDowns[MusicFrequency][1] / 2));

                capi.Settings.Int.AddWatcher("musicFrequency", (newval) => { FrequencyChanged(newval, capi); });

                initialized = true;

                prevFrequency = MusicFrequency;
            }
        }
Пример #2
0
 /// <summary>
 /// Initialize the track.
 /// </summary>
 /// <param name="assetManager">the global Asset Manager</param>
 /// <param name="capi">The Core Client API</param>
 /// <param name="musicEngine"></param>
 public virtual void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)
 {
     this.capi        = capi;
     this.musicEngine = musicEngine;
     Location.Path    = Location.Path.ToLowerInvariant();
     if (!Location.Path.StartsWith("sounds"))
     {
         Location.WithPathPrefixOnce("music/");
     }
     Location.WithPathAppendixOnce(".ogg");
 }
Пример #3
0
        /// <summary>
        /// Initializes the music track
        /// </summary>
        /// <param name="assetManager">the global Asset Manager</param>
        /// <param name="capi">The Core Client API</param>
        public void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)
        {
            this.capi        = capi;
            this.musicEngine = musicEngine;
            PartsShuffled    = new MusicTrackPart[Parts.Length];

            for (int i = 0; i < Parts.Length; i++)
            {
                AssetLocation[] filesbefore = (AssetLocation[])Parts[i].Files.Clone();
                Parts[i].ExpandFiles(assetManager);
                if (filesbefore.Length > 0 && Parts[i].Files.Length == 0)
                {
                    capi.Logger.Warning("No files for cave music track part? Will not play anything (first file = {0}).", filesbefore[0]);
                }

                PartsShuffled[i] = Parts[i];
            }
        }
Пример #4
0
 public void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)
 {
     throw new NotImplementedException();
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerViewModel"/> class.
        /// </summary>
        /// <param name="hostScreen">
        /// The host screen.
        /// </param>
        /// <param name="engine">
        /// The engine.
        /// </param>
        /// <param name="settings">Settings.</param>
        public PlayerViewModel(IScreen hostScreen, IMusicEngine engine, ISettings settings)
            : base(hostScreen)
        {
            this.engine = engine;
            this.settings = settings;

            this.PauseCommand = new ReactiveCommand();
            this.PauseCommand.Subscribe(param => this.engine.Pause());
            this.PlayCommand = new ReactiveCommand();
            this.PlayCommand.Subscribe(param => this.engine.Play(false));
            this.NextSongCommand = new ReactiveCommand();
            this.NextSongCommand.Subscribe(param => this.engine.Next());
            this.PreviousSongCommand = new ReactiveCommand();
            this.PreviousSongCommand.Subscribe(param => this.engine.Previous());
            this.ChangeSongLocationCommand = new ReactiveCommand();
            this.SongEndedCommand = new ReactiveCommand();
            this.LoadSongsCommand = new ReactiveCommand();
            this.SongOpenedCommand = new ReactiveCommand();

            var screen = (IApplicationViewModel)this.HostScreen;
            screen.OnGlobalCommand += this.HandleGlobalCommand;

            // setup interactions
            this.ObservableForProperty(model => model.Volume).Subscribe(param =>
            {
                var newVolume = Math.Round(Convert.ToDecimal(param.Value), 1);
                this.settings.Volume = (float)newVolume;
                this.FormattedVolume = newVolume.ToString("P");
                //this.volume = (float)newVolume;

            });
            this.engine.ObservableForProperty(model => model.Current).Subscribe(param => this.UpdateCurrentPlayingInfo(param.Value));
            this.engine.ObservableForProperty(model => model.Elapsed).Subscribe(param =>
            {
                this.Elapsed = param.Value;
                this.TimelineLocation = this.Elapsed.TotalMilliseconds / this.TotalTime.TotalMilliseconds;
                this.FormattedElapsed = this.Elapsed.ToString("hh':'mm':'ss");
            });

            this.engine.ObservableForProperty(model => model.TotalTime).Subscribe(param =>
                {
                    this.TotalTime = param.Value;
                    this.FormattedTotalTime = this.TotalTime.ToString("hh':'mm':'ss");
                });

            this.SongsOnCollectionChanged(null, null);

            this.engine.Library.Songs.CollectionChanged += this.SongsOnCollectionChanged;

            // setup some default values
            this.Volume = Properties.Settings.Default.Volume;
            this.CurrentSongName = this.CurrentArtistName = this.CurrentAlbumName = "No Song Playing";
            this.FormattedElapsed = new TimeSpan().ToString("hh':'mm':'ss");
            this.FormattedTotalTime = new TimeSpan().ToString("hh':'mm':'ss");
        }