PDA

View Full Version : Help with my Media Player please!


TheProg
10-11-2007, 03:19 AM
right, so I got this app that will be used to play all my music via my internal 1Gb network.

I need help with the following:

I opted for a listbox for listing the availible music, but I have had to split it up into 1 listbox that shows all albums as soon as the page is shown, and when you double-click an album title, it ( should ) display ONLY the tracks in the selected album ( so far, it lists ALL tracks ) and when a track is double-clicked on, I would like it to play using the default player ( on my system its Real Player)

code for On Show:

tblAlbums = File.Find("AutoPlay\\Music", "", true, true)

if tblAlbums ~= nil then
for i,v in tblAlbums do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename..tblSplitPath.Extension, tblSplitPath.Filename..tblSplitPath.Extension)
end
end

Code for Listbox 1 ( Album list )

tblTracks = File.Find("AutoPlay\\Music", "*.MP3", true, false)

if tblTracks ~= nil then
for i,v in tblTracks do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox2", tblSplitPath.Filename..tblSplitPath.Extension, tblSplitPath.Filename..tblSplitPath.Extension)
end
end

Code for Listbox 2 ( Tracks )

tblSelected = ListBox.GetSelected("ListBox1")

if tblSelected ~= nil then
strItemData = ListBox.GetItemData("ListBox1", tblSelected[1])

if strItemData ~= "" then
File.Open("AutoPlay\\Music"..strItemData, "", SW_MAXIMIZE)
end
end

What I would like is when the first listbox is clicked on, it will display only the tracks in that album ( folder ) in Listbox2, and when a track is clicked on I;d like it to play.

Also, is there anyway to remove the .mp3 from the list of tracks? as in: example.mp3 -> example

Any and all help is welcome and well needed!

Thank you all!:)

RizlaUK
10-11-2007, 04:37 AM
im in the middle of making my own mp3 manager,

i using worms (free) mp3tag dll (untill i get my own one working properly!)

heres what i did

create a sqlite database with 2 tables, "tracks" and "playlists", when you add a folder (of mp3 files) to the app you loop through the tracks in the folder adding the id3 info to the tracks table (title, artist, album, genre)

then you can use a tree object, add the main node (name like Music Collection) (1) and add artist (1.1) title (1.2) album (1.3) genre (1.4) and a new node for the playlist (2)

now you can sort through your music by id3 tag info, click a album in the tree and all tracks in that album are shown in the listbox, same for title, artist and genre

and then you can save your playlist to the database as well, adding the id3 info for each track

it might seem like a lot of work.....but its worth it for the end result




failing that.....just set the recurse on your file.find action to false, then it will only add the files in that folder, and to hide the extension, just use "tblSplitPath.Filename" instead of "tblSplitPath.Filename..tblSplitPath.Extension"



EDIT: on closer inspection of your code.....its all wrong, give me 20 mins and ill make you a simple example

RizlaUK
10-11-2007, 05:32 AM
ok, here ya go


put this in page onshow and set the path to your music folder
FolderPath = Shell.GetFolder(SHF_MYDOCUMENTS)-- set your folder path here

tblFolders = Folder.Find(FolderPath, "*", false, nil);
if tblFolders then
for i,k in tblFolders do
FolderName = String.Mid(k, String.ReverseFind(k, "\\") + 1, -1);
ListBox.AddItem("ListBox1", FolderName, k);
end
end


this is the code for listbox 1,
lbSel = ListBox.GetSelected("ListBox1");
if lbSel then
FolderPath = ListBox.GetItemData("ListBox1", lbSel[1]);
tblFiles = File.Find(FolderPath, "*.mp3", false, false, nil, nil);
ListBox.DeleteItem("ListBox2", -1);
if tblFiles then
for i,k in tblFiles do
sPath = String.SplitPath(k);
ListBox.AddItem("ListBox2", sPath.Filename, k);
end
end
end


this is the code for listbox 2
lbSel = ListBox.GetSelected("ListBox2");
if lbSel then
FilePath = ListBox.GetItemData("ListBox2", lbSel[1]);
File.Open(FilePath, "", SW_SHOWNORMAL);
end

hope that helps you out

TheProg
10-11-2007, 06:06 AM
Thanks Rizla, I tried your second post and it works like a charm thanks! :):)

