1 Pages  1 2 3  
Reply to this topic  Start new topic
> Standalone CD player widget, A widget that could play CDs w/o iTunes
SpaceCat85
post Apr 20 2007, 05:22 PM
Post #1






Posts: 2
Joined: 20-April 07
Member No.: 21,392



I'd like to see a simple, easy-to-use widget that could play CDs without requiring iTunes (or, on Windows, WMP). While both the Mac OS and Windows used to have simple apps for playing audio CDs, these days they make you launch the default Swiss Army Knife media player. I don't store many/any of my MP3s on my MacBook's hard drive for space reasons, and it seems like overkill to have something like iTunes open just to play a standard audio CD.

The widget would include:
-a simple, clean controller interface that isn't microscopic; possibly displayed as white text/icons on a black OS X-style bezel akin to the one used by Sizzling Keys and a few Dashboard widgets
-basic CD-playing controls, including a disc repeat button
-a collapsible playlist that lets you rearrange and/or disable tracks

and possibly
-the ability to query an online music database for track names
-album art retrieving and displaying like Sputnik.




Mac OS 10.3.9 PPC and 10.4.9 Intel
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post Apr 20 2007, 06:33 PM
Post #2






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



Well, a UI for this would be fairly easy to design and program. The problem is reading the CDs. As I know, the widget engine doesn't come with built-in tools to read a CD. Someone can correct me on this, but that's as I know. If it could read CDs, this widget would be quite easy, as I would think.




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
lilgshock
post May 24 2007, 04:10 PM
Post #3






Posts: 1
Joined: 24-May 07
Member No.: 22,072



Wouthout some external OCX or COM control this isn't really possible, is it???
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 05:33 PM
Post #4






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ Apr 20 2007, 07:33 PM) *
If it could read CDs, this widget would be quite easy, as I would think.
I've just run this command in Widget Tester:
CODE
play("/Volumes/Dolly Parton/1 Baby I'm Burning - Live.aiff");
The play command played the track. The track is 22 Mbyte in size. I don't know how big a file you can play. However, once you've started to play the track, there's no control over it, other than to stop it.

You could use my cross-platform Media Player classes to play the track in QuickTime Player or Windows Media Player.

On the Macintosh, you would see the application window (but you can hide it). On Windows, you don't need to see it at all,
You also have control over the stream, if your Widget wants that.

Media Player Classes.

CODE
var wmpPlayer = new WMP("file:///Volumes/Dolly Parton/1 Baby I'm Burning - Live.aiff");
wmpPlayer.play();
That's all you need to play a CD track using the class. On the Macintosh, you get the QuickTime Player window:

IPB Image

PLUG: The classes can also be used to play audio and video streams - I have several originally Windows only radio station players running on my iMac.

Harry.

This post has been edited by g6auc: May 24 2007, 06:04 PM




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 08:01 PM
Post #5






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



The only problem I could forsee is detecting a CD drive. What you'd probably have to do is use filesystem.volumes to iterate over connected drives, using totalBytes to determine whether it's a CD drive or not. Then, offer the user the choice of CDs to play. Also, why is the file you played in AIFF? Last time I checked (which was about 5-6 years ago, btw), they had a .cd extension (or something akin to that). Have I fallen behind, or was that a custom CD you made? Or something else entirely?




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
BOINCer
post May 24 2007, 08:15 PM
Post #6






Posts: 1,288
Joined: 28-September 05
From: Buenos Aires, Argentina
Member No.: 10,111



Mac OS X shows the CD as containing .aiff files with the audio.

Windows shows the CD as containing .cda files, which are all 44 bytes, and contain the serial number of the CD, track number, etc. If you copy the .cda to your hard disk, it will ask for that specific CD (if it's not in the drive already) when you open it. At least that's how it worked on Windows 98 with the CD player tongue.gif

All these are really abstractions the OS does. A music CD doesn't even have files at all. It has "Audio tracks" which contain uncompressed 44,100Hz 16-bit stereo audio (and some little extra data like track count and length), instead of "Data tracks" which contain a filesystem.




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 08:42 PM
Post #7






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 09:01 PM) *
...why is the file you played in AIFF? ... or was that a custom CD you made? Or something else entirely?
The CD was a giveaway CD from a national newspaper. I've also loaded a commercial music CD (Verdi's Requiem on the Philips lable). Both appear in the Finder showing AIFF files. What is actually on the CD is not really my concern. The "AIFF" files can be played with the Konfabulator play() command, but QuickTime Player does a better job and is (apple)scriptable. It is, of course, also possible to use iTunes.

