Example #1
0
        public IHttpActionResult PutMP3(string id, MP3 mp3)
        {
            if (id != mp3.MP3ID)
            {
                return(BadRequest());
            }

            // Create a retrieve operation that takes a mp3 entity.
            TableOperation retrieveOperation = TableOperation.Retrieve <MP3Entity>(partitionName, id);

            // Execute the operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);

            // Assign the result to a MP3Entity object.
            MP3Entity updateEntity = (MP3Entity)retrievedResult.Result;

            updateEntity.Artist  = mp3.Artist;
            updateEntity.MP3Blob = mp3.MP3Blob;
            updateEntity.Title   = mp3.Title;

            // Create the TableOperation that inserts the mp3 entity.
            // Note semantics of InsertOrReplace() which are consistent with PUT
            // See: https://stackoverflow.com/questions/14685907/difference-between-insert-or-merge-entity-and-insert-or-replace-entity
            var updateOperation = TableOperation.InsertOrReplace(updateEntity);

            // Execute the insert operation.
            table.Execute(updateOperation);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public AddMp3Response AddMP3(AddMp3Request request)
        {
            int success = 0;

            var mp3 = new MP3()
            {
                Album       = request.Body.Album,
                AlbumArt    = Convert.FromBase64String(request.Body.AlbumArt), //The only reason for intermediary object, cannot send byte[] over service, has to be string
                Artist      = request.Body.Artist,
                Comments    = request.Body.Artist,
                Composer    = request.Body.Composer,
                Genre       = request.Body.Genre,
                Lyrics      = request.Body.Lyrics,
                SongTitle   = request.Body.SongTitle,
                TrackNumber = request.Body.TrackNumber,
                Year        = request.Body.Year,
                DateAdded   = DateTime.Now
            };

            using (var unitOfWork = new UnitOfWork(new MP3DbContext()))
            {
                unitOfWork.Mp3s.AddMp3(mp3);
                success = unitOfWork.Complete();
            }

            var response = new AddMp3Response((success != 0));

            return(response);
        }
Example #3
0
        public IHttpActionResult GetMP3(string id)
        {
            // Create a retrieve operation that takes a mp3 entity.
            TableOperation getOperation = TableOperation.Retrieve <MP3Entity>(partitionName, id);

            // Execute the retrieve operation.
            TableResult getOperationResult = table.Execute(getOperation);

            // Construct response including a new DTO as apprporiatte
            if (getOperationResult.Result == null)
            {
                return(NotFound());
            }
            else
            {
                MP3Entity mp3Entity = (MP3Entity)getOperationResult.Result;
                MP3       p         = new MP3()
                {
                    MP3ID   = mp3Entity.RowKey,
                    Artist  = mp3Entity.Artist,
                    MP3Blob = mp3Entity.MP3Blob,
                    Title   = mp3Entity.Title
                };
                return(Ok(p));
            }
        }
Example #4
0
 private void btnExtract_Click(object sender, EventArgs e)
 {
     if (!File.Exists(txtFileNameDec.Text))
     {
         MessageBox.Show("Fajli nuk eshte valid");
         txtFileNameDec.Text = "";
         btnExtract.Enabled  = false;
         btnResetDec.Enabled = false;
     }
     else
     {
         MP3            mp3 = new MP3(txtFileNameDec.Text);
         String         filePath;
         SaveFileDialog dialog = new SaveFileDialog();
         dialog.Filter = "Text FileName (.txt)|*.txt";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             filePath = dialog.FileName;
             StreamWriter msg    = new StreamWriter(filePath);
             string       strMsg = mp3.decoder(8);
             msg.Write(strMsg);
             txtExtractedText.Text = mp3.decoder(8);
             msg.Flush();
         }
     }
 }
 private void resetMP3Data()
 {
     pictureBox1.Image    = null;
     btnNextImage.Enabled = false;
     btnPrevImage.Enabled = false;
     curMP3 = null;
 }
Example #6
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     song = (MP3)e.Parameter;
     // Zo zou het zijn als we voor elke mp3 file een link hadden naar een online mp3 bestand nu gebruiken we 1 dummy mp3 bestand
     //mediaPlayer.Source = MediaSource.CreateFromUri(new Uri(song.SourceMP3));
     await Show_mp3();
 }
        public static void FourthDemo()
        {
            IMediaPlayer player = new MP3();

            player.Play("file.mp3");
            player = new FormatAdapter(new MP4());
            player.Play("file.mp4");
            player = new FormatAdapter(new VLC());
            player.Play("file.avi");
        }
Example #8
0
 // POST api/<controller>
 public IHttpActionResult Post([FromBody] MP3ViewModel mp3)
 {
     if (ModelState.IsValid)
     {
         var mp3ToCreate = new MP3();
         Mapper.Map(mp3, mp3ToCreate);
         _mp3service.Create(mp3ToCreate);
         return(Created(Url.Link("DefaultApi", new { id = mp3ToCreate.MP3ID }), mp3ToCreate));
     }
     return(BadRequest(ModelState));
 }
