13 Replies - 12267 Views - Last Post: 26 September 2009 - 07:37 AM Rate Topic: -----

#1 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

mp3 player auto next playlist

Post icon  Posted 06 July 2009 - 07:58 PM

hi, im having trouble with some code for a mp3 player program. i want to have a listbox with file paths of mp3's (eg. "c:/users/quatz/music/song1.mp3, c:/users/quatz/music/song2.mp3" ect. in the list) and a windows media player control.
i have every thing else "down pat" but i want to find a way to autoplay the next song in the listbox once the first song has stopped playing

i am using vb2008 express

thankx

Is This A Good Question/Topic? 0
  • +

Replies To: mp3 player auto next playlist

#2 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: mp3 player auto next playlist

Posted 06 July 2009 - 08:13 PM

You want to look at player state changed to media ended. To play the next song may also require a timer and causing it to "click" play until it actually does. I've had problems with continuous play recently.
Was This Post Helpful? 0
  • +
  • -

#3 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 06 July 2009 - 08:35 PM

View Postmark.bottomley, on 6 Jul, 2009 - 07:13 PM, said:

You want to look at player state changed to media ended. To play the next song may also require a timer and causing it to "click" play until it actually does. I've had problems with continuous play recently.

i have tried the timer and play state codes but what happens is the tracks play 3 seconds then skip to the next track and play 3seconds over and over
i understand what your getting at but it just dosent like me
thanks for trying,
any more suggustions??
Was This Post Helpful? 0
  • +
  • -

#4 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: mp3 player auto next playlist

Posted 06 July 2009 - 11:05 PM

Can we see the code that you're working on :) Thanks.
Was This Post Helpful? 0
  • +
  • -

#5 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 06 July 2009 - 11:27 PM

View Postfirebolt, on 6 Jul, 2009 - 10:05 PM, said:

Can we see the code that you're working on :) Thanks.