I would assume that you would also be able to play the CD using the WMP OCX - that is what my Media Player class would try to do on Windows.

Harry.





User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 08:42 PM
Post #8






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



Ah. That makes sense. So what we could do is just get the CD, and use filesystem.getDirectoryContents to get the names of all the files, then play them in order, or maybe a shuffle function built in. Follow?

EDIT: Sorry. My post was in response to BOINCer's post. SpaceCat85, the original requester, said he would like a widget that could do this without iTunes however, so that's out of the question.

EDIT 2: g6auc, your classes look quite promising. That would remove most of the harder code on my part. I'm guessing that it's all right if I redistribute it under one of my widgets, as long as I leave the copyright notice in the files. (I've never bothered to read the GPL, even though I use lots of open-source software: Fedora, GIMP, Firefox...)




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 09:01 PM
Post #9






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 09:42 PM) *
So what we could do is just get the CD, and use filesystem.getDirectoryContents to get the names of all the files, then play them in order, or maybe a shuffle function built in.
That's correct. You could try the play() function, but I suspect that it might break with big files - but try it. If you want a player UI that has the usual play/pause and volume controls, etc., you would be better off using the WMP OCX (on Windows) and QuickTime Player (on Macintosh). You can do that in a cross-platform way using my Media Player class, or you could repeat the work that I have done and make your own class.

Harry.




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 09:06 PM
Post #10






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



All right. So I can probably use your classes for this. Saves me having to learn another API. I thinking now to select a CD, I should just use a chooseFolder call. That'll allow it to play anything on the local system.




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 09:08 PM
Post #11






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 09:42 PM) *
g6auc, your classes look quite promising. That would remove most of the harder code on my part. I'm guessing that it's all right if I redistribute it under one of my widgets, as long as I leave the copyright notice in the files
That's correct.That's essentially what the license says. If you make modifications you should mark them as such. However, if you had problems with the classes, I'd be happy to try to help.

Harry.





User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 09:19 PM
Post #12






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 10:06 PM) *
I thinking now to select a CD, I should just use a chooseFolder call. That'll allow it to play anything on the local system.
You could, but that's rather ugly. You could construct a pull-down menu with the mounted volumes, and maybe try to eliminate those that can't be CDs. Have a look at Eject Volumes. It has code to create a menu of mounted volumes. It's a Macintosh Widget, but should be easy to modify. You are welocome to lift code from it.





User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 09:25 PM
Post #13






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



I like your idea. I'm thinking that you could eliminate any volumes under about 10GB of data? I would use 700MB, but I think you can get music DVDs now that just have music - no video - on them. I haven't seen them personally, but I've heard some stuff about it. Can anyone confirm or deny that claim? It would be very much appreciated. If it turns out that DVDs aren't used for music, I can probably just eliminate all volumes over 700MB.




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
BOINCer
post May 24 2007, 09:29 PM
Post #14






Posts: 1,288
Joined: 28-September 05
From: Buenos Aires, Argentina
Member No.: 10,111



If you use a GPL library, basically your code has to be GPL as well. That means the source code has to be available and free to modify and redistribute. Source availability is a moot point for widgets, since all widgets so far have code available (I don't know of any widget using JS obfuscation yet).

And then the copyright notices of course; I know of very few licenses where you aren't required to keep original author copyright (example: the WTFPL).


There is DVD-Audio, but they haven't been used much (ie. there aren't many in the market). That's what the AUDIO_TS folder on DVDs is for; it's usually empty for movie DVDs.




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 09:44 PM
Post #15






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



You seem to be answering all my unanswered questions. I was always wondering what that was for. Okay, so I'll probably just scan for drives with a capacity lower than 700MB. I just put a CD in, and it came up as 532MB. So anything under that should be a CD. Floppies will be included, but I don't think anybody uses floppies on a regular basis anymore, so I should be fine.




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 09:56 PM
Post #16






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



