public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Author,Tuning,Genre,Rating,DurationTime,Minutes,Seconds")] MusicAsset musicAsset)
        {
            if (id != musicAsset.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(musicAsset);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MusicAssetExists(musicAsset.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(musicAsset));
        }
        /// <summary>
        /// Loads a music asset.
        /// </summary>
        /// <param name="path">Music file path.</param>
        /// <param name="useCache">Should we use cache for this asset to make future loadings faster?</param>
        /// <param name="useAssetsRoot">If true, path will be relative to 'AssetsRoot'. If false, will be relative to working directory.</param>
        /// <returns>Loaded music asset.</returns>
        public MusicAsset LoadMusic(string path, bool useCache = true, bool useAssetsRoot = true)
        {
            var ret = new MusicAsset(_BonEngineBind.BON_Assets_LoadMusic(ToAssetsPath(path, true, useAssetsRoot), useCache));

            ret.Path = path;
            return(ret);
        }
Example #3
0
 /// <summary>
 /// Play a music track.
 /// </summary>
 /// <param name="music">Music asset to play.</param>
 /// <param name="volume">Music volume.</param>
 /// <param name="loops">How many times to repeat music (-1 = endless, 0 = once, above 0 = number of times).</param>
 /// <param name="fadeInTime">Fade in time, in seconds (or 0 to play immediately).</param>
 public void PlayMusic(MusicAsset music, int volume = 100, int loops = -1, float fadeInTime = 0f)
 {
     if (music._handle == IntPtr.Zero)
     {
         throw new Exception("Can't play music asset with null handle!");
     }
     _BonEngineBind.BON_Sfx_PlayMusic(music._handle, volume, loops, fadeInTime);
 }
        public async Task <IActionResult> Create([Bind("ID,Title,Author,Tuning,Genre,Rating,DurationTime,Minutes,Seconds")] MusicAsset musicAsset)
        {
            if (ModelState.IsValid)
            {
                _context.Add(musicAsset);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(musicAsset));
        }
Example #5
0
        string IUploadMusicService.SaveAzureBlobInfoToDatabaseAndReturnKey(string blobName, string uri)
        {
            var blobResource = new MusicAsset()
            {
                Name = blobName,
                Uri  = uri
            };
            var key = musicAssetRepository.CreateAndReturnKey(blobResource);

            return(key);
        }
Example #6
0
        // load the scene
        protected override void Load()
        {
            // load fonts
            _font    = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false);
            _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false);

            // load font and music
            _music = Assets.LoadMusic("sfx/old city theme.ogg");
            _sound = Assets.LoadSound("sfx/phaserUp1.mp3");

            // start playing music
            Sfx.PlayMusic(_music);
        }
Example #7
0
        // load the scene
        protected override void Load()
        {
            // load fonts
            _font    = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false);
            _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false);

            // load font and music
            _music    = Assets.LoadMusic("sfx/old city theme.ogg");
            _altMusic = Assets.LoadMusic("sfx/forest.ogg");
            _sound    = Assets.LoadSound("sfx/phaserUp1.mp3");

            // start playing music via the music fader
            _musicFader = new MusicFader(null, 100, _music, 100);
        }
        public bool TogglePlayback(MusicAsset asset)
        {
            if (asset == null)
            {
                Asset = null;
                return(false);
            }

            if (Asset != asset)
            {
                Asset = asset;
                return(true);
            }

            if (Asset == asset && readyForPlayback)
            {
                //if (Player?.Rate == 0)
                //if (!IsPlaying)
                //{
                //	Player.Play ();

                //	//updateCommandCenterNowPlayingInfo ();

                //	return true;
                //}

                ////if (Player?.Rate == 1)
                //if (IsPlaying)
                //{
                //	Player.Pause ();

                //	//updateCommandCenterNowPlayingInfo ();

                //	return false;
                //}
            }

            return(false);
        }
Example #9
0
 void IMusicAssetRepository.Update(MusicAsset file)
 {
     dbContext.MusicAssets.Update(file);
     dbContext.SaveChanges();
 }
Example #10
0
 string IMusicAssetRepository.CreateAndReturnKey(MusicAsset file)
 {
     (this as IMusicAssetRepository).Create(file);
     return(file.Name);
 }
Example #11
0
 void IMusicAssetRepository.Create(MusicAsset file)
 {
     dbContext.MusicAssets.Add(file);
     dbContext.SaveChanges();
 }
Example #12
0
 private void ParseMusic()
 {
     _musics = _bundles["music"].LoadAsset <MusicAsset>("music");
 }
Example #13
0
 /// <summary>
 /// Play a music track.
 /// </summary>
 /// <param name="music">Music asset to play.</param>
 /// <param name="volume">Music volume.</param>
 /// <param name="loops">How many times to repeat music (-1 = endless, 0 = once, above 0 = number of times).</param>
 public void PlayMusic(MusicAsset music, int volume = 100, int loops = -1)
 {
     _BonEngineBind.BON_Sfx_PlayMusic(music._handle, volume, loops);
 }
Example #14
0
        /// <summary>
        /// Loads a music asset.
        /// </summary>
        /// <param name="filename">Music file path.</param>
        /// <param name="useCache">Should we use cache for this asset to make future loadings faster?</param>
        /// <returns>Loaded music asset.</returns>
        public MusicAsset LoadMusic(string filename, bool useCache = true)
        {
            var ret = new MusicAsset(_BonEngineBind.BON_Assets_LoadMusic(ToAssetsPath(filename, true), useCache));

            return(ret);
        }