Example #9
0
        public IHttpActionResult Put([FromBody] MP3ViewModel mp3)
        {
            if (ModelState.IsValid)
            {
                var mp3ToUpdate = new MP3();
                Mapper.Map(mp3, mp3ToUpdate);
                _mp3service.Update(mp3ToUpdate);

                return(Ok(mp3ToUpdate));
            }
            return(BadRequest(ModelState));
        }
Example #10
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Default;
            Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;128;128;128m");
            Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;128;128;128m");
            Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;170;170;170m");
            Console.WriteLine("▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟☕⚾");

            MP3 mp3 = new MP3();

            //mp3.Decode($@"C:\Users\johnr\Downloads\MBR\warez.zip\Mp3\Contra.mp3");
            mp3.Decode($@"C:\Users\johnr\Documents\outputWave1-ABR-192.mp3");
            return;

            DirectoryInfo directoryInfo = new DirectoryInfo($@"c:\users\johnr\pictures");
            //foreach (var file in directoryInfo.GetFiles())
            //{
            //    if (new string[] { ".jpg", ".jpeg", ".jfif" }.Contains(file.Extension.ToLower()))
            //    {
            //        Console.WriteLine($"File: {file.FullName}");
            //        JPEG jpg = new JPEG(file.FullName);
            //    }
            //}

            //JPEG jpeg = new JPEG($@"c:\users\johnr\pictures\Calculator1.jpg");
            JPEG jpeg = new JPEG($@"c:\users\johnr\pictures\68518b2cd5485d576cc34355ffb0027d.jpg");

            return;

            GIF gif = new GIF($@"c:\users\johnr\pictures\Calculator1.gif");

            LZW lzw = new LZW();

            BMP bmp = new BMP($@"c:\users\johnr\pictures\3Sphere_2c.bmp");

            directoryInfo = new DirectoryInfo($@"c:\users\johnr\pictures");
            foreach (var file in directoryInfo.GetFiles())
            {
                if (file.Extension.ToLower() == ".png")
                {
                    Console.WriteLine($"File: {file.FullName}");
                    PNG png        = new PNG(file.FullName);
                    var header     = png.DataChunks.Where(x => x.ChunkType.ToLower() == "ihdr").FirstOrDefault();
                    var properties = (header.DataChunkRepresentation as PNG.DataChunk.HeaderChunkRepresentation).ToProperties(header.Data);
                    //if ((byte)properties["ColorType"].Value == 6)
                    //    Console.ReadLine();
                }
            }
            //Console.WriteLine("Enter PNG Filename:");
            //string path = Console.ReadLine();
            //PNG png = new PNG(path);
        }
Example #11
0
        public void Create(MP3 entity)
        {
            IList <Playlist> attachedPlaylists = new List <Playlist>();

            foreach (var playlist in entity.Playlist)
            {
                attachedPlaylists.Add(_uow.PlaylistRepository.GetAll().FirstOrDefault(x => x.PlaylistID == playlist.PlaylistID));
            }

            entity.Playlist.Clear();
            entity.Playlist = attachedPlaylists;

            _repository.Create(entity);
            Save();
        }
Example #12
0
        public void ConverstionTest()
        {
            using (MP3 k = new MP3())
            {
                k.Convert();
            }

            //Assert.IsTrue(File.Exists(this.testFile));

            //FileInfo acc = new FileInfo(this.testFile);
            //Console.WriteLine($"Filesize of conversion is {ByteSize.FromBytes(acc.Length).MegaBytes:0.##} MB ({ByteSize.FromBytes(acc.Length).MebiBytes:0.##} MiB)");

            //Assert.Greater(acc.Length, 1024);
            //Assert.AreEqual(".wav", acc.Extension);
        }
Example #13
0
        static void Main(string[] args)
        {
            //通过传参拿到父类
            Computer            cpu  = new Computer();
            MobileStorageDevice disk = new MobileDisk();
            MobileStorageDevice mp3  = new MP3();
            MobileStorageDevice up   = new UP();

            cpu.CpuRead(disk);
            cpu.CpuWrite(disk);
            cpu.CpuRead(mp3);
            cpu.CpuWrite(mp3);
            cpu.CpuRead(up);
            cpu.CpuWrite(up);
            Console.ReadKey();
        }
