public async Task <IActionResult> UploadSong(UploadSongViewModel model) { if (ModelState.IsValid) { user User = await dataBaseContext.users.Where(u => u.UserName == HttpContext.User.Identity.Name).Include(u => u.ArtistProfile).FirstOrDefaultAsync(); if (User.ArtistProfile != null && User.ArtistProfile.Songs.Where(s => s.Name == model.Name) == null) { string FilePath = @"\songs\"; await model.SongFile.CopyToAsync(new FileStream(webHostEnvironment.WebRootPath + FilePath + User.ArtistProfile.BandName + model.Name + "Song", FileMode.Create)); await model.SongLogo.CopyToAsync(new FileStream(webHostEnvironment.WebRootPath + FilePath + User.ArtistProfile.BandName + model.Name + "SongLogo", FileMode.Create)); song Song = new song() { Name = model.Name, Lyrics = model.Lyrics, SongFilePath = webHostEnvironment.WebRootPath + FilePath + User.ArtistProfile.BandName + model.Name + "Song", SongLogoPath = webHostEnvironment.WebRootPath + FilePath + User.ArtistProfile.BandName + model.Name + "SongLogo" }; User.ArtistProfile.Songs.Add(Song); await dataBaseContext.SaveChangesAsync(); } ModelState.AddModelError("Name", "Что-то пошло не так..."); return(Redirect("/")); } ModelState.AddModelError("Name", "Что-то пошло не так..."); return(Redirect("/")); }
public async Task <IActionResult> AddSongToAlbum(int SongId, int AlbumId) { artist Artist = dataBaseContext.users.Where(u => u.UserName == HttpContext.User.Identity.Name).FirstOrDefaultAsync().Result.ArtistProfile; if (SongId != 0 && AlbumId != 0 && Artist != null) { playlist Album = await dataBaseContext.playlists.Where(p => p.Id == AlbumId).FirstOrDefaultAsync(); if (Artist.Albums.Contains(Album)) { song Song = await dataBaseContext.songs.Where(s => s.Id == SongId).FirstOrDefaultAsync(); Album.Songs.Add(Song); await dataBaseContext.SaveChangesAsync(); return(Redirect("/")); } else { return(Redirect("/")); } } else { return(Redirect("/")); } }
private void PlayButton_Clicked(object sender, RoutedEventArgs e) { if (Songs.ItemsSource == null) { return; } if (currentSong == null) { currentSong = Songs.Items[0] as song; MyPlayer.Source = MediaSource.CreateFromUri(new Uri(currentSong.link)); Songs.SelectedIndex = 0; } if (_isPlaying) { MyPlayer.MediaPlayer.Pause(); PlayButton.Icon = new SymbolIcon(Symbol.Play); StatusText.Text = "Paused"; _isPlaying = false; } else { MyPlayer.MediaPlayer.Play(); PlayButton.Icon = new SymbolIcon(Symbol.Pause); StatusText.Text = "Now Playing: " + currentSong.name; _isPlaying = true; } }
public LinePractice(int selectedIndex, song Song) { InitializeComponent(); this.Song = Song; Thread t = new Thread(StopListenning); SoundCapture.SoundCaptureDevice device = null; SelectDeviceForm form = new SelectDeviceForm(); device = form.SelectedDevice; this.selectedIndex = selectedIndex; Clear(); t.Start(); bool finished = t.Join(TimeSpan.FromMilliseconds(300)); if (!finished) { t.Abort(); } if (device != null) { StartListenning(device); } Song.btn_LinePractice.Focus(); }
private void passSongToParentForm(song slectedSong, bool addPlaylist = false) { if (PassSong != null) { PassSong.Invoke(this, new passSongToPlayBarEventArgs(slectedSong, addPlaylist)); } }
// DELETE: api/Songs/{id} public string DeleteSong(string id) { song selSong = null; using (var ctx = new Assignment2Entities()) { //grabs song based on id selSong = ctx.songs .Where(s => (s.id).ToString() == id) .FirstOrDefault(); //returns error if song not found if (selSong == null) { return("Not a valid song"); } else { //deletes song ctx.songs.Remove(selSong); ctx.SaveChanges(); return("Success"); } } }
void Makeinstance() { if (instance == null) { instance = this; } }
public async Task <ActionResult> Edit([Bind(Include = "song_id,album_id,singer_id,author_id,song_name,song_path,song_lyric,song_datemodify")] song song, HttpPostedFileBase SUpload, int id) { if (ModelState.IsValid) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var _FileName = Path.GetFileName(file.FileName); var _Ext = Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/source/audio/"), _FileName + ""); song.song_path = "~/source/audio/" + _FileName; if (System.IO.File.Exists(path)) { var _NewName = Guid.NewGuid(); _FileName = _NewName.ToString(); path = Path.Combine(Server.MapPath("~/source/audio/"), _FileName + _Ext); song.song_path = "~/source/audio/" + _FileName + _Ext; } song.song_datemodify = DateTime.Now; SUpload.SaveAs(path); db.Entry(song).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } ViewBag.album_id = new SelectList(db.albums, "album_id", "album_name", song.album_id); ViewBag.author_id = new SelectList(db.authors, "author_id", "author_name", song.author_id); ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", song.singer_id); return(View()); }
async Task createPlaylist(IReadOnlyList <StorageFile> files) { playlistCount = files.Count; if (previousRegistered) { MediaControl.PreviousTrackPressed -= MediaControl_PreviousTrackPressed; previousRegistered = false; } if (nextRegistered) { MediaControl.NextTrackPressed -= MediaControl_NextTrackPressed; nextRegistered = false; } currentSongIndex = 0; playlist.Clear(); if (files.Count > 0) { // Application now has read/write access to the picked file(s) if (files.Count > 1) { MediaControl.NextTrackPressed += MediaControl_NextTrackPressed; nextRegistered = true; } // Create the playlist foreach (StorageFile file in files) { song newSong = new song(file); await newSong.getMusicPropertiesAsync(); playlist.Add(newSong); } } }
public IHttpActionResult Putsong(int id, song song) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != song.idsong) { return(BadRequest()); } db.Entry(song).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!songExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Play(int id, song song) { song.song_view = song.song_view + 1; db.Entry(song).State = EntityState.Modified; db.SaveChanges(); return(View()); }
private void playcliked() { if (listsongs == null) { result.Text = "List empty"; } else { if (currentSong == null) { currentSong = listsongs[0]; MyPlayer.Source = MediaSource.CreateFromUri(new Uri(listsongs[0].link)); } if (_isPlaying) { MyPlayer.MediaPlayer.Pause(); PlayButton.Icon = new SymbolIcon(Symbol.Play); StatusText.Text = "Paused"; _isPlaying = false; } else { MyPlayer.MediaPlayer.Play(); PlayButton.Icon = new SymbolIcon(Symbol.Pause); StatusText.Text = "Now Playing: " + currentSong.name; _isPlaying = true; } } }
// delete song from artist index page. public ActionResult ArtistDelete(int?id) { song song = db.songs.Find(id); SongsViewModel ss = new SongsViewModel(); ss.ToModel(song); return(View(ss)); }
public void DeleteElementRemovesExactlyThatElement() { song sng = this.ls.First(); this.ls.RemoveAt(this.ls.FindIndex(x => x.song_id == 1)); this.songLogic.Delete(sng); Assert.That(this.songLogic.GetAll(), Is.EqualTo(this.ls)); }
public ActionResult DeleteConfirmed(int id) { song song = db.songs.Find(id); db.songs.Remove(song); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AlbumDeleteConfirmed(int id) { song song = db.songs.Find(id); db.songs.Remove(song); db.SaveChanges(); //delete song and redirect to the album index. return(RedirectToAction("AlbumIndex", new { AlbumID = song.album_id, ArtistID = song.artist_id })); }
public ActionResult ArtistDeleteConfirmed(int id) { song song = db.songs.Find(id); db.songs.Remove(song); db.SaveChanges(); //redirect to artist index. return(RedirectToAction("ArtistIndex", new { ArtistID = song.artist_id })); }
private void playMusic2(int index) { currentSong = listsongs[index]; MyPlayer.Source = MediaSource.CreateFromUri(new Uri(currentSong.link)); MyPlayer.MediaPlayer.Play(); PlayButton.Icon = new SymbolIcon(Symbol.Pause); _isPlaying = true; StatusText.Text = "Now Playing: " + currentSong.name; }
public static void Backward() { if (waveOut != null) { ; } m_currentSong = null; changeState(); }
public static void addSong(song Song) { if (playlist.Contains(Song)) { return; } Song.startDownloading(); playlist.Add(Song); }
public static void playSong(song Song) { int index = playlist.IndexOf(Song); if (playlist.IndexOf(Song) >= 0) { playSong(index); } }
// Use this for initialization void Start() { GameObject song = GameObject.Find("song_pref(Clone)"); song songScript = song.GetComponent <song>(); speed = songScript.speed; initPos = transform.position; initDist = Mathf.Abs(initPos.x + initPos.y); }
public SelectSong(song Song, int select) { InitializeComponent(); this.Song = Song; btn_butterfly.Click += btn_butterfly_Click; btn_clap.Click += btn_clap_Click; btn_equal.Click += btn_equal_Click; btn_schoolBell.Click += btn_schoolBell_Click; this.select = select; }
public void ToModel(song s) { TrackNumber = s.track_number; ArtistID = s.artist_id; AlbumID = s.album_id; TrackName = s.name; SongID = s.id; AlbumName = s.album.albumName; ArtistName = s.artist.artistName; }
private void playMusic(int index) { currentSong = Songs.Items[index] as song; Songs.SelectedIndex = index; MyPlayer.Source = MediaSource.CreateFromUri(new Uri(currentSong.link)); MyPlayer.MediaPlayer.Play(); PlayButton.Icon = new SymbolIcon(Symbol.Pause); _isPlaying = true; StatusText.Text = "Now Playing: " + currentSong.name; }
private void setDataSite(song currentSong) { songName.Text = currentSong.name; if (currentSong.description != null) { songDescription.Text = currentSong.description; } ImageControl.Source = new BitmapImage(new Uri(currentSong.thumbnail, UriKind.Absolute)); imageHome.ImageSource = new BitmapImage(new Uri(currentSong.thumbnail, UriKind.Absolute)); }
async Task SetMediaElementSourceAsync(song Song) { var stream = await Song.File.OpenAsync(Windows.Storage.FileAccessMode.Read); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { mediaElement.SetSource(stream, Song.File.ContentType); }); MediaControl.ArtistName = Song.Artist; MediaControl.TrackName = Song.Track; }
public IHttpActionResult Getsong(int id) { song song = db.songs.Find(id); if (song == null) { return(NotFound()); } return(Ok(song)); }
// edit song from artist index public ActionResult ArtistEdit(int?id) { song ss = db.songs.Find(id); SongsViewModel sv = new SongsViewModel(); sv.ToModel(ss); //populate artist and album drop downs for the song sv.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName", ss.artist_id); sv.AlbumNames = new SelectList(db.albums, "id", "albumName", ss.album_id); return(View(sv)); }
public IHttpActionResult Postsong(song song) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.songs.Add(song); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = song.idsong }, song)); }