Author Topic: New and Improved Voice Music Player, very easy to use.  (Read 6667 times)

iceblast

  • Sr. Member
  • ****
  • Posts: 374
New and Improved Voice Music Player, very easy to use.
« on: September 27, 2018, 03:15:02 PM »
I've been meaning to get this put together and uploaded, but it just didn't happen.

A while back Pfeil created a music player. Well, I took what he did, and modified it. I'm not a programmer, but I was able to MacGyver this player out of what he gave me.

Music Player created by Pfeil, and modified by Iceblast.

This player is very easy to use. After you understand how it works.

After you have your database created, you can just say, Play Thriller, and it should start playing. Of course you have to have the song first, before that could happen. :)

I've made a Tutorial video, that should walk you through everything you should need to know to use it. I'm a bit long winded in it, sorry, :) but there was a lot to cover, and hopefully I didn't leave anything out.

Anyway, let me know what you think, and I hope people will enjoy it.

https://youtu.be/8CKIxTTUG10

Update: 1
 
You also need to download this taglib-sharp.dll file and place it in your VoiceAttack directory. Which should be c:\Program Files (x86)\VoiceAttack\ for most people.

Now I'm going to work on Pfeil's suggestions. I should be updating the profile in a bit.

Update: 2

Ok, Everything should be set, I even adjusted a few things. So, the profile has been replaced with a newer version. So, anyone that has downloaded the profile already, just download it again. Download and move the taglib-sharp.dll file to the VoiceAttack directory, and you should be set.

Just import the profile, hold F5 for 0.3 seconds to reset the profile, which will also create the app directories. After that, just start adding music files.

The Music Player supports (Mp3, Mp4, M4A, Wma, Wav, Aac, and Flac) files. Which means, it will start whatever player windows is assigned to play those file types.

Update: 3

Just replaced the profile with a newer version of it, that just cleans up some commands. Won't effect your database if you have already created one.
« Last Edit: September 28, 2018, 09:58:26 PM by iceblast »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: New and Improved Music Player, very easy to use.
« Reply #1 on: September 27, 2018, 04:53:09 PM »
A few thoughts:

Instead of creating a batch file and executing it to create a directory, you could use
Code: [Select]
Run application 'cmd' -with parameters '/C md "Music Player Backup"' (hidden)
to do so directly.

More info on /C and other cmd parameters here.


Just as plugins are required to be inside a directory to keep the Apps folder organized, I would recommend storing all files related to this profile in a subdirectory of the Apps folder instead.


I don't see any reference to taglib-sharp.dll in the instructions, which is required for the Add/Remove songs function
Reading tags is done using "tagLib sharp", which is a C# wrapper for tagLib.

I found a compiled copy of the latest version here.
Virustotal found nothing objectionable in that file, so it appears to be safe(though use at your own risk).

You only need "taglib-sharp.dll", which must be placed in your VoiceAttack installation directory(where VoiceAttack.exe is also located).


Because it's not currently possible to use tokens in the "Referenced Assemblies" textbox, you need to add the path to the installation folder manually to each inline function, unless you've used the default installation path.

E.G.
Code: [Select]
Microsoft.CSharp.dll;System.dll;System.Core.dll;System.Data.dll;System.Data.DataSetExtensions.dll;System.Deployment.dll;System.Drawing.dll;System.Net.Http.dll; System.Windows.Forms.dll;System.Xml.dll;System.Xml.Linq.dll;C:\Program Files(x86)\VoiceAttack\taglib-sharp.dll
If you've added it correctly, you should not see any errors when you click the "Compile" button.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: New and Improved Music Player, very easy to use.
« Reply #2 on: September 27, 2018, 05:18:12 PM »
Jeez, it's been so long, I totally forgot about the taglib-sharp.dll file.

I tried for the longest time to get VA to create a directory like that, but nothing worked, so I made it work a different way.

Now I have to see how I'm going to get a .dll file to go with this.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: New and Improved Music Player, very easy to use.
« Reply #3 on: September 27, 2018, 06:45:02 PM »
Pfeil it always amazes me, how you can find problems so fast.

Well, I think I've corrected everything you mentioned.