Example #14
0
        public void Update(MP3 entity)
        {
            var attachedEntity = _uow.Mp3Repository.Get(x => x.MP3ID == entity.MP3ID);
            IList <Playlist> attachedPlaylists = new List <Playlist>();

            attachedEntity.Playlist.Clear();
            foreach (var playlist in entity.Playlist)
            {
                attachedEntity.Playlist.Add(_uow.PlaylistRepository.GetAll().FirstOrDefault(x => x.PlaylistID == playlist.PlaylistID));
            }

            attachedEntity.Album  = entity.Album;
            attachedEntity.Artist = entity.Artist;
            attachedEntity.Title  = entity.Title;
            attachedEntity.Year   = entity.Year;

            Save();
        }
Example #15
0
        static void Main(string[] args)
        {
            AudioFile   audioFile = new MP3().Read("C:\\Users\\DEV0002\\Music\\Chill\\I Can't Decide");
            SoundPlayer player    = new SoundPlayer(AFR.ConvertToWav(audioFile));

            player.Load();
            long time = ((long)(audioFile.audioSize
                                / (audioFile.fileFormat.SampleRate * audioFile.fileFormat.nChannels
                                   * audioFile.fileFormat.BitsPerSample / 8)) * 1000) + 1000;
            Stopwatch stopwatch = new Stopwatch();

            player.Play();
            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds < time)
            {
                ;
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            //通过属性拿到父类
            Computer            cpu  = new Computer();
            MobileStorageDevice disk = new MobileDisk();
            MobileStorageDevice mp3  = new MP3();
            MobileStorageDevice up   = new UP();

            cpu.Ms = disk;
            cpu.CpuRead();
            cpu.CpuWrite();
            cpu.Ms = mp3;
            cpu.CpuRead();
            cpu.CpuWrite();
            cpu.Ms = up;
            cpu.CpuRead();
            cpu.CpuWrite();
            Console.ReadKey();
        }
Example #17
0
        public IHttpActionResult PostMP3(MP3 mp3)
        {
            MP3Entity mp3Entity = new MP3Entity()
            {
                RowKey       = getNewMaxRowKeyValue(),
                PartitionKey = partitionName,
                Artist       = mp3.Artist,
                MP3Blob      = mp3.MP3Blob,
                Title        = mp3.Title
            };

            // Create the TableOperation that inserts the mp3 entity.
            var insertOperation = TableOperation.Insert(mp3Entity);

            // Execute the insert operation.
            table.Execute(insertOperation);

            return(CreatedAtRoute("DefaultApi", new { id = mp3Entity.RowKey }, mp3Entity));
        }
        private void loadMP3(string Filename)
        {
            MP3 mp3 = new MP3(Filename);

            dragDropLabel.Text = mp3.ToString();

            //Try to find cover information, if embedded
            try
            {
                string FrameName;
                if (mp3.id3v2.MajorVersion == 2)
                {
                    FrameName = "PIC";
                }
                else
                {
                    FrameName = "APIC";
                }

                iNumOfImages = mp3.id3v2.Frames[FrameName].Count;
                if (iNumOfImages > 0)
                {
                    pictureBox1.Image  = ((ID3v2APICFrame)mp3.id3v2.Frames[FrameName][0].Data).Picture;
                    lblImageText.Text  = "Image 1 / " + iNumOfImages.ToString() + "\n";
                    lblImageText.Text += "Image Type: " + ((ID3v2APICFrame)mp3.id3v2.Frames[FrameName][0].Data).PictureType();
                    pictureBox1.Refresh();

                    btnPrevImage.Enabled = false;
                    if (iNumOfImages > 1)
                    {
                        btnNextImage.Enabled = true;
                    }
                    iCurImage = 0;
                }
            }
            catch (Exception ex)
            {
            }

            curMP3 = mp3;
        }
Example #19
0
        // change stock of a mp3
        static void StockChange()
        {
            Boolean changeStock = true;

            Console.WriteLine("");
            ShowStock();
            Console.WriteLine("");
            Console.WriteLine("Toets de ID van de Mp3 in");

            String ID    = Console.ReadLine();
            int    mp3ID = Convert.ToInt32(ID) - 1;

            if (mp3ID > MediaPlayers.Count || mp3ID < 0)
            {
                Console.WriteLine("ID bestaat niet");
                Console.ReadLine();
                return;
            }

            while (changeStock == true)
            {
                MP3 IDmp3 = MediaPlayers[mp3ID];

                Console.WriteLine("Dit is de voorraad voor de verandering {0}:", IDmp3.Stock);
                Console.WriteLine("Hoeveel moet er bij? Als het eraf moet doe er - voor.");

                String verandering = Console.ReadLine();
                int    nieuwAantal = Convert.ToInt32(verandering);

                if ((IDmp3.Stock = (IDmp3.Stock + nieuwAantal)) < 0)
                {
                    Console.WriteLine("Niet genoeg voorraad");
                }
                else
                {
                    MediaPlayers[mp3ID] = IDmp3;
                    Console.WriteLine("Nieuw voorraad: {0}", IDmp3.Stock);
                    changeStock = false;
                }
            }
        }