hi firebolt, as i am not too experanced with vb2008 most of the code is alot jumbled up
but here it is
Public Class Form1

  
	Private Sub homemusicbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homemusicbut.Click
		musicpanel1.Visible = True
		mediaplayerpanel1.Visible = False

		cisconowpanel1.Visible = False
		settingspane1.Visible = False
	End Sub

	

	Private Sub musicpanel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles musicpanel1.Paint

	End Sub

  

	Private Sub settingsbackbut1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles settingsbackbut1.Click
		settingspane1.Visible = False
	End Sub

	Private Sub settingspane1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles settingspane1.Paint

	End Sub

   




	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		settingsmusicrootfoldertb.Text = My.Settings.musicrootfolder
		If My.Settings.setbypass = "set" Then
			Dim dir As New IO.DirectoryInfo(My.Settings.musicrootfolder)

			Label5.Text = dir.ToString
			'Holds files returned from dir object 
			Dim files As IO.FileInfo() = dir.GetFiles("*.mp3")

			Dim fileName As IO.FileInfo
			For Each fileName In files
				lstmusicfiles.Items.Add(fileName.FullName)
			Next
		Else
			MsgBox("Please set the root folder for music", MsgBoxStyle.Information, "Music Finder")
		End If

	End Sub

	Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles settingssavebut.Click
		My.Settings.musicrootfolder = settingsmusicrootfoldertb.Text
		My.Settings.setbypass = "set"
		My.Settings.Save()

	End Sub

	Private Sub ListFiles(ByVal strPath As String, ByVal Extention As String)
	End Sub


	Private Sub settingsscanbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles settingsscanbut.Click
		Dim dir As New IO.DirectoryInfo(My.Settings.musicrootfolder)

		Label5.Text = dir.ToString
		'Holds files returned from dir object 
		Dim files As IO.FileInfo() = dir.GetFiles("*.mp3")

		Dim fileName As IO.FileInfo
		For Each fileName In files
			lstmusicfiles.Items.Add(fileName.FullName)
		Next
	End Sub

	Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

	End Sub

	Private Sub lstmusicfiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstmusicfiles.SelectedIndexChanged

		mediaplayer.URL = lstmusicfiles.SelectedItem
		musicpanel1.Visible = False
		mediaplayerpanel1.Visible = True
		Timer1.Start()
	End Sub


	Private Sub mediabackbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mediabackbut.Click
		mediaplayerpanel1.Visible = False
	End Sub

   
	Private Sub homenowplaybut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homenowplaybut.Click
		mediaplayerpanel1.Visible = True
		musicpanel1.Visible = False
		cisconowpanel1.Visible = False
		settingspane1.Visible = False
	End Sub

	Private Sub homesettingsbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homesettingsbut.Click

		settingspane1.Visible = True
		mediaplayerpanel1.Visible = False
		musicpanel1.Visible = False
		cisconowpanel1.Visible = False

	End Sub

	Private Sub homeciscinowbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homecisconowbut.Click

		cisconowpanel1.Visible = True
		mediaplayerpanel1.Visible = False
		musicpanel1.Visible = False

		settingspane1.Visible = False
	End Sub

	Private Sub ciscobackbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ciscobackbut.Click
		cisconowpanel1.Visible = False
	End Sub

	Private Sub cnlbut_mix101_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cnlbut_mix101.Click
		mediaplayer.URL = "http://208.96.14.149/mix1011?MSWMExt=.asf"
		cisconowpanel1.Visible = False
		mediaplayerpanel1.Visible = True
	End Sub





	Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs)

	End Sub




  

	Private Sub musicbacbut1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles musicbacbut1.Click
		musicpanel1.Visible = False
	End Sub

	Private Sub mediaplayer_MouseDownEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MouseDownEvent) Handles mediaplayer.MouseDownEvent

	End Sub

   
	Private Sub mediaplayer_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles mediaplayer.PlayStateChange
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsBuffering Then
			mediaplayerhead.Text = "BUFFERING"
		End If
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsPaused Then
			mediaplayerhead.Text = "PAUSED"
		End If
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsPlaying Then
			mediaplayerhead.Text = "PLAYING"
		End If
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsReady Then
			mediaplayerhead.Text = "READY"
		End If
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsStopped Then
			mediaplayerhead.Text = "STOPPED"
		End If
		If mediaplayer.playState = WMPLib.WMPPlayState.wmppsTransitioning Then
			mediaplayerhead.Text = "CONNECTING"
		End If
		id3path.Text = mediaplayer.URL
		Dim objMP3V1 As New MP3ID3v1(mediaplayer.URL)
		If (objMP3V1.TagExists) Then
			id3album.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))
			id3artist.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist))
			id3year.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Year))
			id3track.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Title))

		End If

	End Sub

	Private Sub mediaplayer_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mediaplayer.Enter

	End Sub
End Class



if you would the compiled verson of what i have don just ask and i will zip it all up
Was This Post Helpful? 0
  • +
  • -

#6 zippp  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 76
  • Joined: 22-June 09

Re: mp3 player auto next playlist

Posted 06 July 2009 - 11:54 PM

Ok, this is easy and you do it just using a timer.

i guess that "mediaplayer" it's your player name, it's 10 am and i just woked up and can't see the code to good :)


So you add a timer with the interval set to 100.
The code for "AUTO NEXT" will be something like this.

If (mediaplayer.playState = WMPLib.WMPPlayState.wmppsStopped)  Then
			If (LISTBOX.SelectedIndex < LISTBOX.Items.Count - 1) Then
				lplst.SelectedIndex = lplst.SelectedIndex + 1
				mediaplayer.URL = songs(lplst.SelectedIndex)
				mediaplayer.Ctlcontrols.play()
		End If
End If



good luck.

PS: this is vb 2005 express, don't know how it's 2008 :) i have no idea, but i think it isn't too different.

This post has been edited by zippp: 06 July 2009 - 11:58 PM

Was This Post Helpful? 1
  • +
  • -

