コード例 #1
0
        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("/"));
        }
コード例 #2
0
        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("/"));
            }
        }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
        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();
        }
コード例 #5
0
ファイル: discover_playlist.cs プロジェクト: hoangnhancs/C-
 private void passSongToParentForm(song slectedSong, bool addPlaylist = false)
 {
     if (PassSong != null)
     {
         PassSong.Invoke(this, new passSongToPlayBarEventArgs(slectedSong, addPlaylist));
     }
 }
コード例 #6
0
        // 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");
                }
            }
        }
コード例 #7
0
 void Makeinstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #8
0
ファイル: SongsController.cs プロジェクト: 5ju4ypzz/180518
        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());
        }
コード例 #9
0
        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);
                }
            }
        }
コード例 #10
0
        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));
        }
コード例 #11
0
ファイル: SongController.cs プロジェクト: 5ju4ypzz/180518
 public ActionResult Play(int id, song song)
 {
     song.song_view       = song.song_view + 1;
     db.Entry(song).State = EntityState.Modified;
     db.SaveChanges();
     return(View());
 }
コード例 #12
0
 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;
         }
     }
 }
コード例 #13
0
        // 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));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
        public ActionResult DeleteConfirmed(int id)
        {
            song song = db.songs.Find(id);

            db.songs.Remove(song);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #16
0
        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 }));
        }
コード例 #17
0
        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 }));
        }
コード例 #18
0
 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;
 }
コード例 #19
0
 public static void Backward()
 {
     if (waveOut != null)
     {
         ;
     }
     m_currentSong = null;
     changeState();
 }
コード例 #20
0
 public static void addSong(song Song)
 {
     if (playlist.Contains(Song))
     {
         return;
     }
     Song.startDownloading();
     playlist.Add(Song);
 }
コード例 #21
0
        public static void playSong(song Song)
        {
            int index = playlist.IndexOf(Song);

            if (playlist.IndexOf(Song) >= 0)
            {
                playSong(index);
            }
        }
コード例 #22
0
    // 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);
    }
コード例 #23
0
 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;
 }
コード例 #24
0
 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;
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 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));
 }
コード例 #27
0
        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;
        }
コード例 #28
0
        public IHttpActionResult Getsong(int id)
        {
            song song = db.songs.Find(id);

            if (song == null)
            {
                return(NotFound());
            }

            return(Ok(song));
        }
コード例 #29
0
        // 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));
        }
コード例 #30
0
        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));
        }