Example #20
0
        public MP3 Get(int id)
        {
            var data = _repository.Get(x => x.MP3ID.Equals(id));

            var filteredData = new MP3
            {
                MP3ID    = data.MP3ID,
                Title    = data.Title,
                Artist   = data.Artist,
                Album    = data.Album,
                Year     = data.Year,
                Playlist = data.Playlist.Select(y =>
                                                new Playlist
                {
                    PlaylistID = y.PlaylistID,
                    Name       = y.Name
                }).ToList()
            };

            return(filteredData);
        }
Example #21
0
        private async Task AddSong(ICommandContext context, object[] parameters, IServiceProvider services, CommandInfo info)
        {
            if (context.Message.Attachments.Count != 1)
            {
                await context.Channel.SendMessageAsync("Number of files incorrect");

                return;
            }

            IAttachment att = context.Message.Attachments.First();

            if (att.Filename.EndsWith(".mp3"))
            {
                string filePath = Path.Combine(services.GetService <ConfigHandler>().GetSongDir(), att.Filename).Replace(@"\", @"\\");
                webClient.DownloadFile(att.Url, filePath);
                MP3 mp3 = new MP3
                {
                    command = (string)parameters[0],
                    name    = filePath
                };
                try
                {
                    songList.Add(mp3.command, mp3.name);
                    using (StreamWriter sw = File.AppendText(services.GetService <ConfigHandler>().GetSongConf()))
                    {
                        sw.WriteLine(JsonConvert.SerializeObject(mp3));
                    }
                    await commands.RemoveModuleAsync(customModule);
                    await AddCommands();
                }
                catch (ArgumentException ex)
                {
                    await context.Channel.SendMessageAsync(ex.Message);

                    return;
                }
            }
        }
Example #22
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                Control      _control   = (sender as Control);
                FileTypeBase _processor = null;

                if (ConfirmAction(_control.Tag.ToString()))
                {
                    txtLog.Text += "Processing " + _control.Tag.ToString() + " files:\n\n";
                    txtLog.Refresh();
                    Application.DoEvents();

                    switch (_control.Name)
                    {
                    case "btnProcessEPub":
                        _processor = new EPub();

                        break;

                    case "btnProcessMP3":
                        _processor = new MP3();
                        break;

                    default:
                        return;
                    }
                    _processor.ProcessFolder(txtDirSource.Text, chkSubfolders.Checked, chkTra.Checked, txtLog);
                    txtLog.Text += "\n\n";
                    txtLog.Refresh();
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + "=================" + ex.ToString());
            }
        }
        // return: xml
        public ActionResult GetList(string id)
        {
            string serverPath = Server.MapPath("/Content/Music/" + id);

            if (!Directory.Exists(serverPath))
            {
                return(null);
            }

            string[] files = Directory.GetFiles(serverPath);

            playlist list = new playlist();

            list.title     = "flanker music playlist";
            list.info      = "http://fengzhichao.cn";
            list.trackList = new List <track>();

            foreach (string s in files)
            {
                if (s.ToLower().EndsWith(".mp3"))
                {
                    MP3 m = new MP3();
                    m.fileComplete = s;
                    MP3Helper.readMP3Tag(ref m);

                    track t = new track();
                    t.annotation = m.ArtistTitle;
                    int index = m.fileComplete.IndexOf("\\Content\\Music");
                    t.location = m.fileComplete.Substring(index).Replace('\\', '/');
                    t.info     = "";
                    t.image    = "";
                    list.trackList.Add(t);
                }
            }

            return(new XmlResult(list, list.GetType()));
        }