#7 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 07 July 2009 - 12:28 AM

View Postzippp, on 6 Jul, 2009 - 10:54 PM, said:

Ok, this is easy and you do it just using a timer.

i guess that "mediaplayer" it's your player name, it's 10 am and i just woked up and can't see the code to good :)


So you add a timer with the interval set to 100.
The code for "AUTO NEXT" will be something like this.

If (mediaplayer.playState = WMPLib.WMPPlayState.wmppsStopped)  Then
			If (LISTBOX.SelectedIndex < LISTBOX.Items.Count - 1) Then
				lplst.SelectedIndex = lplst.SelectedIndex + 1
				mediaplayer.URL = songs(lplst.SelectedIndex)
				mediaplayer.Ctlcontrols.play()
		End If
End If



omg thankyou soooooo much, it works great but i needed to tweek it a little bit
heres wat i have now
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		If (mediaplayer.playState = WMPLib.WMPPlayState.wmppsStopped) Then
			If (lstmusicfiles.SelectedIndex < lstmusicfiles.Items.Count - 1) Then
				lstmusicfiles.SelectedIndex = lstmusicfiles.SelectedIndex + 1
				mediaplayer.URL = lstmusicfiles.SelectedItem
				mediaplayer.Ctlcontrols.play()
			End If
		End If

	End Sub



good luck.

PS: this is vb 2005 express, don't know how it's 2008 :) i have no idea, but i think it isn't too different.

Was This Post Helpful? 0
  • +
  • -

#8 zippp  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 76
  • Joined: 22-June 09

Re: mp3 player auto next playlist

Posted 07 July 2009 - 03:05 AM

i`m glad i could help you. i`ve made a music player too but i didn't finish it till now...i`m lazy to work :)

can you post a print screen with your player?
Was This Post Helpful? 0
  • +
  • -

#9 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 08 July 2009 - 08:09 AM

g'day all
here are the screen shots
if you want some more creen shots just ask me


music selection panel

Attached Image


now playing panel

Attached Image


and a cool transparent feature

Attached Image


and thanks to all that helped i am very greatful.
Was This Post Helpful? 0
  • +
  • -

#10 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 08 July 2009 - 08:17 AM

now that this code problem is over i dont know what ill do..... any one have some ideas on what i could add to the player.

and yes....it can read id3 tags from the mp3's currentlu being played.

fyi. the Cisco now button opens a panel that has links to audio streams for australian radio stations
Was This Post Helpful? 0
  • +
  • -

#11 gdberry01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-September 09

Re: mp3 player auto next playlist

Posted 08 September 2009 - 10:02 AM

View Postquatz, on 8 Jul, 2009 - 07:17 AM, said:

now that this code problem is over i dont know what ill do..... any one have some ideas on what i could add to the player.

and yes....it can read id3 tags from the mp3's currentlu being played.

fyi. the Cisco now button opens a panel that has links to audio streams for australian radio stations


Okay, well, I'd love to see the code to read the MP3 Tag information. I just can't get it to work.
Was This Post Helpful? 0
  • +
  • -

#12 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 08 September 2009 - 03:20 PM

no problem, i will post the codes shortly.......
by the way, what exactly did you need to find in the id3 tags......im saying this to help me add and take parts of the code in and out

thanx
Was This Post Helpful? 0
  • +
  • -

#13 quatz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 06-July 09

Re: mp3 player auto next playlist

Posted 09 September 2009 - 03:03 AM

