[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Embedded Windows Media Player in VB 2010 - Need to extract name to textbox while playing

Posted on 2014-08-05
38
Medium Priority
?
657 Views
Last Modified: 2014-08-28
I have written over the years a VB home application that plays any of 100,000 vinyly records I've recorded to WAV files.  I have theses WAV files, Names, Albums Photos and other related data into my SQL database.  I use the Microsoft Player from the COM option to play one or a whole search query that I put in a DataGridView.  It all works great, but the Player's text of the song playing is hard to read.  
To solve the problem, I need to have code that interfaces with the Player so I can update a textbox with the Song Title that is currently being played by the player.
0
Comment
Question by:Earl Marshall
  • 19
  • 16
  • 3
38 Comments
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40259680
Can you please supply some (pertinent) part of your current code that runs when your application actually plays the .WAV file?

Also, what references are included in your project?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40260214
Here is some JS code from Microsoft's WMP Object reference site http://msdn.microsoft.com/en-us/library/windows/desktop/dd564057%28v=vs.85%29.aspx
<!-- Create an event handler for media change. -->
<SCRIPT FOR = "Player" EVENT = "mediaChange(Item)">
   // Test whether a valid currentMedia object exists.
   if (Player.currentMedia){
      // Display the name of the current media item.
      MediaName.innerHTML = Player.currentMedia.name;
   }
</SCRIPT>

Open in new window

0
 

Author Comment

by:Earl Marshall
ID: 40266330
craisin - here is the code that plays multiple WAV files from a DataGridViewSongs -  It works fine but need to update the textbox when play starts playing the next song that was loaded into the player.  Thanks in advance.

        '''''''''''''''''''''' play tracks in DataGridViewArtSongs

        Try
            Dim i, ct, TkCt As Integer
            Dim plList(700) As String
            Dim tmpl As String
            Dim Selt As Boolean = False

            ct = 0

            'indx = lstTracks2.SelectedIndex

            TkCt = Me.DataGridViewArtSongs.RowCount - 1

            If TkCt < 1 Then
                txtPlayerStatus.Text = "No Artist List"
                Exit Sub
            End If

            For i = 0 To TkCt
                If DataGridViewArtSongs.Rows(i).Selected = True Then
                    Selt = True
                    CompleteTrackPath = ""
                    ct = ct + 1
                    TrackName = ""
                    TrackName = TrackName & RTrim(LTrim(Me.DataGridViewArtSongs.Rows(i).Cells(4).Value))
                    ' FindSongTK()
                    If CompleteTrackPath = "" Then
                        CompleteTrackPath = RTrim(LTrim(Me.DataGridViewArtSongs.Rows(i).Cells(1).Value))
                    End If
                    txtSongData.Text = TrackName
                    txtSongData.Text = txtSongData.Text.Replace(".WAV", "")
                    txtSongData.Text = txtSongData.Text.Replace(".wav", "")
                    plList(ct) = CompleteTrackPath
                    tmpl = plList(ct)
                End If
            Next

            If Selt = False Then

                For i = 0 To TkCt
                    CompleteTrackPath = ""
                    ct = ct + 1
                    ' If Stylist = True Then
                    ' ct = ct + 1
                    ' DataGridViewArtSongs.CurrentRow(i, True)
                    ' plList(ct) = "c:\Song1\Stylist-Sound.wav"
                    ' End If
                    TrackName = ""

                    TrackName = TrackName & RTrim(LTrim(Me.DataGridViewArtSongs.Rows(i).Cells(4).Value))
                    ' FindSongTK()
                    If CompleteTrackPath = "" Then
                        CompleteTrackPath = RTrim(LTrim(Me.DataGridViewArtSongs.Rows(i).Cells(1).Value))
                    End If

                    txtSongData.Text = TrackName
                    txtSongData.Text = txtSongData.Text.Replace(".WAV", "")
                    txtSongData.Text = txtSongData.Text.Replace(".wav", "")

                    plList(ct) = CompleteTrackPath

                    tmpl = plList(ct)
                Next
            End If

            txtPlayerStatus.Text = "Playing Entire Artist List"

            Dim Playlist As WMPLib.IWMPPlaylist = AxWMP1.newPlaylist("Artist List", "")
            For i = 1 To TkCt + 1
                tmpl = plList(i)
                Playlist.appendItem(AxWMP1.newMedia(plList(i)))
                tmpl = plList(i)
            Next

            AxWMP1.currentPlaylist = Playlist
            AxWMP1.Ctlcontrols.play()

            TrackPlaying = "Playing Entire Artist List"
            'ShowPlaying()

            Application.DoEvents()

            For i = 0 To lstTracks2.Items.Count - 1
                lstTracks2.SetSelected(i, False)
            Next

            txtCompoundSearch.Visible = False

        Catch ex As Exception
            txtStatus1.Text = "Throw New Exception Invalid File Type"
        End Try
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40266534
OK - thx.

One way of course would be to name the physical "WAV" file as the nameof the song/tune. That usually makes things easier when using Windows Explorer to move files physically as well. Have you done that, or is that not a possibility?

Can you please give some sample data in your datagrid?

I will assume that you want to get the name of the item from the database rather than from the physical name of the file, but it is worth considering as an option since working with a filename is MUCH easier than relying on an manually updated database for the name of the item.

Working on it...standby
0
 

Author Comment

by:Earl Marshall
ID: 40266590
Craisin - My fault, let me make this a little clearer.  I have studio quality recordings from MY vinyls - over 100,000 tracks that takes up 6 terribytes on my Amazon Server Box.  So moving files is not an option.  I have some 40 tables in my SQL database that cross-referrences Album, Artist, Photos, etc. then finally the recordings themselves that are in the 'Tracks' SQL table.  For instance if I do a query from SQL database for an Artist or Group (I have 14,084 presently) it will populate Artist data text boxes, album Datagrid and Tracks Datagrid. I can then click on any of the items in the gridboxes for event I want to take place.  If i click on a track title if plays that song and displays all the other Artists that have also recorded that song (from my database).  Or I can click Play All Listed.  Then I read from the database from the table fields shown below.  The TkPath and TkTitleOnlyName fields are loaded into the Player and it starts playing them in the order I send to the Player.  The Player DOES displays the name of the track it is playing, but it is not easily read.  So, I have a textbox with large fonts that I want to sync with the player, or in other words update the textbox with the Track Title when the player starts playing the next track.  Thanks for your help.

SELECT TOP 1000 [TkIdNo]
      ,[TkPath]
      ,[TkArtName]
      ,[TkArtNo]
      ,[TkAlbName]
      ,[TkAlbNo]
      ,[TkName]
      ,[TkNameNo]
      ,[TkTrackNo]
      ,[TkArtName2]
      ,[TkArtNo2]
      ,[TkTitle]
      ,[TkTitleOnly]
      ,[TkWvLyricNo]
  FROM [sql_song1].[dbo].[WvTracks]
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40266607
Does the player play one song after another and so you want the text box to change when that happens
or does it ony play one track at a time when you click on a textbox (while we are at it, does clicking on any text box cause the player to play?)

Will the data in the filed txtTitleOnly be enough for your textbox display?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40266608
Does the method in my post (admitedley in Javascript) not work?
0
 

Author Comment

by:Earl Marshall
ID: 40266785
<!-- Create an event handler for media change. -->
<SCRIPT FOR = "Player" EVENT = "mediaChange(Item)">
   // Test whether a valid currentMedia object exists.
   if (Player.currentMedia){
      // Display the name of the current media item.
      MediaName.innerHTML = Player.currentMedia.name;
   }
</SCRIPT>

What event make this run.  I have not used Scripts in my code so don't know how to test it.  Thanks
0
 

Author Comment

by:Earl Marshall
ID: 40266801
Also note, this is an vb 2010 application 'form' not a web based application.  So, Javascript is not for Applications of this type?
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40267002
Java can be run within web applications in VB2010, but you are not running a web application, using a Forms application instead. That is what Iamworking on.

Please stand by....I unfortunately do not have any data to test against because I do not have your player
(what player are you using by the way?)
0
 

Author Comment

by:Earl Marshall
ID: 40268459
craisin - thanks for trying to help me on this.
I'm using the Microsoft default player that is available under Tools/Com Tabs with Visual Studio 2010 - under properties is shows version - 12.0.7601.18150
I'm taking my computer in today - no problems in 5 years, but I got an Adware bot that I can't get rid of.  So, may be a few days before I can respond and/or try your suggestions.
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40274303
OK thanks - just recovering from flu, hence the delay.

I can work on this thoroughly tomorrow afternoon and night, so should have something for you in 24 hours.

Thanks

Chris
0
 

Author Comment

by:Earl Marshall
ID: 40287073
craisin - I have my computer repaired and have it back now.  Hope your bout with the flu is over.  Hopefully we can continue where we left off.  Thanks - 2PartMedia - Marvin E Marshall
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40287083
Ok - thanks.

I have just fully recovered today (it was pretty bad).I will get back to work on it this afternoon (after lunch).
Iyt s now 12.30pm so I should have something worked out in about 5 hours. Stand by.....

Cheers
Chris
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40287135
Earl,

Can you please send a screen capture of your control named "DataGridViewArtSongs" (so I can get a feel for the column names and order) and also a screen capture of your applications "work area" so that I can get
a feeling for your text fields and other controls that may be on your dekstop.
If I just enter data from my own CD collection I gather that would also work, would it not, at my end?

Cheers
Chris
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40287667
Hi, Earl, (again)

I need the code for your procedure "ShowPlaying()" and (perhaps) ) " FindSongTK()" (although I notice you have commented out the "findsong" call.

I also really need the code for the procedure which starts the song playing after it ascertains which one you want. I will not utilize SQL at my end, what I really would like to do is populate the datagrid with some data (from ytracks I have on a CD which have been copied as mp3 to a PC folder).

Once I can get a song to play., I can investigate the reason for yoru problem with the font.

By the way, if all that is causing a problem is readability in one of the text bozes, there is a "font" property you can change, or is it tather that the data being placed into a particular textbox (which is the one gioving you a problem by the way?) is in an incorrect format to make it readable?

I have basically set up a project using the coe you have givne me sofar, adding 4 columns and a couple of rows to the gridbox (all blank). I need to basically populate the gridbox with the MMP3 files I have stored in my folder.

Lastly, what is "Stylist" (which I gather is a boolean) and what effect do that have on anything?

Cheers
Chris

Cheers
Chris
0
 

Author Comment

by:Earl Marshall
ID: 40288563
Very good.  I'll get to work on getting you the code, screen photo, grid shot.
0
 

Author Comment

by:Earl Marshall
ID: 40288815
craisin - I've attached 4 jpg's that cover what your requested.  I've noted that I have filed the complete program for and received a copyright on this software.  Here are the titles for the 4 attached jpg's.

2-Read_drives_2_SQL  (Reads my locally recorded content from my vinyl's, CD's, Cassettes and saved as 44,100 KHz - 32 bit or whatever quality desired of course)

1-Main-Display = This is the main screen that allows many type of searches, song, album, lyrics, artist.  The attached screen dump was generated from the word 'Bridge' in the lyric search.  As you can see that generated 787 songs (from the 100,000 plus WAV files I've recorded) that have 'bridge' in the lyrics.   Note that it automatically put 'Bridge Over Troubled Water" at that top of the list.  I clicked on that title, it then displayed that song data - writers, complete lyrics, and a list of all the artists/groups who have recorded this song - 39.  Then when you chose and click on one of the 39 listed, it starts and playing that version is usually less than 1 second.  In this case is BJ Thomas's version and upon this click it automatically brings up all data and recordings related to BJ Thomas I have in my SQL database.
Now, you could get the same results by search for BJ Thomas (on the right side of the screen) and it would do the same basically in reverse.  This particular screen shot shows 'Bridge Over Troubled Water' highlighted - in the DataGridViewArtSongs at the far right.  Upon clicking on that choice it uses the code shown on the attached DataGridViewArtSongs-Code.txt
Within that code you will see a call to PlayitWMP.  That code is shown in the attached PlayitWMP.txt
When you look at the Main-Display.jpg you will quickly note that the song title is shown at the bottom part of the player - note how faint and hard to read it is.  My textbox immediately below display it clearly.  However, if a click on play album, or playlist or artist list it will play many even hundreds of songs continually.  This is where I have a problem to update my textbox while the player goes to the next song I provided to the player from the source datagrid (or listbox of album tracks).
Yes, the Stylist boolean is to insert the sound of a stylist being set upon a vinyl.  This is for the purest who wants the flexibility of digital recordings, but what that unique sound at the beginning.
Actually, your point of changed the font size in the player, may be a simpler answer, but that only solves readability.  See, if I can intercept each title while playing, then I can update all the related textboxes plus displaying the lyrics of the song playing.  Currently the best I can do is having a manual click event on the textbox.
3-DataGridviewArtSongs-Code
4-PlayitWMP
Main-Display.JPG
Read-drives-2-SQL.JPG
DataGridViewArtSongs---Code.txt
PlayitWMP.txt
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40288997
Earl Marshall, like the music.

For the code, it would be better to copy and paste it into the comment text, select it, and click on 'Code' in the comment window. It will the appear like this (Word VBA) example:
Function GetCellText(cl As Cell) As String
    Dim rng As Range
    Set rng = cl.Range
    rng.MoveEnd wdCharacter, -1 'drop cell delimiter
    GetCellText = rng.Text
End Function

Open in new window

0
 

Author Comment

by:Earl Marshall
ID: 40289307
Graham, what triggers the event to know when the players switches to the next song?  That is when your function would apply.  Somehow the main program that is running needs to have the Player notify the main program so this function can work automatically.  Thanks
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289524
Thanks Earl,

Jpg's are fine, I can screen grab the code.

Working on the code now.....will advise as soon as breakthrough comes.

Cheers
Chris
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289534
Wow! Fancy application! (I'm impressed!)

What is the name (in the code) of the a textbox with the Song Title that is currently being played by the player
and what appears in it at the moment (that makes it hard to read?)

Cheers
Chris
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289552
I suspect the bit of code that "triggers" the move to the next song is in this loop found in
PlayitWMP()

Do 
    If (AxWMP1.playState = WMPPlayState.wmppsPlaying) Then
        'okay keep playing
         FileType = FileType
    Else
        MusicActive = False 'Flag that says music is no longer playing
        Exit Do
    End If
Loop

Open in new window


After exiting the loop when a song finishes, the code would then continue on processing from it's call to
"PlayiyWMP" in grid's "Click" Event, " DataGridViewArtSongs_CellContentClick"

I gather the next song would play because the next song would then be selected automatically somewhere (which wpould then trigger the "click" event again). I assume the selction of the next song in the grid is controlled by a "Setting" whether to "autoplay"
(i.e. auto-advance) or not.

Am I correct?

Cheers
Chris
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289579
Oops, just re-read your comments you had with the images, and you have actually answered my question.

I jext need to know the name of the field that is "hard to read".

Which one is it in the following screen grab? IThe only "fuzzy" bit I can see it the STOP button and
"Del Playlist Track"

Grab of part of screen when App is running
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289591
Try this first (in case it is just something simple).

The loop you have is very processor intensive since there is no "leeway" for other Windowws processes (such as updating the screen) to do their stuff within that loop. Add a "DoEvents" call in the loop and see if that improves things - if not, then we can keep looking elsewhere.

So the code should be:

Do 
    If (AxWMP1.playState = WMPPlayState.wmppsPlaying) Then
        'okay keep playing
          DoEvents     ' remove "Filetype = Filetype" which I assume was a "breakpoint"
    Else
        MusicActive = False 'Flag that says music is no longer playing
        Exit Do
    End If
Loop

Open in new window

0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289594
Looking further into it, I think that the text you are having trouble seeing might actually be the title line within the Player itself. This we cannot interfer with, but perhaps my point about the "DoEvents" will give the player time to update its screen quickly when the loop starts again.

Please note, where I stated simply" DoEvents" in previous comments I meant "Application.DoEvents" so the code should be:

Do 
    If (AxWMP1.playState = WMPPlayState.wmppsPlaying) Then
        'okay keep playing
        'but let Windows do some of its pending screen updates etc. first
         Application.DoEvents
    Else
        MusicActive = False 'Flag that says music is no longer playing
        Exit Do
    End If
Loop

Open in new window


A slightly more efficient way to write this is:
MusicActive = True '(this may not be required if the state will always be True   
'                                  coming into the loop).
Do while MusicActive   
    if AxWMP1.playState = WMPPlayState.wmppsPlaying then
        'the current track is still playing
        'but let Windows do some of its pending screen updates etc. first
         Application.DoEvents
    Else
        MusicActive = False         'This will cause the loop to ne exited
    End If
Loop

Open in new window



I strongly suspect now this is your problem,so I will not continue until you verify that the addition of the "Application.DoEvents" call does not fix things.



Cheers
Chris
0
 

Author Comment

by:Earl Marshall
ID: 40289647
craisin and Chris - Gee you are both really getting into it.  Tomorrow I'll have time to try these methods.  I have a lot going on else where with my code, so likely the loop even with Application.DoEvents will bog the program (processor) down.  I'm thinking if I put a timer inside the loop that would delay the loop for maybe 2 second intervals before checking the player, the timer would take up far less processing drain.  I do appreciate your fine help.
BTW - this application I will be using as an added feature on my new digital patent issued in May 2014.  You can get a sense of my new patent at my web site - www.song1.com
I'll be checking back tomorrow with my results.  Thanks.
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40289746
Hi...craisin and Chris are the same person!  LOL  :-)

Yes, I was considering a timer too. Your thoughts about processor "bog down"  though is a bit adrift.

Putting in a timer will actually "bog down" (albeir only slightly) your system in that the loop will suddenly run the timer event (i.e. DoEvents) before continuing,  but remember that the music is going to keep playing anyway
whether the loop has paused to do something or not!

so all that will happen is that your program will use a tiny bit of processing interrupt to run a "DoEvents" when it could simply run the DoEvents anyway without affecting the processing in your program.

So running the "DoEvents" each loop without any timer will not affect your program ( since I gather it is doing nothing at the time except playing the track through the MediaPlayer. Repeated DoEvents and will ensure that other programs running (including the Housekeeping cleanups of .NET and the Windows system chores) run at optimum speed.

In summary, forget the timer UNLESS your program is performing multi-threaded actions while the music is playing (such as running other SQL queries, writing reports or running OTHER timer events written into this particular program playing the music). I hope that clarifys why a timer may be a bad idea. (Do you have other timer events running in your App. and/or is it perdorming other threaded actions while the music is playing?)
Playing music does not take up any processing time (as far as I know).
 

Cheers
craisin (aka, Chris) - Melbourne, Australia
0
 

Author Comment

by:Earl Marshall
ID: 40290881
Chris, I send a group of songs to the player.  It starts playing the first song instantly (usually less than a second - I clip any leading no sound from the track before saving it to the hard drive).  Then once the player is active and playing I do all the other queries relating to that track - song data and lyrics, photos front and back from which I recorded the album, and one more query to look up all the other Artists/Groups who have also recorded that same song.  Right now I can only do that for the first song in the group.
So, i could do the look ups first then start the player with the suggested loop, but that would only work smoothly for the first song in the group.
Let me just play around to make sure the code you sent works, then we'll know if it's practical for my setup.  Ideally, would be for the player to update my textbox (txtPlayerStatus.text).  Then I could have an on event set in the textbox that would trigger the other related queries.

If there's a way, I think you'll find it.  Thanks so much.
BTW, my wife is an aussie and we (her's actually) have a home in Bundaberg, QLD and she was born in Melbourne (Frankston).  We now reside in Hideaway, TX - east of Dallas 80 miles (or 110 km or so) lol
0
 

Author Comment

by:Earl Marshall
ID: 40291177
Chris - I test putting in a do loop with the application.doevents and it allowed me to do other queries, etc. with no problem.  So, the do loop is fine to work from.  Graham, several days ago did post a js script that might give you something to work from.  I'm pasting the code area where I put the do loop and where the code will need to go to query the player for track change.  If we can get that code to work, it will answer the overall problem.  I could even put in  a little bong alerting track change and the listener could then see all the data relating to that song - lyrics, writer, etc and the other who have recorded it that are in the database.  Of course all that works now, but just for a single song.
here's the code... Notice the appenditem extension I use to load the player with multiple tracks.

            txtPlayerStatus.Text = "Playing Entire Artist List"

            Dim Playlist As WMPLib.IWMPPlaylist = AxWMP1.newPlaylist("Artist List", "")
            For i = 1 To TkCt + 1
                tmpl = plList(i)
                Playlist.appendItem(AxWMP1.newMedia(plList(i)))
                tmpl = plList(i)
            Next

            AxWMP1.currentPlaylist = Playlist
            AxWMP1.Ctlcontrols.play()

            TrackPlaying = "Playing Entire Artist List"
            'ShowPlaying()

            Application.DoEvents()


            For i = 0 To lstTracks2.Items.Count - 1
                lstTracks2.SetSelected(i, False)
            Next

            txtCompoundSearch.Visible = False

            Do
                ' Code goes here for checking player for change in title (next song)

                ' If newtrack Then

                '   Start related queries relating to that track (song)

                '  Then code of this type to check for track change - plus if player is finished

                '     <!-- Create an event handler for media change. -->
                '        <SCRIPT FOR = "Player" EVENT = "mediaChange(Item)">
                '            // Test whether a valid currentMedia object exists.
                '            if (Player.currentMedia){
                '               // Display the name of the current media item.
                '               MediaName.innerHTML = Player.currentMedia.name;
                '             }
                '        </SCRIPT>

                ' End If

                Application.DoEvents()
            Loop
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40291663
Earl, you already have the line ofcode that determines whether the music is still playing.
It isin one simple line:

"if AxWMP1.playState = WMPPlayState.wmppsPlaying then"

You have that in a loop, so provided you add the line "Application.DoEvents" in that loop,
as soon as the music stops it is ready to move on to the next line in the grid which your code can easily do.

Then you kick off the next track which will then eventually reach the loop again and wait until
"AxWMP1.playState = WMPPlayState.wmppsPlaying" is false.
(Keeps looping while true)

Does that not achieve what you want? Have you verified that the addition ofthe "Application.DoEvents" line
allows the system time to refresh the Players screen so that it's track information shows clearly on the screen?
Really, once that information is clear, your question has been answered.  :-)

Cheers
Chris
0
 

Author Comment

by:Earl Marshall
ID: 40291762
Chris - Ah, yes I see that now.  Where we got confused was I first posted the code for playing a single track.   However, I have another player code where I send the entire list of titles and paths to the player with the Playlist.appendItem(AxWMP1.newMedia(plList(i))) statement.
now I understand that this method is not necessary, simply send one track at a time and check for player true and false.
I'm confident this will work and will make a huge improvement of automatically displaying all related data upon starting a new track.
I won't close it out yet as I want to confirm to you that I have it working.... especially since you've spent so much time on this which I really appreciate.  Hopefully, this will help others with player issues.
Did you read the part in my last post of my wife being from Frankston?
Thanks Marvin E Marshall
0
 
LVL 13

Accepted Solution

by:
Chris Raisin earned 2000 total points
ID: 40291853
Thats great Earl (or is it Marvin? LOL)

Yes, I did read about your wife's "origins",  but it was 4.15 am here by the time I finished working on your stuff (as well as on a major "Bridge" program I am writing and I was really half asleep, so I forgot to mention how lucky you are to have an aussie in the family. :-)

I actually play Bridge (the card game, which I love, and teach)  out at Frankston ocassionally.
....Hmmm....So your wife is now "hiddenaway" in Hideaway, eh?
(Sounds like a cue for a song!) :-)

I also worked in Bundaberg for a while when I was working for National Australia Bank. (Left them after they retrenched me after 30 years service).

In fact, I lived in Queensland for 20 years before I returned back to Melbourne (again, the bank transferred me around a bit back in those days). All my family have lived in Brisbane and Toowoomba for over 40 years and I will probably retire to Toowoomba in another two years when I turn 65. (Toowoomba is much like Melbourne with cooler weather which I prefer). The temperatures in Brisbane were too hot for me in Summer, but, mind you, Melbourne last siummer (December) had 15 days with temperatures exceeding 40 degrees celcius every day. (Whew)

AAhhh..memories!

Back to programming.....I certainly hope that the addition of one single line "Application.DoEvents" in the loop will now allow the system to clearly write the track on the Players display.

Just one question, though......

The display you now have (with the track showing in a text box in a nice bright color) is rather attractive....why not leave it there anyway, even when the Media Player shows its characters in a clear manner? (Just a thought). People with poor eyesight (not that you are one of those) might appreciate the larger lettering.

Is this application just for your use, or are you going to make it a commercial "goer"? It looks really good
and serious collectors of music would probably love it. (If it sells big, remember me and allocate approprate commission....LOL  :-)

Cheers
Chris

P.S.  Send a "G'Day" to your wife for me.....  :-)
0
 

Author Comment

by:Earl Marshall
ID: 40291856
Chris - IT WORKS PERFECTLY!!!!
After loading the PlayLst array with one or x number of track paths - CompleteTrackPath -  
I pass PlayLst to the sub shown below.  However, I should point out that the WMPPlayState after AxWMP1.Ctlcontrols.play() is false, even after do.events.  So, I put in a Force Loop that keeps checking until it becomes true.  Then the main loop runs until it's false whereby I feed it the next track path in the PlayLst array.

        Dim ln As Integer = 0
        Dim i As Integer = 0
        Dim whr As Integer = 0
        Dim ct As Integer = 0
        Dim GetDataAll As Boolean = True

Again:
        ct = ct + 1
        CompleteTrackPath = PlayLst(ct)
        If CompleteTrackPath = "" Then
            Exit Sub
        End If
        ln = Len(CompleteTrackPath)
        CompleteTrackPath = Microsoft.VisualBasic.LTrim(RTrim(CompleteTrackPath))
        CompletePathParse()   ' parse complete path for title, etc.
        ln = Len(CompleteTrackPath)
        WaveFile = CompleteTrackPath
        TrackPlaying = WaveFile
        ln = Len(WaveFile)
        ShowPlaying()

        ' Find out what type of file you want to play and play it.
        Select Case New IO.FileInfo(WaveFile).Extension.ToLower
            Case ".wma", ".mp3"
                AxWMP1.URL = WaveFile
                AxWMP1.Ctlcontrols.play()
                FileType = "axWMP"
            Case ".wav"
                ' MyBase.Play(Location)
                FileType = "WAV"
                AxWMP1.URL = WaveFile
                AxWMP1.Ctlcontrols.play()
                ' AxWMP1.Ctlcontrols.currentPosition.

                Application.DoEvents()

                Do
                    Application.DoEvents()
                    If (AxWMP1.playState = WMPPlayState.wmppsPlaying) Then
                        'okay keep playing
                        MusicActive = True
                        If GetDataAll = True Then

                            '               insert queries related to track playing

                            txtCompoundSearch.Visible = False
                            GetDataAll = False
                        End If
                    Else
                        If MusicActive = False Then
                            GoTo forceloop
                        End If
                        MusicActive = False
                        GetDataAll = True
                        GoTo again
                    End If

ForceLoop:
                Loop

            Case Else
                txtStatus1.Text = "Invalid File Type or Length" & " - " & ln.ToString
        End Select
        txtStatus1.Text = ""

    End Sub

Cheers to you Chris !!!
Now to click on solved.
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40291859
Great!

You are actually checking the value of "WMPPlayState.wmppsPlaying" though (which is stored in the play state).

WMPPlayState.wmppsPlaying = True when the player is playing, and becomes False when the Player stops playing.

What you have done, though is correct.

So, did the "Application.DoEvents" give the system time to clarify the lettering of the tracks name on the player's display? If so, then that is in fact the solution to your original question.
The added code you have supplied actually probably fixes another area in your code that may not have been functioning correctly.

Please confirm that Application.DoEvents fixed the "blurred" track display problem (and thanks for an enjoyable wander down memory lane and an interesting programming problem!  :-)
0
 

Author Closing Comment

by:Earl Marshall
ID: 40291870
Chris - just read your reply relating to mentioning my wife's origin and home in Bundaberg.  Amazing that both of you are from Melbourne and you lived in Bundaberg - small world.  Actually, my wife Robyn and you are exactly the same age.  

I have thought about marketing this program, but more likely it will be used as a Super App that will come along with the SSD or Thumb Drive that will have 10's of thousands of studio quality music which is needed as part of my new digital media patent - 8,719.946.  It will need to be converted to smart phones.  I'm looking for a programmer to do that now.
My new invention that I just received a patent, is my second major patent.  The first was the Prepaid/Postpaid phone card technology which I have 3 patents with the first one being filed for in May of 1989.  I've learned a lot about the do's and don'ts  of the patent business.  It was because of my phone patents is why we moved back to the USA to get them enforced.

When we get back to Australia, perhaps we can meet.  www.song1.com has my full contact details, but I'm assuming you have my Expert-Exchange email - marvin@omega2011.com
I haven't play Bridge in years, but do love the game.  
Thanks again Chris - it's been a pleasure working with you and I'm sure I'll be an Expert-Exchange customer for quite some time.
Marvin Earl Marshall
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40291886
Thanks Marvin...my pleasure.

By the way, it is a good idea not to put email addresses in text boxes on Expert Exchange (or anywhere) because they will be picked up by some scanning programs and you may end up with lots of junk mail.

When you quote an email address, best to do it like this: marvinATomega2011DOTcom.
That fools the "trawlers".

We "Experts" do not have your email address (it is hidden to everyone except the administrators).
Yes, it would be good to play bridge some time.

And...Wow!....I am friends now with a famous inventor! (just looked at your website).......
one day your name will be up there with Edison the way you are churning things out!

Have a look at my website for matters relating to bridge and to get my contact details :
http://www.ecbc.net.au
:-)

All the best
Chris
0
 

Author Comment

by:Earl Marshall
ID: 40291903
Good advice on the email addresses.  That's worth another 500 points!
I'm sure my wife Robyn will want to compare notes and memories.  She talks all the time about some Facebook page where all the people from Frankston compare memories, share old photos of the town, the famous pier, business, etc.
Now let me test this out RobynATomega2011dotcom.   We just looked at your bridge web site - WOW back - you are an expert - next thing I might read is you beat Sean Connery..lol  Maybe you already have come to think about it.
Well better sign off.  Marvin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question