Example #24
0
        public static void LongPollListener()
        {
            //Default menu
            KeyboardBuilder key                 = new KeyboardBuilder();
            KeyboardBuilder key_linked          = new KeyboardBuilder();
            KeyboardBuilder key_unlinked        = new KeyboardBuilder();
            KeyboardBuilder genres_menu_general = new KeyboardBuilder();

            key.AddButton("Привязать аккаунт", null, agree);
            key.AddButton("Удалить привязку", null, decine);

            genres_menu_general.AddButton("House", null, def);
            genres_menu_general.AddButton("Vocal Deep", null, def);
            genres_menu_general.AddButton("Bass", null, def);
            genres_menu_general.AddButton("Psy-Trance", null, def);
            MessageKeyboard keyboard_genres_general = genres_menu_general.Build();

            MessageKeyboard keyboard = key.Build();

            key_linked.AddButton("Удалить привязку", null, decine);
            MessageKeyboard keyboard_linked = key_linked.Build();

            key_unlinked.AddButton("Привязать аккаунт", null, agree);
            MessageKeyboard keyboard_unlinked = key_unlinked.Build();

            HashSet <string> messages = new HashSet <string>();

Start:
            try
            {
Restart:
                while (true) // Бесконечный цикл, получение обновлений
                {
                    var api = new VkApi();

                    try
                    {
                        api.Authorize(new ApiAuthParams()
                        {
                            AccessToken = vkapiToken,
                        });
                    }
                    catch (Exception apiAuth) { Logging.ErrorLogging(apiAuth); Logging.ReadError(); goto Restart; }
                    longPoolServerResponse = new LongPollServerResponse();
                    longPoolServerResponse = api.Groups.GetLongPollServer(groupID);
                    BotsLongPollHistoryResponse poll = null;
                    try
                    {
                        poll = api.Groups.GetBotsLongPollHistory(
                            new BotsLongPollHistoryParams()
                        {
                            Server = longPoolServerResponse.Server, Ts = longPoolServerResponse.Ts, Key = longPoolServerResponse.Key, Wait = 25
                        });
                        pts = longPoolServerResponse.Pts;
                        if (poll?.Updates == null)
                        {
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.ErrorLogging(ex);
                        Logging.ReadError();
                        goto Restart;
                    }
                    foreach (var a in poll.Updates)
                    {
                        PostType postType = new PostType();
                        postType = PostType.Post;

                        if (a.Type == GroupUpdateType.WallPostNew)
                        {
                            if (a.WallPost.PostType == postType)
                            {
                                Uri    thumbUrl    = null; //Картинка для телеграма (музыки) 200 кб 90х90px
                                string postMessage = a.WallPost.Text;

                                //Скачать песни из вложений - отправить в телеграм
                                var allAttachments = a.WallPost.Attachments;
                                Console.WriteLine(string.Format("Новый пост: {0}, вложений: {1} ", postMessage, allAttachments.Count));

                                List <VkNet.Model.Attachments.Audio> audios = new List <VkNet.Model.Attachments.Audio>();
                                List <string> trackIds = new List <string>();

                                List <string> photoList2Load = new List <string>();

                                if (allAttachments.Count > 0)
                                {
                                    foreach (var attach in allAttachments)
                                    {
                                        var attid  = attach.Instance.Id;
                                        var attown = attach.Instance.OwnerId;

                                        string attachFullId = attown + "_" + attid;

                                        if (attach.Type == typeof(VkNet.Model.Attachments.Audio))
                                        //decode - download
                                        {
                                            trackIds.Add(attachFullId);
                                        }
                                        if (attach.Type == typeof(VkNet.Model.Attachments.Photo))
                                        {
                                            photoList2Load.Add(attachFullId);
                                        }
                                    }
                                }

                                List <VkNet.Model.Attachments.Photo> photoList = new List <VkNet.Model.Attachments.Photo>();
                                if (photoList2Load.Count > 0)
                                {
                                    try
                                    {
                                        api = new VkApi();
                                        //Get JPG Link
                                        api.Authorize(new ApiAuthParams()
                                        {
                                            Login         = vkLogin,
                                            Password      = vkPassword,
                                            ApplicationId = kateMobileAppID,
                                            Settings      = Settings.All
                                        });
                                        Console.WriteLine("VK User auth для фото!");
                                        Thread.Sleep(1000);

                                        var photos = api.Photo.GetById(photoList2Load, null, photoSizes: true);
                                        photoList = photos.ToList();

                                        if (photoList.Count > 0)
                                        {
                                            using (WebClient webClient = new WebClient())
                                            {
                                                Classes.Photo photoClass2Process = GetLargePhoto.GetLargeAndThumbUrl(photoList);
                                                List <Uri>    getLargePhoto      = photoClass2Process.largePhotoUris;
                                                thumbUrl = photoClass2Process.smallPhotoUri;

                                                foreach (var largePhotoLink in getLargePhoto)
                                                {
                                                    webClient.DownloadFile(largePhotoLink.AbsoluteUri.ToString(), Path.GetFileName(largePhotoLink.ToString()));
                                                    Classes.Photo photoClass = new Classes.Photo(Path.GetFileName(largePhotoLink.ToString()), postMessage);

                                                    Thread senderTGPhotoThread = new Thread(TelegramSender.SendPhoto2TG);
                                                    senderTGPhotoThread.Start(photoClass);
                                                    Thread.Sleep(100);
                                                }
                                                getLargePhoto.Clear();
                                            }
                                        }
                                    } catch (Exception sendPhotoEx) { Logging.ErrorLogging(sendPhotoEx); Logging.ReadError(); goto SendMusic; }
                                }
SendMusic:
                                if (trackIds.Count > 0)
                                {
                                    var services = new ServiceCollection();
                                    services.AddAudioBypass();
                                    api = new VkApi(services);

                                    try
                                    {
                                        api.Authorize(new ApiAuthParams()
                                        {
                                            Login         = vkLogin,
                                            Password      = vkPassword,
                                            ApplicationId = kateMobileAppID,
                                            Settings      = Settings.All
                                        });
                                        Console.WriteLine("VK User auth для музыки!");
                                    }
                                    catch (Exception apiEx) { Logging.ErrorLogging(apiEx); Logging.ReadError(); goto Restart; }
                                    audios = api.Audio.GetById(trackIds).ToList();

                                    foreach (var song in audios)
                                    {
                                        Uri audioUri = song.Url; //get URI

                                        if (audioUri != null)    //Если запись не по подписке или не запрещена
                                        {
                                            Uri    mp3link   = AudioDownloader.DecodeAudioUrl(audioUri);
                                            var    uriString = mp3link.ToString();
                                            string mp3Direct = mp3link.AbsoluteUri;
                                            int    divider   = mp3Direct.IndexOf('?');
                                            string clearLink = mp3Direct.Substring(0, divider);

                                            string mp3Title  = song.Title;
                                            string mp3Artist = song.Artist;

                                            string mp3name = mp3Title + " - " + mp3Artist + ".mp3";

                                            if (song.Duration < 720) //12 минут
                                            {
                                                MP3 mP;
                                                if (thumbUrl != null)
                                                {
                                                    mP = new MP3(clearLink, mp3name, mp3Title, mp3Artist, postMessage, thumbUrl);
                                                }
                                                else
                                                {
                                                    mP = new MP3(clearLink, mp3name, mp3Title, mp3Artist, postMessage);
                                                }
                                                Thread senderTGThread = new Thread(TelegramSender.SendMusic2TG);
                                                senderTGThread.Start(mP);
                                                Thread.Sleep(500);
                                            }
                                            else
                                            {
                                                Console.WriteLine("Слишком длинный трек >12 минут");
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }

                                //Clear after All
                                try
                                {
                                    if (trackIds.Count > 0)
                                    {
                                        trackIds.Clear();
                                    }
                                    if (photoList.Count > 0)
                                    {
                                        photoList.Clear();
                                    }
                                    if (photoList2Load.Count > 0)
                                    {
                                        photoList2Load.Clear();
                                    }
                                }
                                catch (Exception ex) { Logging.ErrorLogging(ex); Logging.ReadError(); }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.ErrorLogging(ex);
                Logging.ReadError();
                goto Start;
            }
        }
Example #25
0
        void Song_Click(object sender, ItemClickEventArgs e)
        {
            MP3 song = (MP3)e.ClickedItem;

            Frame.Navigate(typeof(PlayMusic), song);
        }
Example #26
0
 void saveMP3(MP3 mp3, string filename, wz_file f)
 {
     FileStream	save	= new FileStream(filename, FileMode.OpenOrCreate);
     f.stream.Position	= mp3.offset;
     save.Write(f.bStream.ReadBytes(mp3.length), 0, mp3.length);
     save.Close();
 }
Example #27
0
        static void Main(string[] args)
        {
            #region 接口例子
            //IFly[] flies = new IFly[3];
            //flies[0] = new Bird();
            //flies[1] = new Superman();
            //flies[2] = new Plane();

            //for (int i = 0; i < flies.Length; i++)
            //{
            //    flies[i].Fly();
            //}
            #endregion

            #region 接口题
            //Ostrich ostrich = new Ostrich();
            //Swan swan = new Swan();
            //Penguin penguin = new Penguin();
            //Parrot parrot = new Parrot();
            //Sparrow sparrow = new Sparrow();
            //Helicopter helicopter = new Helicopter();

            //ostrich.walk();
            //Console.WriteLine();
            //swan.Fly();
            //swan.walk();
            //swan.swim();
            //Console.WriteLine();
            //penguin.walk();
            //penguin.swim();
            //Console.WriteLine();
            //parrot.walk();
            //parrot.Fly();
            //Console.WriteLine();
            //sparrow.walk();
            //sparrow.Fly();
            //Console.WriteLine();
            //helicopter.Fly();


            #endregion

            #region 接口题二

            //Student student = new Student("小明");
            //Teacher teacher = new Teacher("老李");
            //HeadMaster headMaster = new HeadMaster("老王");

            //ICollectHomework[] list = new ICollectHomework[2] { student, teacher };

            //for (int i = 0; i < list.Length; i++)
            //{
            //    list[i].CollectHomework();
            //}
            //teacher.CollectHomework();

            #endregion

            #region 接口题三

            //Person person = new Person("老王");
            //Car car = new Car();
            //House house = new House();

            //IRegister[] list = new IRegister[3] { person, car, house };

            //for (int i = 0; i < list.Length; i++)
            //{
            //    list[i].Register();
            //}

            #endregion

            #region 接口题4,交互!
            Computer computer = new Computer();

            USB_Drive UDisk     = new USB_Drive();
            HardDisk  hardDisk  = new HardDisk();
            MP3       mp3       = new MP3();
            HardDisk  hardDisk1 = new HardDisk();

            UDisk.Connect(computer);
            hardDisk.Connect(computer);
            mp3.Connect(computer);
            hardDisk1.Connect(computer);

            UDisk.ReadData();
            hardDisk.ReadData();
            mp3.ReadData();
            hardDisk1.ReadData();
            #endregion
        }
Example #28
0
        static void Main(string[] args)
        {
            LoadSettings();

            if (args.Length > 0)
            {
                //Use comand prompt execution
                try
                {
                    string   _folder        = "";
                    bool     _recursive     = false;
                    bool     _renameFiles   = false;
                    string[] _fileTypes     = new string[2];
                    int      _fileTypeIndex = 0;
                    for (int _i = 0; _i < args.Length; _i++)
                    {
                        switch (args[_i].Replace("/", "").Replace("\\", "").Replace("-", "").ToLower())
                        {
                        case "d":     // directory
                            _folder = args[++_i];
                            break;

                        case "s":     // include subfolders
                            _recursive = true;
                            break;

                        case "r":     // rename files
                            _renameFiles = true;
                            break;

                        case "mp3":
                        case "epub":
                            _fileTypes[_fileTypeIndex++] = args[_i];
                            break;

                        case "?":
                            string _helpMessage = "Syntax: ktanc2e.exe -<switch>\n\n";
                            _helpMessage += "-d <folder>\t- source directory/folder\n";
                            _helpMessage += "-mp3\t\t- process MP3 files\n";
                            _helpMessage += "-epub\t\t- process epub files\n";
                            _helpMessage += "-s\t\t- include subdirectories\n";
                            _helpMessage += "-r\t\t- rename files\n";
                            _helpMessage += "-?\t\t- show this message\n\n";
                            _helpMessage += "Example:\t";
                            _helpMessage += "ktanc2e.exe -d c:\\MyDocs -epub -mp3 -s -r\n";
                            MessageBox.Show(_helpMessage);
                            Environment.Exit(0);
                            break;

                        default:
                            break;
                        }
                    }

                    if (String.IsNullOrEmpty(_folder) && (_fileTypes.Length <= 0))
                    {
                        args = new string[0];
                    }
                    else
                    {
                        foreach (string _fileType in _fileTypes)
                        {
                            FileTypeBase _processor = null;
                            switch (_fileType.ToUpper())
                            {
                            case "EPUB":
                                _processor = new EPub();
                                break;

                            case "MP3":
                                _processor = new MP3();
                                break;

                            default:
                                continue;
                            }
                            _processor.ProcessFolder(_folder, _recursive, _renameFiles, Console.Out);
                            MessageBox.Show("Finished Succesufy.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("==================================");
                    Console.WriteLine(ex.ToString());
                }
            }

            if (args.Length <= 0)
            {
                // Show GUI
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmMain());
            }
        }
Example #29
0
 public void MP3Play(string path)
 {
     MP3 mp3 = new MP3(path);
 }
Example #30
0
 public void reset()
 {
     readDataPointer = 0;
     mp3Reader.close();
     mp3Reader = new MP3(this.path);
 }
Example #31
0
        private void btnEncode_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtFileName.Text) && comboBox.SelectedIndex == 1)
            {
                MessageBox.Show("Fajli MP3 eshte invalid");
                txtFileName.Text = "";
                txtFileName.Focus();
            }

            else if ((!File.Exists(txtFileName.Text) || !File.Exists(txtFile.Text)) && comboBox.SelectedIndex == 0)
            {
                if (!File.Exists(txtFileName.Text) && File.Exists(txtFile.Text))
                {
                    MessageBox.Show("Fajli MP3 eshte invalid");
                    txtFileName.Text = "";
                    txtFileName.Focus();
                }

                else if (!File.Exists(txtFile.Text) && File.Exists(txtFileName.Text))
                {
                    MessageBox.Show("Fajli TXT eshte invalid");
                    txtFile.Text = "";
                    txtFile.Focus();
                }

                else if (!File.Exists(txtFile.Text) && !File.Exists(txtFileName.Text))
                {
                    MessageBox.Show("Fajlet jane invalide");
                    txtFile.Text     = "";
                    txtFileName.Text = "";
                    txtFileName.Focus();
                }
            }


            else
            {
                MP3    mp3      = new MP3(txtFileName.Text);
                String pathFile = txtFile.Text;
                int    zgjedhja = comboBox.SelectedIndex;
                String path     = "";
                if (zgjedhja == 0)
                {
                    FileStream txtfile      = new FileStream(pathFile, FileMode.Open, FileAccess.Read);
                    byte[]     b            = new byte[1024];
                    int        bytetelexuar = txtfile.Read(b, 0, b.Length);
                    path = Encoding.ASCII.GetString(b, 0, bytetelexuar);
                }
                else if (zgjedhja == 1)
                {
                    path = txtPlainText.Text;
                }
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "MP3 Audio (.mp3)|*.mp3";
                String filename;
                steganography.Message msg = new steganography.Message(path);
                mp3.stega(msg, 8);
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    mp3.toMP3(dialog.FileName);
                }
            }
        }
Example #32
0
    /// <summary>
    /// Read the file specified for this instance of FileReader
    /// </summary>
    public ReadStatus read()
    {
        this.reading = true;

        #if UNITY_ANDROID || UNITY_EDITOR

        // Check input
        if (this.path == null || this.path == "") {
            Debug.LogError("Path not specified!");
            this.reading = false;
            return ReadStatus.FAIL;
        } else if (this.format == FileFormat.OGG || this.format == FileFormat.ERROR) {
            Debug.Log("This format: " + this.format.ToString() + " is not supported yet");
            this.reading = false;
            return ReadStatus.UNSUPPORTED_FORMAT;
        }

        // Get audioclip according to file format
        switch (this.format) {
            case FileFormat.WAV:
                readWAV();
                break;
            case FileFormat.MPEG:
                mp3Reader = new MP3(this.path);
                this.frequency = mp3Reader.getFrequency();
                this.channels = mp3Reader.getChannels();
                this.mp3FrameSize = mp3Reader.getFrameSize();
                break;
            case FileFormat.RYT:
                readRytData();
                break;
        }

        #elif UNITY_IPHONE
        if (this.path == null || this.path == "") {
            Debug.LogError("Path not specified!");
            this.reading = false;
            return ReadStatus.FAIL;
        }

        reader = new IPhoneReader(this.path);
        this.frequency = reader.getFrequency();
        this.channels = reader.getChannels();
        #endif

        this.reading = false;
        return ReadStatus.SUCCESS;
    }
Example #33
0
        public void Run()
        {
            Print("Enter path: ", false);
            string Home = Console.ReadLine();

            Print("Enter extentions (i.e mp3, flac): ", false);
            string Extentions = Console.ReadLine();

            string[] ExtentionsArray = { "mp3", "flac", "m4a" };
            if (!string.IsNullOrWhiteSpace(Extentions))
            {
                ExtentionsArray = Extentions.ToLower().Replace(" ", "").Replace(".", "").Split(',');
            }

            List <string> AllFiles = ListAllFiles(Home);
            List <string> MP3Files = new List <string>();

            foreach (var File in AllFiles)
            {
                foreach (var Extention in ExtentionsArray)
                {
                    if (File.ToLower().EndsWith("." + Extention))
                    {
                        MP3Files.Add(File);
                    }
                }
            }

            List <string> FailedToFix = new List <string>();

            foreach (var MP3 in MP3Files)
            {
                try
                {
                    var    TagFile  = TagLib.File.Create(MP3);
                    var    Pictures = TagFile.Tag.Pictures;
                    string NewPath  = MP3.Remove(MP3.LastIndexOf('.')) + $".waaf.jpg";
                    foreach (var Picture in Pictures)
                    {
                        File.WriteAllBytes(NewPath, Picture.Data.Data);
                        string response = SingleExecute(Rooter("bin/jpegtran.exe"), "-o \"" + NewPath + "\" \"" + NewPath + "\"", true);
                        if (response != "")
                        {
                            FailedToFix.Add(MP3);
                        }
                        byte[] FixedCover = File.ReadAllBytes(NewPath);
                        Picture.Data = new TagLib.ByteVector(FixedCover, FixedCover.Length);
                    }

                    try { TagFile.Save(); PrintLine("Fixed " + MP3.Replace("\\", "/").Split('/').Last()); }
                    catch (Exception ex) { FailedToFix.Add(MP3); PrintLine("Failed to fix " + MP3.Replace("\\", "/").Split('/').Last()); PrintLine("Reason: " + ex.Message); }
                    int index = MP3Files.FindIndex(a => a == MP3) + 1;
                    Console.Title = "WAAF: " + index + "/" + MP3Files.Count + $" ({Math.Round(((double)index / MP3Files.Count) * 100, 2)}%)";
                    File.Delete(NewPath);
                }
                catch (Exception ex) { FailedToFix.Add(MP3); PrintLine("Failed to fix " + MP3.Replace("\\", "/").Split('/').Last()); PrintLine("Reason: " + ex.Message); }
            }
            Console.Clear();
            Print("Process finished ");
            if (FailedToFix.Count > 0)
            {
                PrintLine("with some problems: ");
            }
            else
            {
                PrintLine("with no problems.");
            }
            foreach (var Fail in FailedToFix)
            {
                Console.WriteLine("Failed to fix: " + Fail);
            }
        }