Example #1
0
        protected bool SaveTrack(Models.Track track, XOUNDContext ctx)
        {
            Mp3FileReader reader = new Mp3FileReader(track.AudioFile.InputStream);

            track.DurationMinutes = reader.TotalTime.Minutes;
            track.DurationSeconds = reader.TotalTime.Seconds;

            ctx.Tracks.Add(track);
            ctx.SaveChanges();

            byte[] fileData = null;
            using (var binaryReader = new BinaryReader(track.AudioFile.InputStream))
            {
                fileData = binaryReader.ReadBytes(track.AudioFile.ContentLength);
            }

            Models.TrackFile file = new Models.TrackFile()
            {
                TrackID = track.ID,
                Track   = fileData
            };

            ctx.TrackFiles.Add(file);
            ctx.SaveChanges();

            return(true);
        }
Example #2
0
        protected bool SaveTrack(Models.Track track, XOUNDContext ctx)
        {
            Mp3FileReader reader = new Mp3FileReader(track.AudioFile.InputStream);

            track.DurationMinutes = reader.TotalTime.Minutes;
            track.DurationSeconds = reader.TotalTime.Seconds;

            ctx.Tracks.Add(track);
            ctx.SaveChanges();

            byte[] fileData = null;
            using (var binaryReader = new BinaryReader(track.AudioFile.InputStream))
            {
                fileData = binaryReader.ReadBytes(track.AudioFile.ContentLength);
            }

            Models.TrackFile file = new Models.TrackFile()
            {
                TrackID = track.ID,
                Track = fileData
            };

            ctx.TrackFiles.Add(file);
            ctx.SaveChanges();

            return true;
        }