op the working part
i a new module paste this code
Imports System.IO
Module mp3idv1


	Public Class MP3ID3v1

		' Constructor
		Public Sub New(Optional ByVal Filename As String = "")
			MyBase.New()
			If (Filename <> "") Then Me.Filename = Filename
		End Sub

		' Genres
		Public Enum Genres As Byte
			Blues = 0
			ClassicRock = 1
			Country = 2
			Dance = 3
			Disco = 4
			Funk = 5
			Grunge = 6
			HipHop = 7
			Jazz = 8
			Metal = 9
			NewAge = 10
			Oldies = 11
			Other = 12
			Pop = 13
			RnB = 14
			Rap = 15
			Reggae = 16
			Rock = 17
			Techno = 18
			Industrial = 19
			Alternative = 20
			Ska = 21
			DeathMetal = 22
			Pranks = 23
			Soundtrack = 24
			EuroTechno = 25
			Ambient = 26
			TripHop = 27
			Vocal = 28
			JazzFunk = 29
			Fusion = 30
			Trance = 31
			Classical = 32
			Instrumental = 33
			Acid = 34
			House = 35
			Game = 36
			SoundClip = 37
			Gospel = 38
			Noise = 39
			AlternRock = 40
			Bass = 41
			Soul = 42
			Punk = 43
			Space = 44
			Meditative = 45
			InstrumentalPop = 46
			InstrumentalRock = 47
			Ethnic = 48
			Gothic = 49
			Darkwave = 50
			TechnoIndustrial = 51
			Electronic = 52
			PopFolk = 53
			Eurodance = 54
			Dream = 55
			SouthernRock = 56
			Comedy = 57
			Cult = 58
			Gangsta = 59
			Top40 = 60
			ChristianRap = 61
			PopFunk = 62
			Jungle = 63
			NativeAmerican = 64
			Cabaret = 65
			NewWave = 66
			Psychadelic = 67
			Rave = 68
			Showtunes = 69
			Trailer = 70
			LoFi = 71
			Tribal = 72
			AcidPunk = 73
			AcidJazz = 74
			Polka = 75
			Retro = 76
			Musical = 77
			RocknRoll = 78
			HardRock = 79
			None = 255
		End Enum

		' Frame types
		Public Enum FrameTypes As Byte
			Title = 0
			Artist = 1
			Album = 2
			Year = 3
			Track = 4
			Comment = 5
			Genre = 6
		End Enum

		' Filename
		Private mstrFilename As String
		Public Property Filename() As String
			Get
				Return mstrFilename
			End Get
			Set(ByVal Value As String)
				Dim objFile As File
				If (objFile.Exists(Value)) Then
					mstrFilename = Value
					Refresh()
				Else
					Throw New System.IO.FileLoadException( _
						"The specified file does not exist", Value)
				End If
			End Set
		End Property

		' TagExists
		Private mblnTagExists As Boolean
		Public ReadOnly Property TagExists() As Boolean
			Get
				Return mblnTagExists
			End Get
		End Property

		' Frame
		Private mobjFrame(7) As Object
		Public Property Frame(ByVal FrameType As FrameTypes)
			Get
				Return mobjFrame(FrameType)
			End Get
			Set(ByVal Value)
				mobjFrame(FrameType) = Value
			End Set
		End Property

		' Refresh (gets all tags from the specified file)
		Public Sub Refresh()

			' Declarations
			Dim strTag As New String(" ", 3)
			Dim strTitle As New String(" ", 30)
			Dim strArtist As New String(" ", 30)
			Dim strAlbum As New String(" ", 30)
			Dim strYear As New String(" ", 4)
			Dim strComment As New String(" ", 28)
			Dim bytDummy As Byte
			Dim bytTrack As Byte
			Dim bytGenre As Byte

			' Open the file
			Dim intFile As Integer = FreeFile()
			FileOpen(intFile, mstrFilename, OpenMode.Binary, _
				  OpenAccess.Read, OpenShare.LockWrite)

			' Gets length of file
			Dim lngLOF As Long = LOF(intFile)
			If (lngLOF > 128) Then

				' Check for the ID3v1 tag
				FileGet(intFile, strTag, lngLOF - 127, True)
				If (strTag.ToUpper <> "TAG") Then

					' No ID3v1 tag found
					mblnTagExists = False
					mobjFrame(0) = ""
					mobjFrame(1) = ""
					mobjFrame(2) = ""
					mobjFrame(3) = ""
					mobjFrame(4) = ""
					mobjFrame(5) = ""
					mobjFrame(6) = ""

				Else

					' ID3v1 tag found
					mblnTagExists = True

					' Read all frames from the file
					FileGet(intFile, strTitle)
					FileGet(intFile, strArtist)
					FileGet(intFile, strAlbum)
					FileGet(intFile, strYear)
					FileGet(intFile, strComment)
					FileGet(intFile, bytDummy)
					FileGet(intFile, bytTrack)
					FileGet(intFile, bytGenre)

					' Assign the frame content to the properties
					mobjFrame(0) = strTitle
					mobjFrame(1) = strArtist
					mobjFrame(2) = strAlbum
					mobjFrame(3) = strYear
					mobjFrame(4) = bytTrack
					mobjFrame(5) = strComment
					mobjFrame(6) = bytGenre

				End If
			End If

			' Close the file
			FileClose(intFile)

		End Sub

		' Update
		Public Sub Update()

			' Declarations
			Dim strTag As New String(" ", 3)
			Dim strTitle As New String(" ", 30)
			Dim strArtist As New String(" ", 30)
			Dim strAlbum As New String(" ", 30)
			Dim strYear As New String(" ", 4)
			Dim strComment As New String(" ", 28)
			Dim bytDummy As Byte
			Dim bytTrack As Byte
			Dim bytGenre As Byte

			' Open the file
			Dim intFile As Integer = FreeFile()
			FileOpen(intFile, mstrFilename, OpenMode.Binary, _
			   OpenAccess.ReadWrite, OpenShare.LockWrite)

			' Gets length of file
			Dim lngLOF As Long = LOF(intFile)
			If (lngLOF > 0) Then
				If (lngLOF > 128) Then

					' Check for an existing ID3v1 tag
					FileGet(intFile, strTag, lngLOF - 127)
					If (strTag.ToUpper <> "TAG") Then

						' No ID3v1 tag found, so just add one
						Seek(intFile, lngLOF)
						strTag = "TAG"
						FilePut(intFile, strTag)

					End If

					' Fix the length of the frames
					strTitle = LSet(mobjFrame(0), Len(strTitle))
					strArtist = LSet(mobjFrame(1), Len(strArtist))
					strAlbum = LSet(mobjFrame(2), Len(strAlbum))
					strYear = LSet(mobjFrame(3), Len(strYear))
					bytTrack = mobjFrame(4)
					strComment = LSet(mobjFrame(5), Len(strComment))
					bytGenre = mobjFrame(6)

					' Write the frames to the file
					FilePut(intFile, strTitle)
					FilePut(intFile, strArtist)
					FilePut(intFile, strAlbum)
					FilePut(intFile, strYear)
					FilePut(intFile, strComment)
					FilePut(intFile, bytDummy)
					FilePut(intFile, bytTrack)
					FilePut(intFile, bytGenre)

				End If
			End If

			' Close the file
			FileClose(intFile)

		End Sub

	End Class

