private void openStream(string url) { sound[PlayerController.MainChannel] = Bass.BASS_StreamCreateURL(url, 0, BASSFlag.BASS_STREAM_STATUS, null, IntPtr.Zero); tagInfo = new TAG_INFO(url); BASS_CHANNELINFO info = Bass.BASS_ChannelGetInfo(sound[PlayerController.MainChannel]); // display buffering for MP3, OGG... while (true) { long len = Bass.BASS_StreamGetFilePosition(sound[PlayerController.MainChannel], BASSStreamFilePosition.BASS_FILEPOS_END); if (len == -1) { break; // typical for WMA streams } // percentage of buffer filled float progress = ( Bass.BASS_StreamGetFilePosition(sound[PlayerController.MainChannel], BASSStreamFilePosition.BASS_FILEPOS_DOWNLOAD) - Bass.BASS_StreamGetFilePosition(sound[PlayerController.MainChannel], BASSStreamFilePosition.BASS_FILEPOS_CURRENT) ) * 100f / len; if (progress > 75f) { break; // over 75% full, enough } //Application.DoEvents(); System.Threading.Thread.Sleep(500); } }
public Tag(string path, bool isRadio) { TAG_INFO tagInfo = null; if (isRadio) { if (CommonInterface.IsValid(path, CommonInterface.URLPattern) && !CommonInterface.IsValid(path, CommonInterface.PathPattern2)) { tagInfo = new TAG_INFO(path); } } else { tagInfo = BassTags.BASS_TAG_GetFromFile(path); } if (tagInfo != null) { bitRate = tagInfo.bitrate; freq = tagInfo.channelinfo.freq; channels = ChannelsDict[tagInfo.channelinfo.chans]; artist = tagInfo.artist; album = tagInfo.album; genre = tagInfo.genre; title = tagInfo.title; year = tagInfo.year; this.path = path; fileName = System.IO.Path.GetFileName(path); image = tagInfo.PictureGetImage(0); error = false; } else { error = true; } }
public void PlayId(string id) { if (SoundInitialized) { DataProvider.currentlyPlayed = id; TagInfo = new TAG_INFO(); BassStream = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, BASSFlag.BASS_STREAM_AUTOFREE, DataProvider.bassStreamingProc, IntPtr.Zero); if (BassStream == 0) { BASSError err = Bass.BASS_ErrorGetCode(); throw new Exception("Cannot create stream: " + err.ToString()); } if (BassTags.BASS_TAG_GetFromFile(BassStream, TagInfo)) { // nop } else { Program.logging.addToLog("Cannot get tags for stream " + BassStream); } BassTimer.Start(); Bass.BASS_ChannelPlay(BassStream, false); } }
public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); if (tagInfo == null) { BitRate = 0; } else { BitRate = tagInfo.bitrate; Freg = tagInfo.channelinfo.freq; Channels = ChannelsDist[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; if (tagInfo.title == "") { Title = main.GetFileName(file); } else { Title = tagInfo.title; } Year = tagInfo.year; } }
private void Instance_StreamCreated(int channel) { this.Title = AudioControllerService.Current.TagInfo.title; this.Artist = AudioControllerService.Current.TagInfo.artist; this.Album = AudioControllerService.Current.TagInfo.album; this.StreamInfo = AudioControllerService.Current.ChannelInfo.ToString(); this.LengthMMSS = AudioControllerService.Current.GetTotalTimeString(); this.LengthInBytes = AudioControllerService.Current.LengthInBytes; TAG_INFO tagInfo = AudioControllerService.Current.TagInfo; if (tagInfo.PictureCount > 0) { //System.Drawing.Image image = AudioControllerService.Instance.TagInfo.PictureGetImage(0); this.PictureData = AudioControllerService.Current.TagInfo.PictureGet(0).Data; } else { this.PictureData = null; } SetVolume(volume); AudioControllerService.Current.SetPan(pan); RaisePropertyChanged(() => Stream); }
public void Play(string fileName, int vol = 100) { if (_handle != 0) { Stop(); _currentPosition = 0; OnTrackPositionProgressChanged(new TrackPositionProgrressChangedEventHandlerArgs() { PositionSeconds = _currentPosition }); } _handle = Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_DEFAULT); if (_handle != 0) { CurrentTrackLength = GetTrackLength(); TAG_INFO tagInfo = BassTags.BASS_TAG_GetFromFile(fileName); OnTrackChanged(new TrackChangedEventHandlerArgs() { TrackLength = CurrentTrackLength, Title = tagInfo.title, Album = tagInfo.album, Artist = tagInfo.artist, Image = tagInfo.PictureCount > 0 ? tagInfo.PictureGetImage(0): null, Year = tagInfo.year }); Bass.BASS_ChannelSetAttribute(_handle, BASSAttribute.BASS_ATTRIB_VOL, vol / 100f); Bass.BASS_ChannelPlay(_handle, false); _timer.Start(); } }
public void GetStationInfo() { TAG_INFO tagInfo = new TAG_INFO(URL); if (BassTags.BASS_TAG_GetFromURL(BassNetHelper.Stream, tagInfo)) { if (TrackArtist != tagInfo.artist && TrackName != tagInfo.title) { TrackArtist = tagInfo.artist; TrackName = tagInfo.title; TrackGenre = tagInfo.genre; if (tagInfo.bpm == "") { ChannelInfo = "Bitrate : " + tagInfo.bitrate; } else { ChannelInfo = "Bitrate : " + tagInfo.bitrate + "kBit/sec Bpm : " + tagInfo.bpm; } GetImageLink(SongImageLink); IsSongChanged = true; } else { IsSongChanged = false; } } else { TrackArtist = "No Data"; TrackName = "No Data"; } }
public void OnMetaUpdated(TAG_INFO tagInfo) { if (MetaUpdated != null) { MetaUpdated(tagInfo); } }
/// <summary> /// Считать альбомарт из файла /// если нет данных вернет null /// </summary> /// <param name="path"></param> /// <returns></returns> private Image GetAlbumArt(string path) { Image img = null; if (!path.StartsWith("http")) //если не поток { int _stream = Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN); if (_stream != 0)//если успешно { TAG_INFO tagInfo = new TAG_INFO(path); if (BassTags.BASS_TAG_GetFromFile(_stream, tagInfo)) { img = (Image)tagInfo.PictureGetImage(0); } } Bass.BASS_StreamFree(_stream);//освобождаем поток } else { if (RecordImages.ContainsKey(path)) { img = RecordImages[path]; } } return(img); }
public Song(string file) { TAG_INFO tag_inf = new TAG_INFO(); tag_inf = BassTags.BASS_TAG_GetFromFile(file); if (tag_inf.title == "") { Title = MainWindow.GetFileName(file); } else { Title = tag_inf.title; } AlbumName = tag_inf.album; ArtistName = tag_inf.artist; Year = tag_inf.year; Inf = tag_inf.bitrate + "KBps, " + tag_inf.channelinfo.chans; TagLib.File file_TAG = TagLib.File.Create(file); TrackNumber = file_TAG.Tag.Track.ToString(); int minutes = (int)file_TAG.Properties.Duration.TotalMinutes; int seconds = file_TAG.Properties.Duration.Seconds; string sec = seconds.ToString(); if (sec.Length == 1) { sec = "0" + sec; } Lenght = minutes.ToString() + ":" + sec; }
public void OnTrackTagInfoUpdated(TrackVM trackVM, TAG_INFO tagInfo) { if (TrackTagInfoUpdated != null) { TrackTagInfoUpdated(trackVM, tagInfo); } }
/// <summary> /// Recode the file /// </summary> /// <param name = "fileName">Initial file</param> /// <param name = "outFileName">Target file</param> /// <param name = "targetSampleRate">Target sample rate</param> public void RecodeTheFile(string fileName, string outFileName, int targetSampleRate) { int stream = Un4seen.Bass.Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_SAMPLE_FLOAT); TAG_INFO tags = new TAG_INFO(); BassTags.BASS_TAG_GetFromFile(stream, tags); int mixerStream = BassMix.BASS_Mixer_StreamCreate(targetSampleRate, 1, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_SAMPLE_FLOAT); if (BassMix.BASS_Mixer_StreamAddChannel(mixerStream, stream, BASSFlag.BASS_MIXER_FILTER)) { WaveWriter waveWriter = new WaveWriter(outFileName, mixerStream, true); const int length = 5512 * 10 * 4; float[] buffer = new float[length]; while (true) { int bytesRead = Un4seen.Bass.Bass.BASS_ChannelGetData(mixerStream, buffer, length); if (bytesRead == 0) { break; } waveWriter.Write(buffer, bytesRead); } waveWriter.Close(); } else { throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString()); } }
private void ReadInfoFromFile(Song sInfo) { TAG_INFO tagInfo = new TAG_INFO(sInfo.FileUrl); try { tagInfo = BassTags.BASS_TAG_GetFromFile(sInfo.FileUrl); sInfo.Size = string.Format("{0:F}M", new FileInfo(sInfo.FileUrl).Length / Math.Pow(1024, 2)); sInfo.Album = tagInfo.album; sInfo.Artist = tagInfo.artist; sInfo.Title = tagInfo.title; sInfo.PublicDate = tagInfo.year; sInfo.Company = tagInfo.publisher; sInfo.PicUrl = sInfo.Album == "" ? sInfo.FileName : sInfo.Album; sInfo.Duration = TimeSpan.FromSeconds(tagInfo.duration); if (tagInfo.PictureGetImage(0) != null) { SavePicToLocal(tagInfo.PictureGetImage(0), tagInfo.PictureGetType(0), sInfo.PicUrl); } else { SavePicToLocal(sInfo.FileUrl, sInfo.PicUrl); } } catch (Exception ex) { Debug.Write(ex.Message); } }
public TagInfo GetTagInfo(string pathToAudioFile) { TAG_INFO tags = bassServiceProxy.GetTagsFromFile(pathToAudioFile); if (tags == null) { return(new TagInfo { IsEmpty = true }); } int year; int.TryParse(tags.year, out year); TagInfo tag = new TagInfo { Duration = tags.duration, Album = tags.album, Artist = tags.artist, Title = tags.title, AlbumArtist = tags.albumartist, Genre = tags.genre, Year = year, Composer = tags.composer, ISRC = tags.isrc }; return(tag); }
public static void GetTagsFromCurrentURLStream(int stream) { TAG_INFO tagInfo = new TAG_INFO(); IntPtr tagsIntPtr = Bass.BASS_ChannelGetTags(stream, BASSTag.BASS_TAG_META); BassTags.BASS_TAG_GetFromURL(stream, tagInfo); }
/// <summary> /// 获取歌曲的tag信息,如专辑,歌手等等。 /// </summary> /// <param name="filePath">歌曲的路径</param> private void GetSongTagInformation(string filePath) { TAG_INFO tagInfo = new TAG_INFO(filePath); string str = tagInfo.album + Environment.NewLine + tagInfo.artist + Environment.NewLine + tagInfo.disc; MessageBox.Show(str); }
public TrackInfo(string filename) { Tags = BassTags.BASS_TAG_GetFromFile(filename); Duration = Tags.duration.ToString(); if (Tags == null) { throw new ArgumentException("File not valid!"); } }
public void AddTagInfo(TAG_INFO tag) { this.tag = new TAG_INFO() { artist = tag.artist, title = tag.title, album = tag.album, comment = tag.comment }; }
public SoundFile(string name = "new", double start = 0, double end = 0, TAG_INFO tag = null) { fileName = name; startTimeSeconds = start; endTimeSeconds = end; if (tag != null) { AddTagInfo(tag); } }
public TAG_INFO FillInputFileTags(string inputFileText) { m_inputFileTags = BassTags.BASS_TAG_GetFromFile(inputFileText); if (m_outputFiles == null) { var sound = new SoundFile(tag: m_inputFileTags); m_outputFiles = new OutputFiles(sound); } return(m_inputFileTags); }
public static TAG_INFO GetMP3Tags() { TAG_INFO tagInfo = new TAG_INFO(); var tag = Bass.BASS_ChannelGetTags(_stream, BASSTag.BASS_TAG_META); if (tag != null) { BassTags.BASS_TAG_GetFromURL(_stream, tagInfo); } return(tagInfo); }
/// <summary> /// Initializes a new instance of the <see cref="BassSongInfo"/> class. /// </summary> /// <param name="Path">The file's path to read</param> public BassSongInfo(string Path) : this() { #region Error checking if (!File.Exists(Path)) { throw new FileNotFoundException($"{Path} does not exists.", Path); } #endregion this.tagInfo = BassTags.BASS_TAG_GetFromFile(Path); }
/// <summary> /// Initializes a new instance of the <see cref="BassSongInfo"/> class. /// </summary> /// <param name="ChannelID">The BASS handle of the channel</param> /// <exception cref="ArgumentException">when ChannelID is 0</exception> public BassSongInfo(int ChannelID) : this() { #region Error checking if (ChannelID == 0) { throw new ArgumentException($"{nameof(ChannelID)} cannot be 0."); } #endregion this.tagInfo = new TAG_INFO(); BassTags.BASS_TAG_GetFromFile(ChannelID, this.tagInfo); }
public bool UpdateTitle(TAG_INFO tag, string url) { bool flag = this.Server.UpdateTitle(tag, url); if (flag) { this.RaiseNotification(BroadCastEventType.TitleUpdated, tag); return(flag); } this.RaiseNotification(BroadCastEventType.TitleUpdateError, tag); return(flag); }
static public PlaylistItem GetTags(string path) { TAG_INFO tagInfo = new TAG_INFO(path); if (!new System.Text.RegularExpressions.Regex("^(ftp|http)").IsMatch(path)) { string extension = new System.IO.FileInfo(path).Extension; if (!MainForm.supportedExts.Contains("*" + extension.ToLower())) { MessageBox.Show("File \"" + path + "\" is an unsupported file type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } int type = PlaylistItem.TYPE_STREAM_FILE; if (Bass.SupportedMusicExtensions.Contains("*" + extension)) { type = PlaylistItem.TYPE_MUSIC; } tagInfo = BassTags.BASS_TAG_GetFromFile(path); if (tagInfo == null) { return(new PlaylistItem("?", "?", "?", "?", path, type)); } else { return(new PlaylistItem(tagInfo.track, tagInfo.title, tagInfo.artist, tagInfo.album, path, type)); } } else { if (MainForm.stream != 0) { bool tagsAvailable = BassTags.BASS_TAG_GetFromURL(MainForm.stream, tagInfo); if (tagsAvailable) { return(new PlaylistItem(tagInfo.track, tagInfo.title, tagInfo.artist, tagInfo.album, path, PlaylistItem.TYPE_STREAM_URL)); } else { return(new PlaylistItem("?", "?", "?", "?", path, PlaylistItem.TYPE_STREAM_URL)); } } else { return(new PlaylistItem("?", "?", "?", "?", path, PlaylistItem.TYPE_STREAM_URL)); } } }
void init_tag() { try { _tagInfo = new TAG_INFO(_url); BASS_CHANNELINFO info = Bass.BASS_ChannelGetInfo(_Stream); if (info.ctype == BASSChannelType.BASS_CTYPE_STREAM_WMA) { isWMA = true; } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } }
public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = tagInfo.bitrate; Freq = tagInfo.channelinfo.freq; Channels = ChannelsDist[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; Title = (tagInfo.title == "") ? Vars.GetFileName(file) : tagInfo.title; Year = (tagInfo.year != "") ? tagInfo.year : DateTime.Now.Year.ToString(); Pictute = (tagInfo.PictureCount > 0) ? tagInfo.PictureGetImage(0) : Properties.Resources.misic; }
/// <summary> ///Теги для аудиофайла /// </summary> /// <param name="file"></param> public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); Artist = tagInfo.artist; if (tagInfo.title == "") { Title = Vars.GetFileName(file); } else { Title = tagInfo.title; } }
private void buttonPlay_Click(object sender, System.EventArgs e) { this.label1.Text = ""; Bass.BASS_StreamFree(_Stream); this.timerBPM.Stop(); // test PlugIns... // after additional Add-Ons have been loaded, // they will be supported in the standard BASS_StreamCreateFile methods if (_FileName != String.Empty) { // create the stream _Stream = Bass.BASS_StreamCreateFile(_FileName, 0, 0, BASSFlag.BASS_DEFAULT); // update the tags _tagInfo = new TAG_INFO(_FileName); if (BassTags.BASS_TAG_GetFromFile(_Stream, _tagInfo)) { // and display what we get this.textBoxAlbum.Text = _tagInfo.album; this.textBoxArtist.Text = _tagInfo.artist; this.textBoxTitle.Text = _tagInfo.title; this.textBoxComment.Text = _tagInfo.comment; this.textBoxGenre.Text = _tagInfo.genre; this.textBoxYear.Text = _tagInfo.year; } // play the stream if (_Stream != 0 && Bass.BASS_ChannelPlay(_Stream, false)) { //playing... BASS_CHANNELINFO info = new BASS_CHANNELINFO(); if (Bass.BASS_ChannelGetInfo(_Stream, info)) { // start the BPMCounter _bpm.Reset(info.freq); this.timerBPM.Start(); // display the channel info.. this.label1.Text = String.Format("Type={0}, Channels={1}, OrigRes={2}", Utils.BASSChannelTypeToString(info.ctype), info.chans, info.origres); } } else { MessageBox.Show(this, "Error: " + Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode())); } } }
private bool Bass() { Uri URL = new Uri(m_UrlStream); TAG_INFO tags = new TAG_INFO(); Un4seen.Bass.Bass.BASS_StreamFree(numberStream); numberStream = Un4seen.Bass.Bass.BASS_StreamCreateURL(URL.OriginalString, 0, BASSFlag.BASS_STREAM_STATUS, _downloadProc_, IntPtr.Zero); Un4seen.Bass.Bass.BASS_ChannelGetTags(numberStream, BASSTag.BASS_TAG_MUSIC_MESSAGE); BassTags.BASS_TAG_GetFromURL(numberStream, tags); if (m_Singer != tags.artist || m_Song != tags.title) { m_Singer = tags.artist; m_Song = tags.title; return(true); } return(false); }