Thanks for checking it out for me.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: New and Improved Music Player, very easy to use.
« Reply #4 on: September 28, 2018, 02:02:30 PM »
A few more random observations:


In "Setup Music Player":

The second action is redundant:
Code: [Select]
Run application 'cmd' -with parameters '/C md "{VA_APPS}\Music Player\Music Player Backup"' (hidden)
Run application 'cmd' -with parameters '/C md "{VA_APPS}\Music Player"' (hidden)
The first action will create both folders(luckily, because otherwise the second action would have to be first, so the upper directory would exist before creating a subdirectory).


Code: [Select]
Begin Text Compare : [Folder] Equals '1'
End Condition
Begin Text Compare : [Folder] Equals '0'
End Condition
could be done more efficiently using
Code: [Select]
Begin Text Compare : [Folder] Equals '1'
Else
End Condition



In "Add Songs":

Code: [Select]
Begin Condition : Keyboard Key 'Ctrl' Is Pressed OR Keyboard Key 'Right Ctrl' Is Pressed
is redundant; "Ctrl" checks both control keys, whereas "Left Ctrl" and "Right Ctrl" are those specific keys only(I checked in case this was a workaround, both keys work as expected on my machine).


Instead of an inline function for each file type,
Code: [Select]
using System;
using System.Windows.Forms;
using System.IO;

public class VAInline
{
public void main()
{
System.Collections.Specialized.StringCollection returnList = null;
if (Clipboard.ContainsFileDropList())
{
returnList = Clipboard.GetFileDropList();
}
else
{
return;
}

string path = returnList[0];
VA.SetText("songPath", Path.GetDirectoryName(path));

string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.TopDirectoryOnly);
string output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("songNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.flac", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("FlacsongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.mp4", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("mp4songNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.m4a", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("m4asongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.wma", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("wmasongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.wav", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("wavsongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.aac", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("aacsongNames", output); //Put file name list into a VoiceAttack text value
}
}
*should* do it all. This is untested, but should work the same way as the separate ones.
This is still not the most efficient way to accomplish this, but only getting the clipboard contents once is an improvement.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: New and Improved Music Player, very easy to use.
« Reply #5 on: September 28, 2018, 07:20:35 PM »
Ok, I've changed everything you mentioned. I had noticed the CTRL one before, but I figured I might have done it for a reason, so I just left it. It didn't hurt anything. I've taken it out though.

Using your new code to combine all the inlines. I'm getting this error.

Inline function execution exception: Exception has been thrown by the target of an invocation. The directory name is invalid.

I'm not sure what directory it's talking about, and I don't see any obvious issues with the code, so maybe you'll understand what it means.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: New and Improved Music Player, very easy to use.
« Reply #6 on: September 28, 2018, 08:12:53 PM »
Inline function execution exception: Exception has been thrown by the target of an invocation. The directory name is invalid.

So it is.

That should be
Code: [Select]
using System;
using System.Windows.Forms;
using System.IO;

public class VAInline
{
public void main()
{
System.Collections.Specialized.StringCollection returnList = null;
if (Clipboard.ContainsFileDropList())
{
returnList = Clipboard.GetFileDropList();
}
else
{
return;
}

string path = returnList[0];
path = Path.GetDirectoryName(path);
VA.SetText("songPath", path);

string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.TopDirectoryOnly);
string output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("songNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.flac", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("FlacsongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.mp4", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("mp4songNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.m4a", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("m4asongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.wma", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("wmasongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.wav", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("wavsongNames", output); //Put file name list into a VoiceAttack text value

files = Directory.GetFiles(path, "*.aac", SearchOption.TopDirectoryOnly);
output = "";
foreach (string filePath in files)
{
output += Path.GetFileName(filePath) + "\r\n";
}
VA.SetText("aacsongNames", output); //Put file name list into a VoiceAttack text value
}
}

I didn't think to check whether "path" was used later on, so by not storing the result of
Code: [Select]
Path.GetDirectoryName(path);anything after that was using
Code: [Select]
returnList[0]instead.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: New and Improved Voice Music Player, very easy to use.
« Reply #7 on: September 28, 2018, 09:54:27 PM »
Yup, that did the trick, everything is working as it should, thanks for going over it again for me! :)