Can anyone try the following .kon file on their computer with a CD in. It should list the CD and no other drives. Basically, it just checks if the total size is less than 700MB and is not 0. Printing copied from the docs.

CODE
<?xml version="1.1"?>
<widget debug="on">
    <action trigger="onLoad">
    <![CDATA[
        var vols = filesystem.volumes;
        for(var a = 0; a < vols.length; a++) if(vols[a].totalBytes < 734003200 && vols[a].totalBytes != 0) print( "Volume " + filesystem.getDisplayName( vols[a].path ) + " (path " + vols[a].path + ") has a capacity of " + bytesToUIString( vols[a].totalBytes ) + " and " + bytesToUIString( vols[a].freeBytes ) + " free." );
    ]]>
    </action>
</widget>




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 10:10 PM
Post #17






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 10:56 PM) *
Can anyone try the following .kon file on their computer with a CD in. It should list the CD and no other drives. Basically, it just checks if the total size is less than 700MB and is not 0. Printing copied from the docs.
CODE
Yahoo! Widget Engine 4.0.3x177 on 2007-05-24 23:06:10 +0100
Loaded Widget 'test' from /Users/nhw/Desktop/test.kon
Volume Dolly Parton (path /Volumes/Dolly Parton) has a capacity of 415.4 MB and 0 bytes free.
As expected.
However, your limit of 700MB is a bit low. I've seen CDs in 750MB range. Why not use 800MB or 1GB?




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 10:12 PM
Post #18






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



I might try 800MB. Here's the update code.

CODE
<?xml version="1.1"?>
<widget debug="on">
    <action trigger="onLoad">
    <![CDATA[
        var vols = filesystem.volumes;
        for(var a = 0; a < vols.length; a++) if(vols[a].totalBytes < 838860800 && vols[a].totalBytes != 0) print( "Volume " + filesystem.getDisplayName( vols[a].path ) + " (path " + vols[a].path + ") has a capacity of " + bytesToUIString( vols[a].totalBytes ) + " and " + bytesToUIString( vols[a].freeBytes ) + " free." );
    ]]>
    </action>
</widget>




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Michael's Programming
post May 24 2007, 10:36 PM
Post #19






Posts: 761
Joined: 30-March 07
From: Ottawa, Canada
Member No.: 20,895



g6auc, there may be a problem with your code for this widget. If the CD has extras on it, I can't check what tracks are available. I can still play them by manually defining the .cda file, but using filesystem.itemExists on the file return false. It return true if there are no extras though. If I define a file that I know is not there, I get an alert saying that WMP cannot play the item. No exception is thrown. Don't know if this is something you can intercept.




I do HTML, JavaScript, XML, Perl, PHP, Java, C, C++, and Obj-C. You want something done, I have it. Now with Python!
Widgets: IPB Image Illusion of the Day | IPB Image Alienware Clock | IPB Image ToDo List | IPB Image BOINC Statistics
Possibly Dropped: CD Player | Flexible Clock | Al'Bhed Translator
The Unofficial Konfabulator Wiki
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
g6auc
post May 24 2007, 10:56 PM
Post #20






Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322



QUOTE(Michael's Programming @ May 24 2007, 11:36 PM) *
g6auc, there may be a problem with your code for this widget. If the CD has extras on it, I can't check what tracks are available. I can still play them by manually defining the .cda file, but using filesystem.itemExists on the file return false. It return true if there are no extras though. If I define a file that I know is not there, I get an alert saying that WMP cannot play the item. No exception is thrown. Don't know if this is something you can intercept.
As I don't have a Windows computer that will run K, it's not possible for me to do any tests on Windows. The cross-platform code uses the WMP OCX on Windows. The code was written based on the Microsoft documentation and tested by volunteers here on the Forum. If you have a Windows computer, you are in a better position than I am to play with the code.





User is offlineProfile CardPM
Go to the top of the page
+Quote Post
1 Pages  1 2 3 
Fast Reply  Reply to this topic    Start new topic  
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: