/// <summary> /// Plays given song /// </summary> /// <param name="song">the song to be played</param> public void playCurrSong(Song song) { ISound sound = engine.Play2D(song.getPath()); sound.Volume = window.getVolume(); sound.setSoundStopEventReceiver(this); //set stop handler song.setSound(new Sound(sound)); }
/// <summary> /// Plays given song /// </summary> /// <param name="song">The song to be played</param> public void playCurrSong(Song song) { //Create the stream and play it using a channel int stream = Bass.BASS_StreamCreateFile(song.getPath(), 0, 0, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_STREAM_AUTOFREE); Bass.BASS_ChannelPlay(stream, false); //Set up the syncer, and update the song and the volume Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, syncer, IntPtr.Zero); song.setSound(new Sound(stream)); Bass.BASS_SetVolume(window.getVolume()); }
/// <summary> /// Updates the song label and the artist/album label /// Specifically, it parses the current song's path to get this information, and then calls the scroller thread to scroll the label /// </summary> private void updateLabels() { //parse path to get name, album, and artist String[] fields = currentSong.getPath().Split('/'); String nameFiltered = fields[fields.Length - 1].Replace(".mp3", "").Replace(".aac", "").Replace(".mp4", "").Replace(".m4a", ""); String nameTmp2 = System.Text.RegularExpressions.Regex.Replace(nameFiltered, matchPattern, ""); String name = System.Text.RegularExpressions.Regex.Replace(nameTmp2, matchPattern2, ""); String album = fields[fields.Length - 2]; String artist = fields[fields.Length - 3]; //update labels and notify scroller thread songLabel.Text = name; Monitor.Enter(labelHasChanged); Monitor.Enter(artistAlbumLabel); artistAlbumLabel.Text = artist + " - " + album; artistAlbumLabel.Refresh(); Monitor.Exit(artistAlbumLabel); labelHasChanged.setBoolean(true); Monitor.Pulse(labelHasChanged); Monitor.Exit(labelHasChanged); }
///<summary> ///For deep copying ///</summary> ///<param name="prevSong">the song that is deep copied</param> public Song(Song prevSong) { this.path = prevSong.getPath(); this.sound = prevSong.getSound(); }