End Module



and to get them on the form


 id3path.Text = mediaplayer.URL
		Dim objMP3V1 As New MP3ID3v1(mediaplayer.URL)
		If (objMP3V1.TagExists) Then
			id3album.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))
			id3artist.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist))
			id3year.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Year))
			id3track.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Title))
		Else
			id3album.Text = ""
			id3artist.Text = ""
			id3year.Text = ""
			id3track.Text = "Unknown Track"
		End If




id3album, artist, year and track are all labels
Was This Post Helpful? 0
  • +
  • -

#14 waveman  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 25-September 09

Re: mp3 player auto next playlist

Posted 26 September 2009 - 07:37 AM

View Postquatz, on 9 Sep, 2009 - 02:03 AM, said:

op the working part
i a new module paste this code
Imports System.IO
Module mp3idv1


	Public Class MP3ID3v1

		' Constructor
		Public Sub New(Optional ByVal Filename As String = "")
			MyBase.New()
			If (Filename <> "") Then Me.Filename = Filename
		End Sub

		' Genres
		Public Enum Genres As Byte
			Blues = 0
			ClassicRock = 1
			Country = 2
			Dance = 3
			Disco = 4
			Funk = 5
			Grunge = 6
			HipHop = 7
			Jazz = 8
			Metal = 9
			NewAge = 10
			Oldies = 11
			Other = 12
			Pop = 13
			RnB = 14
			Rap = 15
			Reggae = 16
			Rock = 17
			Techno = 18
			Industrial = 19
			Alternative = 20
			Ska = 21
			DeathMetal = 22
			Pranks = 23
			Soundtrack = 24
			EuroTechno = 25
			Ambient = 26
			TripHop = 27
			Vocal = 28
			JazzFunk = 29
			Fusion = 30
			Trance = 31
			Classical = 32
			Instrumental = 33
			Acid = 34
			House = 35
			Game = 36
			SoundClip = 37
			Gospel = 38
			Noise = 39
			AlternRock = 40
			Bass = 41
			Soul = 42
			Punk = 43
			Space = 44
			Meditative = 45
			InstrumentalPop = 46
			InstrumentalRock = 47
			Ethnic = 48
			Gothic = 49
			Darkwave = 50
			TechnoIndustrial = 51
			Electronic = 52
			PopFolk = 53
			Eurodance = 54
			Dream = 55
			SouthernRock = 56
			Comedy = 57
			Cult = 58
			Gangsta = 59
			Top40 = 60
			ChristianRap = 61
			PopFunk = 62
			Jungle = 63
			NativeAmerican = 64
			Cabaret = 65
			NewWave = 66
			Psychadelic = 67
			Rave = 68
			Showtunes = 69
			Trailer = 70
			LoFi = 71
			Tribal = 72
			AcidPunk = 73
			AcidJazz = 74
			Polka = 75
			Retro = 76
			Musical = 77
			RocknRoll = 78
			HardRock = 79
			None = 255
		End Enum

		' Frame types
		Public Enum FrameTypes As Byte
			Title = 0
			Artist = 1
			Album = 2
			Year = 3
			Track = 4
			Comment = 5
			Genre = 6
		End Enum

		' Filename
		Private mstrFilename As String
		Public Property Filename() As String
			Get
				Return mstrFilename
			End Get
			Set(ByVal Value As String)
				Dim objFile As File
				If (objFile.Exists(Value)) Then
					mstrFilename = Value
					Refresh()
				Else
					Throw New System.IO.FileLoadException( _
						"The specified file does not exist", Value)
				End If
			End Set
		End Property

		' TagExists
		Private mblnTagExists As Boolean
		Public ReadOnly Property TagExists() As Boolean
			Get
				Return mblnTagExists
			End Get
		End Property

		' Frame
		Private mobjFrame(7) As Object
		Public Property Frame(ByVal FrameType As FrameTypes)
			Get
				Return mobjFrame(FrameType)
			End Get
			Set(ByVal Value)
				mobjFrame(FrameType) = Value
			End Set
		End Property

		' Refresh (gets all tags from the specified file)
		Public Sub Refresh()

			' Declarations
			Dim strTag As New String(" ", 3)
			Dim strTitle As New String(" ", 30)
			Dim strArtist As New String(" ", 30)
			Dim strAlbum As New String(" ", 30)
			Dim strYear As New String(" ", 4)
			Dim strComment As New String(" ", 28)
			Dim bytDummy As Byte
			Dim bytTrack As Byte
			Dim bytGenre As Byte

			' Open the file
			Dim intFile As Integer = FreeFile()
			FileOpen(intFile, mstrFilename, OpenMode.Binary, _
				  OpenAccess.Read, OpenShare.LockWrite)

			' Gets length of file
			Dim lngLOF As Long = LOF(intFile)
			If (lngLOF > 128) Then

				' Check for the ID3v1 tag
				FileGet(intFile, strTag, lngLOF - 127, True)
				If (strTag.ToUpper <> "TAG") Then

					' No ID3v1 tag found
					mblnTagExists = False
					mobjFrame(0) = ""
					mobjFrame(1) = ""
					mobjFrame(2) = ""
					mobjFrame(3) = ""
					mobjFrame(4) = ""
					mobjFrame(5) = ""
					mobjFrame(6) = ""

				Else

					' ID3v1 tag found
					mblnTagExists = True

					' Read all frames from the file
					FileGet(intFile, strTitle)
					FileGet(intFile, strArtist)
					FileGet(intFile, strAlbum)
					FileGet(intFile, strYear)
					FileGet(intFile, strComment)
					FileGet(intFile, bytDummy)
					FileGet(intFile, bytTrack)
					FileGet(intFile, bytGenre)

					' Assign the frame content to the properties
					mobjFrame(0) = strTitle
					mobjFrame(1) = strArtist
					mobjFrame(2) = strAlbum
					mobjFrame(3) = strYear
					mobjFrame(4) = bytTrack
					mobjFrame(5) = strComment
					mobjFrame(6) = bytGenre

				End If
			End If

			' Close the file
			FileClose(intFile)

		End Sub

		' Update
		Public Sub Update()

			' Declarations
			Dim strTag As New String(" ", 3)
			Dim strTitle As New String(" ", 30)
			Dim strArtist As New String(" ", 30)
			Dim strAlbum As New String(" ", 30)
			Dim strYear As New String(" ", 4)
			Dim strComment As New String(" ", 28)
			Dim bytDummy As Byte
			Dim bytTrack As Byte
			Dim bytGenre As Byte

			' Open the file
			Dim intFile As Integer = FreeFile()
			FileOpen(intFile, mstrFilename, OpenMode.Binary, _
			   OpenAccess.ReadWrite, OpenShare.LockWrite)

			' Gets length of file
			Dim lngLOF As Long = LOF(intFile)
			If (lngLOF > 0) Then
				If (lngLOF > 128) Then

					' Check for an existing ID3v1 tag
					FileGet(intFile, strTag, lngLOF - 127)
					If (strTag.ToUpper <> "TAG") Then

						' No ID3v1 tag found, so just add one
						Seek(intFile, lngLOF)
						strTag = "TAG"
						FilePut(intFile, strTag)

					End If

					' Fix the length of the frames
					strTitle = LSet(mobjFrame(0), Len(strTitle))
					strArtist = LSet(mobjFrame(1), Len(strArtist))
					strAlbum = LSet(mobjFrame(2), Len(strAlbum))
					strYear = LSet(mobjFrame(3), Len(strYear))
					bytTrack = mobjFrame(4)
					strComment = LSet(mobjFrame(5), Len(strComment))
					bytGenre = mobjFrame(6)

					' Write the frames to the file
					FilePut(intFile, strTitle)
					FilePut(intFile, strArtist)
					FilePut(intFile, strAlbum)
					FilePut(intFile, strYear)
					FilePut(intFile, strComment)
					FilePut(intFile, bytDummy)
					FilePut(intFile, bytTrack)
					FilePut(intFile, bytGenre)

				End If
			End If

			' Close the file
			FileClose(intFile)

		End Sub

	End Class

End Module



and to get them on the form


 id3path.Text = mediaplayer.URL
		Dim objMP3V1 As New MP3ID3v1(mediaplayer.URL)
		If (objMP3V1.TagExists) Then
			id3album.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))
			id3artist.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist))
			id3year.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Year))
			id3track.Text = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Title))
		Else
			id3album.Text = ""
			id3artist.Text = ""
			id3year.Text = ""
			id3track.Text = "Unknown Track"
		End If




id3album, artist, year and track are all labels

hello i am newbie here and my project is same as yours

but i need help about id3 tags

i have a database and i want to do is when i add an mp3 file it gets the tags and passes to the database is it possible?
if yes, some help please this is my last part of my project...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1