I will however, try your first method too, as Im sure I could incorporate this as a version 1.1 :)
If I need anymore help I will post here!

Thanks once again fella, top notch!

RizlaUK
10-11-2007, 06:51 AM
Hey no problem, always glad to help

TheProg
10-11-2007, 11:23 AM
right, now I have made a section for my movies & videos, but the double-clicked listbox will not open them :huh

On Show Code:tblAVIFiles = File.Find("AutoPlay\\Movies & Films\\", "*.avi", false, false)

if tblAVIFiles ~= nil then
for i,v in tblAVIFiles do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename, tblSplitPath.Filename)
end
end

On Listbox1 ( Double-click ) tblSelected = ListBox.GetSelected("ListBox1")

if tblSelected ~= nil then
strItemData = ListBox.GetItemData("ListBox1", tblSelected[1])

if strItemData ~= "" then
File.Open("AutoPlay\\Movies & Films"..strItemData, "", SW_MAXIMIZE)
end
end

Well this is all I need to get right before it will all work, then I need something major hehe!
When I single click on a movie, I want it to display it's relevant artwork and to display a small text file in the paragraph object, this will be for the use of extra information (some knows by the titles, others by the artwork) and could proove useful for chosing the right movie as it will have a short description & plot outline ( or the like )

So if anyone can help me with the coding for the above, that would be excellent!:)

RizlaUK
10-11-2007, 11:54 AM
ok, well for this issue you are setting the filename as the listbox data, the file.run command needs the full path to the file


in this block of code
tblAVIFiles = File.Find("AutoPlay\\Movies & Films\\", "*.avi", false, false)

if tblAVIFiles ~= nil then
for i,v in tblAVIFiles do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename, tblSplitPath.Filename)
end
end

change it to
tblAVIFiles = File.Find("AutoPlay\\Movies & Films\\", "*.avi", false, false)

if tblAVIFiles ~= nil then
for i,v in tblAVIFiles do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename, v)
end
end

and that should work

EDIT:

for the image and text info, name your image and text file the same as the movie and when a movie is selected from the listbox you can loat the image and text file with the same name

hope that helps

TheProg
10-11-2007, 12:10 PM
er, it didnt help really, it just adds the list of movies again and again lol :rolleyes

Ive attatched an export of the video portion so it hopefully will be clearer & easier!

also, reguarding the text & images, would it be OK to have them in seperate folders, as I have Movies & Videos, then something like Artwork and another folder called say "Bio's" hopefully this would work :)

RizlaUK
10-11-2007, 12:24 PM
well, i cant see why its adding the list over and over as i only changed the listbox item data, are you sure you put the code in the right place ?

TheProg
10-11-2007, 12:32 PM
I think so, I pasted the code into the listbox on double click event, but it just adds loads more to the list and dont open anything, see the exported app for what I mean happens :)

RizlaUK
10-11-2007, 12:54 PM
lol, that was the code to add the files to the listbox, put it in page onshow

TheProg
10-11-2007, 01:07 PM
Ah right lol!
Well I sorted that out, put it in the right place and re-did the listbox code, but I think it is a problem with the code for the Double-click as it wont do anything now, I double click and no movie!

tblSelected = ListBox.GetSelected("ListBox1")

if tblSelected ~= nil then
strItemData = ListBox.GetItemData("ListBox1", tblSelected[1])

if strItemData ~= "" then
File.Open("AutoPlay\\Movies & Films"..strItemData, "", SW_MAXIMIZE)
end
end

Is this the problem by any chance?

RizlaUK
10-11-2007, 01:11 PM
try it like this
tblSelected = ListBox.GetSelected("ListBox1")
if tblSelected then
strItemData = ListBox.GetItemData("ListBox1", tblSelected[1])
if strItemData ~= "" then
File.Open(strItemData, "", SW_MAXIMIZE)
end
end

TheProg
10-19-2007, 06:32 AM
Thanks fella that works a treat :)

I have added an 'admin page' so I can update (copy) the media from my server as at the moment I have this app running on a 160GB USB HDD and works lovely!

I am interested in your database way of doing the music, so like a tree labeled My Music, with expandable branches for music in album order or individual tracks!
The only database experience I have is with Excel & Clarion, so would this be too difficult for me to make with or without a database?