Patch by Vasilis Kaoutsis:
* Fixed several missing incorrect initializations from fYear. * Style cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21739 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#ifndef BUTTON_BITMAPS_H
|
#ifndef BUTTON_BITMAPS_H
|
||||||
#define BUTTON_BITMAPS_H
|
#define BUTTON_BITMAPS_H
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
// #pragma mark play
|
// #pragma mark play
|
||||||
|
|
||||||
|
|||||||
+552
-539
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
* DarkWyrm, bpmagic@columbus.rr.com
|
||||||
*/
|
*/
|
||||||
#ifndef CDAUDIODEVICE_H
|
#ifndef CDAUDIODEVICE_H
|
||||||
#define CDAUDIODEVICE_H
|
#define CDAUDIODEVICE_H
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
// The SCSI table of contents consists of a 4-byte header followed by 100 track
|
// The SCSI table of contents consists of a 4-byte header followed by 100 track
|
||||||
// descriptors, which are each 8 bytes. We don't really need the first 5 bytes
|
// descriptors, which are each 8 bytes. We don't really need the first 5 bytes
|
||||||
// of the track descriptor, so we'll just ignore them. All we really want is the
|
// of the track descriptor, so we'll just ignore them. All we really want is the
|
||||||
// length of each track, which happen to be the last 3 bytes of the descriptor.
|
// fLength of each track, which happen to be the last 3 bytes of the descriptor.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8 reserved;
|
uint8 reserved;
|
||||||
uint8 adr_control; // bytes 0-3 are control, 4-7 are ADR
|
uint8 adr_control; // bytes 0-3 are control, 4-7 are ADR
|
||||||
uint8 track_number;
|
uint8 track_number;
|
||||||
uint8 reserved2;
|
uint8 reserved2;
|
||||||
|
|
||||||
uint8 reserved3;
|
uint8 reserved3;
|
||||||
uint8 min;
|
uint8 min;
|
||||||
uint8 sec;
|
uint8 sec;
|
||||||
@@ -29,7 +30,7 @@ typedef struct {
|
|||||||
} TrackDescriptor;
|
} TrackDescriptor;
|
||||||
|
|
||||||
enum CDState {
|
enum CDState {
|
||||||
kNoCD=0,
|
kNoCD = 0,
|
||||||
kStopped,
|
kStopped,
|
||||||
kPaused,
|
kPaused,
|
||||||
kPlaying,
|
kPlaying,
|
||||||
@@ -38,79 +39,104 @@ enum CDState {
|
|||||||
kInit
|
kInit
|
||||||
};
|
};
|
||||||
|
|
||||||
class cdaudio_time
|
|
||||||
{
|
class CDAudioTime {
|
||||||
public:
|
public:
|
||||||
cdaudio_time(const int32 min=-1,const int32 &sec=-1);
|
CDAudioTime(const int32 min = -1, const int32 &sec = -1);
|
||||||
cdaudio_time(const cdaudio_time &from);
|
CDAudioTime(const CDAudioTime &from);
|
||||||
cdaudio_time &operator=(const cdaudio_time &from);
|
CDAudioTime &operator=(const CDAudioTime &from);
|
||||||
cdaudio_time operator+(const cdaudio_time &from);
|
CDAudioTime operator+(const CDAudioTime &from);
|
||||||
cdaudio_time operator-(const cdaudio_time &from);
|
CDAudioTime operator-(const CDAudioTime &from);
|
||||||
|
|
||||||
int32 minutes;
|
void SetMinutes(const int32& minutes)
|
||||||
int32 seconds;
|
{
|
||||||
|
fMinutes = minutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSeconds(const int32& seconds)
|
||||||
|
{
|
||||||
|
fSeconds = seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 GetMinutes() const
|
||||||
|
{
|
||||||
|
return fMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 GetSeconds() const
|
||||||
|
{
|
||||||
|
return fSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fMinutes;
|
||||||
|
int32 fSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cdaudio_data
|
|
||||||
{
|
class CDAudioData {
|
||||||
public:
|
public:
|
||||||
cdaudio_data(const int32 &id = -1, const int32 &count = -1,
|
CDAudioData(const int32 &id = -1, const int32 &count = -1,
|
||||||
const int32 &disclength = -1);
|
const int32 &discLength = -1);
|
||||||
cdaudio_data(const cdaudio_data &from);
|
CDAudioData(const CDAudioData &from);
|
||||||
cdaudio_data &operator=(const cdaudio_data &from);
|
CDAudioData &operator=(const CDAudioData &from);
|
||||||
|
|
||||||
int32 disc_id;
|
private:
|
||||||
int32 track_count;
|
int32 fDiscId;
|
||||||
int32 length;
|
int32 fTrackCount;
|
||||||
|
int32 fLength;
|
||||||
BString frame_offsets;
|
BString fFrameOffsets;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDAudioDevice
|
|
||||||
{
|
class CDAudioDevice {
|
||||||
public:
|
public:
|
||||||
CDAudioDevice(void);
|
CDAudioDevice();
|
||||||
~CDAudioDevice(void);
|
~CDAudioDevice();
|
||||||
|
|
||||||
bool Play(const int16 &track);
|
bool Play(const int16 &track);
|
||||||
bool Pause(void);
|
bool Pause();
|
||||||
bool Resume(void);
|
bool Resume();
|
||||||
bool Stop(void);
|
bool Stop();
|
||||||
bool Eject(void);
|
bool Eject();
|
||||||
|
|
||||||
bool StartFastFwd(void);
|
bool StartFastFwd();
|
||||||
bool StopFastFwd(void);
|
bool StopFastFwd();
|
||||||
|
|
||||||
bool StartRewind(void);
|
bool StartRewind();
|
||||||
bool StopRewind(void);
|
bool StopRewind();
|
||||||
|
|
||||||
bool SetVolume(uint8 value);
|
bool SetVolume(uint8 value);
|
||||||
uint8 GetVolume(void);
|
uint8 GetVolume();
|
||||||
|
|
||||||
CDState GetState(void);
|
CDState GetState();
|
||||||
|
|
||||||
int16 CountTracks(void);
|
int16 CountTracks();
|
||||||
int16 GetTrack(void);
|
int16 GetTrack();
|
||||||
|
|
||||||
uint8 CountDrives(void);
|
uint8 CountDrives();
|
||||||
bool SetDrive(const int32 &drive);
|
bool SetDrive(const int32 &drive);
|
||||||
const char * GetDrivePath(void) const;
|
const char* GetDrivePath() const;
|
||||||
int32 GetDrive(void) const { return fDriveIndex; }
|
|
||||||
|
int32 GetDrive() const
|
||||||
bool GetTime(cdaudio_time &track, cdaudio_time &disc);
|
{
|
||||||
bool GetTimeForTrack(const int16 &index, cdaudio_time &track);
|
return fDriveIndex;
|
||||||
bool GetTimeForDisc(cdaudio_time &disc);
|
}
|
||||||
int32 GetDiscID(void);
|
|
||||||
|
bool GetTime(CDAudioTime &track, CDAudioTime &disc);
|
||||||
bool IsDataTrack(const int16 &track);
|
bool GetTimeForTrack(const int16 &index, CDAudioTime &track);
|
||||||
|
bool GetTimeForDisc(CDAudioTime &disc);
|
||||||
private:
|
int32 GetDiscID();
|
||||||
int32 FindDrives(const char *path);
|
|
||||||
|
bool IsDataTrack(const int16 &track);
|
||||||
int fFileHandle;
|
|
||||||
BString * fDrivePath;
|
private:
|
||||||
BList fDriveList;
|
int32 _FindDrives(const char *path);
|
||||||
int32 fDriveIndex;
|
|
||||||
|
int fFileHandle;
|
||||||
|
BString* fDrivePath;
|
||||||
|
BList fDriveList;
|
||||||
|
int32 fDriveIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // CDAUDIODEVICE_H
|
||||||
|
|||||||
+395
-351
File diff suppressed because it is too large
Load Diff
+190
-127
@@ -1,149 +1,212 @@
|
|||||||
#ifndef CDDBSUPPORT_H
|
#ifndef CDDBSUPPORT_H
|
||||||
#define CDDBSUPPORT_H
|
#define CDDBSUPPORT_H
|
||||||
|
|
||||||
#include <NetEndpoint.h>
|
#include "CDAudioDevice.h"
|
||||||
#include <String.h>
|
|
||||||
#include <scsi.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include "CDAudioDevice.h"
|
#include <NetEndpoint.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
#include <scsi.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
class CDDBData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDDBData(int32 discid=-1);
|
|
||||||
CDDBData(const CDDBData &from);
|
|
||||||
~CDDBData(void);
|
|
||||||
CDDBData & operator=(const CDDBData &from);
|
|
||||||
|
|
||||||
status_t Load(const entry_ref &ref);
|
|
||||||
status_t Save(const char *filename);
|
|
||||||
|
|
||||||
status_t Load(void);
|
|
||||||
status_t Save(void);
|
|
||||||
|
|
||||||
void MakeEmpty(void);
|
|
||||||
void SetDiscID(const int32 &id) { fDiscID=id; }
|
|
||||||
int32 DiscID(void) const { return fDiscID; }
|
|
||||||
|
|
||||||
uint16 CountTracks(void) const;
|
|
||||||
const char * TrackAt(const int16 &index) const;
|
|
||||||
bool RenameTrack(const int32 &index, const char *newname);
|
|
||||||
void AddTrack(const char *track, const cdaudio_time &time,
|
|
||||||
const int16 &index=-1);
|
|
||||||
void RemoveTrack(const int16 &index);
|
|
||||||
|
|
||||||
cdaudio_time * TrackTimeAt(const int16 &index);
|
|
||||||
|
|
||||||
void SetDiscTime(const cdaudio_time time) { fDiscTime = time; }
|
|
||||||
cdaudio_time * DiscTime(void) { return &fDiscTime; }
|
|
||||||
|
|
||||||
void SetGenre(const char *genre) { fGenre=genre; }
|
|
||||||
const char * Genre(void) { return fGenre.String(); }
|
|
||||||
|
|
||||||
void SetArtist(const char *artist) { fArtist=artist; }
|
|
||||||
const char * Artist(void) const { return fArtist.String(); }
|
|
||||||
|
|
||||||
void SetAlbum(const char *album) { fAlbum=album; }
|
|
||||||
const char * Album(void) const { return fAlbum.String(); }
|
|
||||||
|
|
||||||
void SetYear(const int16 &year) { fYear=year; }
|
|
||||||
int16 Year(void) const { return fYear; }
|
|
||||||
|
|
||||||
|
class CDDBData {
|
||||||
private:
|
public:
|
||||||
void EmptyLists(void);
|
CDDBData(int32 discid = -1);
|
||||||
|
CDDBData(const CDDBData &from);
|
||||||
int32 fDiscID;
|
~CDDBData();
|
||||||
|
CDDBData& operator=(const CDDBData &from);
|
||||||
BString fArtist;
|
|
||||||
BString fAlbum;
|
status_t Load(const entry_ref &ref);
|
||||||
BString fGenre;
|
status_t Save(const char *filename);
|
||||||
|
|
||||||
BList fTrackList;
|
status_t Load();
|
||||||
BList fTimeList;
|
status_t Save();
|
||||||
|
|
||||||
cdaudio_time fDiscTime;
|
void MakeEmpty();
|
||||||
int32 fYear;
|
|
||||||
|
void SetDiscID(const int32 &id)
|
||||||
|
{
|
||||||
|
fDiscID = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 DiscID() const
|
||||||
|
{
|
||||||
|
return fDiscID;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 CountTracks() const;
|
||||||
|
const char* TrackAt(const int16 &index) const;
|
||||||
|
bool RenameTrack(const int32 &index, const char *newname);
|
||||||
|
void AddTrack(const char *track, const CDAudioTime &time,
|
||||||
|
const int16 &index=-1);
|
||||||
|
void RemoveTrack(const int16 &index);
|
||||||
|
|
||||||
|
CDAudioTime* TrackTimeAt(const int16 &index);
|
||||||
|
|
||||||
|
void SetDiscTime(const CDAudioTime time)
|
||||||
|
{
|
||||||
|
fDiscTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDAudioTime* DiscTime()
|
||||||
|
{
|
||||||
|
return &fDiscTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetGenre(const char *genre)
|
||||||
|
{
|
||||||
|
fGenre=genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Genre()
|
||||||
|
{
|
||||||
|
return fGenre.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetArtist(const char *artist)
|
||||||
|
{
|
||||||
|
fArtist = artist;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Artist() const
|
||||||
|
{
|
||||||
|
return fArtist.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAlbum(const char *album)
|
||||||
|
{
|
||||||
|
fAlbum = album;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Album() const
|
||||||
|
{
|
||||||
|
return fAlbum.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetYear(const int16 &year)
|
||||||
|
{
|
||||||
|
fYear = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16 Year() const
|
||||||
|
{
|
||||||
|
return fYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _EmptyLists();
|
||||||
|
|
||||||
|
int32 fDiscID;
|
||||||
|
|
||||||
|
BString fArtist;
|
||||||
|
BString fAlbum;
|
||||||
|
BString fGenre;
|
||||||
|
|
||||||
|
BList fTrackList;
|
||||||
|
BList fTimeList;
|
||||||
|
|
||||||
|
CDAudioTime fDiscTime;
|
||||||
|
int32 fYear;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// based on Jukebox by Chip Paul
|
// based on Jukebox by Chip Paul
|
||||||
|
|
||||||
class CDDBQuery
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDDBQuery(const char *server, int32 port = 888);
|
|
||||||
~CDDBQuery(void);
|
|
||||||
void SetToSite(const char *server, int32 port);
|
|
||||||
status_t GetSites(bool (*)(const char *site, int port,
|
|
||||||
const char *latitude, const char *longitude,
|
|
||||||
const char *description, void *state), void *);
|
|
||||||
|
|
||||||
void SetToCD(const char *devicepath);
|
class CDDBQuery {
|
||||||
|
public:
|
||||||
const char * GetArtist(void) { return fCDData.Artist(); }
|
CDDBQuery(const char *server, int32 port = 888);
|
||||||
const char * GetAlbum(void) { return fCDData.Album(); }
|
~CDDBQuery();
|
||||||
const char * GetGenre(void) { return fCDData.Genre(); }
|
void SetToSite(const char *server, int32 port);
|
||||||
|
status_t GetSites(bool (*)(const char *site, int port,
|
||||||
bool GetData(CDDBData *data, bigtime_t timeout);
|
const char *latitude, const char *longitude,
|
||||||
void SetData(const CDDBData &data);
|
const char *description, void *state), void *);
|
||||||
|
|
||||||
bool Ready() const { return fState == kDone; }
|
|
||||||
int32 CurrentDiscID() const { return fCDData.DiscID(); }
|
|
||||||
|
|
||||||
static int32 GetDiscID(const scsi_toc *);
|
void SetToCD(const char *devicepath);
|
||||||
static int32 GetTrackCount(const scsi_toc *);
|
|
||||||
static cdaudio_time GetDiscTime(const scsi_toc *);
|
|
||||||
static void GetTrackTimes(const scsi_toc *, vector<cdaudio_time> ×);
|
|
||||||
static BString OffsetsToString(const scsi_toc *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t Connect();
|
|
||||||
void Disconnect();
|
|
||||||
bool IsConnected() const;
|
|
||||||
|
|
||||||
static int32 QueryThread(void *);
|
|
||||||
|
|
||||||
// cached retrieved data
|
const char* GetArtist()
|
||||||
enum State
|
{
|
||||||
{
|
return fCDData.Artist();
|
||||||
kInitial,
|
}
|
||||||
kReading,
|
|
||||||
kDone,
|
|
||||||
kInterrupting,
|
|
||||||
kError
|
|
||||||
};
|
|
||||||
void SetDefaultInfo(void);
|
|
||||||
status_t OpenContentFile(const int32 &discID);
|
|
||||||
|
|
||||||
status_t ReadFromServer(BString &data);
|
|
||||||
void ParseData(const BString &data);
|
|
||||||
void WriteFile(void);
|
|
||||||
|
|
||||||
void ReadLine(BString &);
|
|
||||||
status_t IdentifySelf();
|
|
||||||
|
|
||||||
const char * GetToken(const char *, BString &);
|
const char* GetAlbum()
|
||||||
|
{
|
||||||
|
return fCDData.Album();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* GetGenre()
|
||||||
|
{
|
||||||
|
return fCDData.Genre();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetData(CDDBData *data, bigtime_t timeout);
|
||||||
|
void SetData(const CDDBData &data);
|
||||||
|
|
||||||
|
bool Ready() const
|
||||||
|
{
|
||||||
|
return fState == kDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CurrentDiscID() const
|
||||||
|
{
|
||||||
|
return fCDData.DiscID();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32 GetDiscID(const scsi_toc *);
|
||||||
|
static int32 GetTrackCount(const scsi_toc *);
|
||||||
|
static CDAudioTime GetDiscTime(const scsi_toc *);
|
||||||
|
static void GetTrackTimes(const scsi_toc *, vector<CDAudioTime> ×);
|
||||||
|
static BString OffsetsToString(const scsi_toc *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t _Connect();
|
||||||
|
void _Disconnect();
|
||||||
|
bool _IsConnected() const;
|
||||||
|
|
||||||
|
static int32 _QueryThread(void *);
|
||||||
|
|
||||||
|
// cached retrieved data
|
||||||
|
enum State {
|
||||||
|
kInitial,
|
||||||
|
kReading,
|
||||||
|
kDone,
|
||||||
|
kInterrupting,
|
||||||
|
kError
|
||||||
|
};
|
||||||
|
|
||||||
|
void _SetDefaultInfo();
|
||||||
|
status_t _OpenContentFile(const int32 &discID);
|
||||||
|
|
||||||
|
status_t _ReadFromServer(BString &data);
|
||||||
|
void _ParseData(const BString &data);
|
||||||
|
void _WriteFile();
|
||||||
|
|
||||||
|
void _ReadLine(BString &);
|
||||||
|
status_t _IdentifySelf();
|
||||||
|
|
||||||
|
const char* _GetToken(const char*, BString &);
|
||||||
|
|
||||||
|
// state data
|
||||||
|
BString fServerName;
|
||||||
|
BNetEndpoint fSocket;
|
||||||
|
int32 fPort;
|
||||||
|
bool fConnected;
|
||||||
|
|
||||||
|
thread_id fThread;
|
||||||
|
State fState;
|
||||||
|
status_t fResult;
|
||||||
|
|
||||||
// state data
|
// disc information
|
||||||
BString fServerName;
|
CDDBData fCDData;
|
||||||
BNetEndpoint fSocket;
|
BString fFrameOffsetString;
|
||||||
int32 fPort;
|
scsi_toc fSCSIData;
|
||||||
bool fConnected;
|
|
||||||
|
|
||||||
thread_id fThread;
|
|
||||||
State fState;
|
|
||||||
status_t fResult;
|
|
||||||
|
|
||||||
// disc information
|
|
||||||
CDDBData fCDData;
|
|
||||||
BString fFrameOffsetString;
|
|
||||||
scsi_toc fSCSIData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BString GetLineFromString(const char *string);
|
BString GetLineFromString(const char *string);
|
||||||
|
|
||||||
#endif
|
#endif // CDDBSUPPORT_H
|
||||||
|
|||||||
+253
-243
@@ -1,13 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
* DarkWyrm, bpmagic@columbus.rr.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ButtonBitmaps.h"
|
||||||
|
#include "CDPlayer.h"
|
||||||
|
#include "DrawButton.h"
|
||||||
|
#include "DoubleShotDrawButton.h"
|
||||||
|
#include "TwoStateDrawButton.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <BitmapStream.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
@@ -17,20 +26,14 @@
|
|||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
#include <TranslatorFormats.h>
|
||||||
|
#include <TranslatorRoster.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ButtonBitmaps.h"
|
|
||||||
#include "CDPlayer.h"
|
|
||||||
#include "DrawButton.h"
|
|
||||||
#include "DoubleShotDrawButton.h"
|
|
||||||
#include "TwoStateDrawButton.h"
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <TranslatorFormats.h>
|
|
||||||
#include <TranslatorRoster.h>
|
|
||||||
#include <BitmapStream.h>
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
M_STOP = 'mstp',
|
M_STOP = 'mstp',
|
||||||
@@ -47,46 +50,50 @@ enum {
|
|||||||
M_SET_CD_TITLE
|
M_SET_CD_TITLE
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDPlayerWindow : public BWindow
|
|
||||||
{
|
class CDPlayerWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
CDPlayerWindow(void);
|
CDPlayerWindow();
|
||||||
bool QuitRequested(void);
|
bool QuitRequested();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
SetLabel(BStringView *label, const char *text)
|
SetLabel(BStringView *label, const char *text)
|
||||||
{
|
{
|
||||||
if (strcmp(label->Text(),text) != 0)
|
if (strcmp(label->Text(), text) != 0)
|
||||||
label->SetText(text);
|
label->SetText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
|
CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
|
||||||
: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
|
: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
|
||||||
fCDQuery("freedb.freedb.org")
|
fCDQuery("freedb.freedb.org")
|
||||||
{
|
{
|
||||||
SetViewColor(216,216,216);
|
SetViewColor(216,216,216);
|
||||||
|
|
||||||
fVolume = 255;
|
fVolume = 255;
|
||||||
|
|
||||||
BuildGUI();
|
BuildGUI();
|
||||||
|
|
||||||
if (fCDDrive.CountDrives() < 1) {
|
if (fCDDrive.CountDrives() < 1) {
|
||||||
BAlert *alert = new BAlert("CDPlayer","It appears that there are no CD drives"
|
BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD drives"
|
||||||
" on your computer or there is no system software"
|
" on your computer or there is no system software"
|
||||||
" to support one. Sorry.","OK");
|
" to support one. Sorry.", "OK");
|
||||||
alert->Go();
|
alert->Go();
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
fWindowState = fCDDrive.GetState();
|
fWindowState = fCDDrive.GetState();
|
||||||
fVolumeSlider->SetValue(fCDDrive.GetVolume());
|
fVolumeSlider->SetValue(fCDDrive.GetVolume());
|
||||||
if (fVolumeSlider->Value() <= 2) {
|
if (fVolumeSlider->Value() <= 2) {
|
||||||
fCDDrive.SetVolume(255);
|
fCDDrive.SetVolume(255);
|
||||||
fVolumeSlider->SetValue(255);
|
fVolumeSlider->SetValue(255);
|
||||||
}
|
}
|
||||||
WatchCDState();
|
_WatchCDState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,147 +104,143 @@ CDPlayer::~CDPlayer()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CDPlayer::BuildGUI(void)
|
CDPlayer::BuildGUI()
|
||||||
{
|
{
|
||||||
fStopColor.red = 80;
|
fStopColor.red = 80;
|
||||||
fStopColor.green = 164;
|
fStopColor.green = 164;
|
||||||
fStopColor.blue = 80;
|
fStopColor.blue = 80;
|
||||||
fStopColor.alpha = 255;
|
fStopColor.alpha = 255;
|
||||||
|
|
||||||
fPlayColor.red = 40;
|
fPlayColor.red = 40;
|
||||||
fPlayColor.green = 230;
|
fPlayColor.green = 230;
|
||||||
fPlayColor.blue = 40;
|
fPlayColor.blue = 40;
|
||||||
fPlayColor.alpha = 255;
|
fPlayColor.alpha = 255;
|
||||||
|
|
||||||
BRect r(Bounds().InsetByCopy(10,10));
|
BRect r(Bounds().InsetByCopy(10, 10));
|
||||||
BBox *box = new BBox(r,"",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
BBox *box = new BBox(r, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
AddChild(box);
|
AddChild(box);
|
||||||
|
|
||||||
r = box->Bounds().InsetByCopy(10,10);
|
r = box->Bounds().InsetByCopy(10, 10);
|
||||||
r.bottom = 25;
|
r.bottom = 25;
|
||||||
|
|
||||||
float labelWidth, labelHeight;
|
float labelWidth, labelHeight;
|
||||||
fCDTitle = new BStringView(r,"CDTitle","CD drive is empty", B_FOLLOW_LEFT_RIGHT);
|
fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty", B_FOLLOW_LEFT_RIGHT);
|
||||||
fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
|
fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
|
||||||
fCDTitle->ResizeTo(r.Width(), labelHeight);
|
fCDTitle->ResizeTo(r.Width(), labelHeight);
|
||||||
box->AddChild(fCDTitle);
|
box->AddChild(fCDTitle);
|
||||||
|
|
||||||
r.bottom = r.top + labelHeight;
|
r.bottom = r.top + labelHeight;
|
||||||
r.OffsetBy(0, r.Height() + 5);
|
r.OffsetBy(0, r.Height() + 5);
|
||||||
|
|
||||||
fCurrentTrack = new BStringView(r,"TrackNumber","",B_FOLLOW_LEFT_RIGHT);
|
fCurrentTrack = new BStringView(r, "TrackNumber", "", B_FOLLOW_LEFT_RIGHT);
|
||||||
box->AddChild(fCurrentTrack);
|
box->AddChild(fCurrentTrack);
|
||||||
|
|
||||||
r.OffsetBy(0, r.Height() + 5);
|
r.OffsetBy(0, r.Height() + 5);
|
||||||
r.right = r.left + (r.Width() / 2);
|
r.right = r.left + (r.Width() / 2);
|
||||||
fTrackTime = new BStringView(r,"TrackTime","Track: --:-- / --:--",B_FOLLOW_LEFT_RIGHT);
|
fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--", B_FOLLOW_LEFT_RIGHT);
|
||||||
box->AddChild(fTrackTime);
|
box->AddChild(fTrackTime);
|
||||||
|
|
||||||
r.OffsetTo(box->Bounds().right / 2, r.top);
|
r.OffsetTo(box->Bounds().right / 2, r.top);
|
||||||
fDiscTime = new BStringView(r,"DiscTime","Disc: --:-- / --:--",B_FOLLOW_RIGHT);
|
fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--", B_FOLLOW_RIGHT);
|
||||||
fDiscTime->ResizeToPreferred();
|
fDiscTime->ResizeToPreferred();
|
||||||
fDiscTime->ResizeBy(10,0);
|
fDiscTime->ResizeBy(10, 0);
|
||||||
box->AddChild(fDiscTime);
|
box->AddChild(fDiscTime);
|
||||||
|
|
||||||
box->ResizeTo(fCDTitle->Frame().right + 5, fDiscTime->Frame().bottom + 10);
|
box->ResizeTo(fCDTitle->Frame().right + 5, fDiscTime->Frame().bottom + 10);
|
||||||
|
|
||||||
fStop = new DrawButton(BRect(0,0,1,1), "Stop",
|
fStop = new DrawButton(BRect(0, 0, 1, 1), "Stop",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"stop_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"stop_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_down"),
|
||||||
new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||||
fStop->ResizeToPreferred();
|
fStop->ResizeToPreferred();
|
||||||
fStop->MoveTo(10, box->Frame().bottom + 15);
|
fStop->MoveTo(10, box->Frame().bottom + 15);
|
||||||
fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"stop_disabled"));
|
fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_disabled"));
|
||||||
AddChild(fStop);
|
AddChild(fStop);
|
||||||
float stopTop = fStop->Frame().top;
|
float stopTop = fStop->Frame().top;
|
||||||
|
|
||||||
|
|
||||||
fPlay = new TwoStateDrawButton(BRect(0,0,1,1), "Play",
|
fPlay = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Play",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_up_on"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up_on"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"),
|
||||||
new BMessage(M_PLAY), B_FOLLOW_NONE, B_WILL_DRAW);
|
new BMessage(M_PLAY), B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
|
|
||||||
fPlay->ResizeToPreferred();
|
fPlay->ResizeToPreferred();
|
||||||
fPlay->MoveTo(fStop->Frame().right + 2, stopTop);
|
fPlay->MoveTo(fStop->Frame().right + 2, stopTop);
|
||||||
AddChild(fPlay);
|
AddChild(fPlay);
|
||||||
|
|
||||||
fPrevTrack = new DrawButton(BRect(0,0,1,1), "PrevTrack",
|
fPrevTrack = new DrawButton(BRect(0, 0, 1, 1), "PrevTrack",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"prev_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"prev_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_down"),
|
||||||
new BMessage(M_PREV_TRACK), 0,
|
new BMessage(M_PREV_TRACK), 0, B_WILL_DRAW);
|
||||||
B_WILL_DRAW);
|
|
||||||
fPrevTrack->ResizeToPreferred();
|
fPrevTrack->ResizeToPreferred();
|
||||||
fPrevTrack->MoveTo(fPlay->Frame().right + 20, stopTop);
|
fPrevTrack->MoveTo(fPlay->Frame().right + 20, stopTop);
|
||||||
AddChild(fPrevTrack);
|
AddChild(fPrevTrack);
|
||||||
|
|
||||||
fNextTrack = new DrawButton(BRect(0,0,1,1), "NextTrack",
|
fNextTrack = new DrawButton(BRect(0, 0, 1, 1), "NextTrack",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"next_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"next_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_down"),
|
||||||
new BMessage(M_NEXT_TRACK), 0,
|
new BMessage(M_NEXT_TRACK), 0, B_WILL_DRAW);
|
||||||
B_WILL_DRAW);
|
|
||||||
fNextTrack->ResizeToPreferred();
|
fNextTrack->ResizeToPreferred();
|
||||||
fNextTrack->MoveTo(fPrevTrack->Frame().right + 1, stopTop);
|
fNextTrack->MoveTo(fPrevTrack->Frame().right + 1, stopTop);
|
||||||
AddChild(fNextTrack);
|
AddChild(fNextTrack);
|
||||||
|
|
||||||
fRewind = new DoubleShotDrawButton(BRect(0,0,1,1), "Rewind",
|
fRewind = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "Rewind",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_down"),
|
||||||
new BMessage(M_REWIND), 0, B_WILL_DRAW);
|
new BMessage(M_REWIND), 0, B_WILL_DRAW);
|
||||||
fRewind->ResizeToPreferred();
|
fRewind->ResizeToPreferred();
|
||||||
fRewind->MoveTo(fNextTrack->Frame().right + 20, stopTop);
|
fRewind->MoveTo(fNextTrack->Frame().right + 20, stopTop);
|
||||||
AddChild(fRewind);
|
AddChild(fRewind);
|
||||||
|
|
||||||
fFastFwd = new DoubleShotDrawButton(BRect(0,0,1,1), "FastFwd",
|
fFastFwd = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "FastFwd",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_down"),
|
||||||
new BMessage(M_FFWD), 0, B_WILL_DRAW);
|
new BMessage(M_FFWD), 0, B_WILL_DRAW);
|
||||||
fFastFwd->ResizeToPreferred();
|
fFastFwd->ResizeToPreferred();
|
||||||
fFastFwd->MoveTo(fRewind->Frame().right + 1, stopTop);
|
fFastFwd->MoveTo(fRewind->Frame().right + 1, stopTop);
|
||||||
AddChild(fFastFwd);
|
AddChild(fFastFwd);
|
||||||
|
|
||||||
r.left = 10;
|
r.left = 10;
|
||||||
r.right = fPlay->Frame().right;
|
r.right = fPlay->Frame().right;
|
||||||
r.top = fStop->Frame().bottom + 14;
|
r.top = fStop->Frame().bottom + 14;
|
||||||
r.bottom = r.top + kVolumeSliderBitmapHeight - 1.0;
|
r.bottom = r.top + kVolumeSliderBitmapHeight - 1.0;
|
||||||
fVolumeSlider = new VolumeSlider(r,"VolumeSlider",0,255, new BMessage(M_SET_VOLUME),
|
fVolumeSlider = new VolumeSlider(r, "VolumeSlider",
|
||||||
this);
|
0, 255, new BMessage(M_SET_VOLUME), this);
|
||||||
fVolumeSlider->ResizeToPreferred();
|
fVolumeSlider->ResizeToPreferred();
|
||||||
AddChild(fVolumeSlider);
|
AddChild(fVolumeSlider);
|
||||||
|
|
||||||
fRepeat = new TwoStateDrawButton( BRect(0,0,1,1), "Repeat",
|
fRepeat = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Repeat",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"repeat_up_off"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_off"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"repeat_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"repeat_up_on"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_on"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"repeat_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"),
|
||||||
new BMessage(M_REPEAT), B_FOLLOW_NONE, B_WILL_DRAW);
|
new BMessage(M_REPEAT), B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
fRepeat->ResizeToPreferred();
|
fRepeat->ResizeToPreferred();
|
||||||
fRepeat->MoveTo(fPrevTrack->Frame().left,
|
fRepeat->MoveTo(fPrevTrack->Frame().left, fVolumeSlider->Frame().top -
|
||||||
fVolumeSlider->Frame().top -
|
((fRepeat->Frame().Height() - fVolumeSlider->Frame().Height()) / 2));
|
||||||
((fRepeat->Frame().Height() - fVolumeSlider->Frame().Height()) / 2));
|
|
||||||
AddChild(fRepeat);
|
AddChild(fRepeat);
|
||||||
|
|
||||||
fShuffle = new TwoStateDrawButton(BRect(0,0,1,1), "Shuffle",
|
fShuffle = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Shuffle",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"shuffle_up_off"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_off"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"shuffle_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"shuffle_up_on"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_on"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"shuffle_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"),
|
||||||
new BMessage(M_SHUFFLE), B_FOLLOW_NONE, B_WILL_DRAW);
|
new BMessage(M_SHUFFLE), B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
fShuffle->ResizeToPreferred();
|
fShuffle->ResizeToPreferred();
|
||||||
fShuffle->MoveTo(fRepeat->Frame().right + 2,fRepeat->Frame().top);
|
fShuffle->MoveTo(fRepeat->Frame().right + 2, fRepeat->Frame().top);
|
||||||
AddChild(fShuffle);
|
AddChild(fShuffle);
|
||||||
|
|
||||||
fEject = new DrawButton(BRect(0,0,1,1), "Eject",
|
fEject = new DrawButton(BRect(0, 0, 1, 1), "Eject",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "eject_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_down"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "eject_down"),
|
||||||
new BMessage(M_EJECT), 0, B_WILL_DRAW);
|
new BMessage(M_EJECT), 0, B_WILL_DRAW);
|
||||||
fEject->ResizeToPreferred();
|
fEject->ResizeToPreferred();
|
||||||
fEject->MoveTo(fFastFwd->Frame().left, fShuffle->Frame().top);
|
fEject->MoveTo(fFastFwd->Frame().left, fShuffle->Frame().top);
|
||||||
AddChild(fEject);
|
AddChild(fEject);
|
||||||
|
|
||||||
ResizeTo(box->Frame().right + 10, fVolumeSlider->Frame().bottom + 10);
|
ResizeTo(box->Frame().right + 10, fVolumeSlider->Frame().bottom + 10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,44 +248,45 @@ void
|
|||||||
CDPlayer::MessageReceived(BMessage *msg)
|
CDPlayer::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case M_SET_VOLUME: {
|
case M_SET_VOLUME:
|
||||||
fCDDrive.SetVolume(fVolumeSlider->Value());
|
fCDDrive.SetVolume(fVolumeSlider->Value());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_STOP: {
|
case M_STOP:
|
||||||
if (fWindowState == kPaused) {
|
if (fWindowState == kPaused) {
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_up"),
|
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_down"));
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
||||||
fPlay->SetState(1);
|
fPlay->SetState(1);
|
||||||
}
|
}
|
||||||
fWindowState = kStopped;
|
fWindowState = kStopped;
|
||||||
fCDDrive.Stop();
|
fCDDrive.Stop();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_PLAY: {
|
case M_PLAY:
|
||||||
// If we are currently playing, then we will be showing
|
// If we are currently playing, then we will be showing
|
||||||
// the pause images and will want to switch back to the play images
|
// the pause images and will want to switch back to the play images
|
||||||
if (fWindowState == kPlaying) {
|
if (fWindowState == kPlaying) {
|
||||||
fWindowState = kPaused;
|
fWindowState = kPaused;
|
||||||
fCDDrive.Pause();
|
fCDDrive.Pause();
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,"paused_up"),
|
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "paused_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_down"));
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
||||||
} else if (fWindowState == kPaused) {
|
} else if (fWindowState == kPaused) {
|
||||||
fWindowState = kPlaying;
|
fWindowState = kPlaying;
|
||||||
fCDDrive.Resume();
|
fCDDrive.Resume();
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_up"),
|
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"play_down"));
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
||||||
} else {
|
} else {
|
||||||
fWindowState = kPlaying;
|
fWindowState = kPlaying;
|
||||||
fCDDrive.Play(fPlayList.GetCurrentTrack());
|
fCDDrive.Play(fPlayList.GetCurrentTrack());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_EJECT: {
|
case M_EJECT:
|
||||||
fCDDrive.Eject();
|
fCDDrive.Eject();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_NEXT_TRACK: {
|
case M_NEXT_TRACK:
|
||||||
|
{
|
||||||
int16 next = fPlayList.GetNextTrack();
|
int16 next = fPlayList.GetNextTrack();
|
||||||
if (next <= 0) {
|
if (next <= 0) {
|
||||||
// force a "wrap around" when possible. This makes it
|
// force a "wrap around" when possible. This makes it
|
||||||
@@ -290,11 +294,11 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
// back to the first track from the last one with 1 button push
|
// back to the first track from the last one with 1 button push
|
||||||
next = fPlayList.GetFirstTrack();
|
next = fPlayList.GetFirstTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next > 0) {
|
if (next > 0) {
|
||||||
CDState state = fCDDrive.GetState();
|
CDState state = fCDDrive.GetState();
|
||||||
if (state == kPlaying) {
|
if (state == kPlaying) {
|
||||||
while(!fCDDrive.Play(next)) {
|
while (!fCDDrive.Play(next)) {
|
||||||
next = fPlayList.GetNextTrack();
|
next = fPlayList.GetNextTrack();
|
||||||
if (next < 1) {
|
if (next < 1) {
|
||||||
fWindowState = kStopped;
|
fWindowState = kStopped;
|
||||||
@@ -312,11 +316,13 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
fPlayList.SetCurrentTrack(next);
|
fPlayList.SetCurrentTrack(next);
|
||||||
|
|
||||||
// Force an update for better responsiveness
|
// Force an update for better responsiveness
|
||||||
WatchCDState();
|
_WatchCDState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case M_PREV_TRACK: {
|
|
||||||
|
case M_PREV_TRACK:
|
||||||
|
{
|
||||||
int16 prev = fPlayList.GetPreviousTrack();
|
int16 prev = fPlayList.GetPreviousTrack();
|
||||||
if (prev <= 0) {
|
if (prev <= 0) {
|
||||||
// force a "wrap around" when possible. This makes it
|
// force a "wrap around" when possible. This makes it
|
||||||
@@ -324,11 +330,11 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
// back to the first track from the last one with 1 button push
|
// back to the first track from the last one with 1 button push
|
||||||
prev = fPlayList.GetLastTrack();
|
prev = fPlayList.GetLastTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev > 0) {
|
if (prev > 0) {
|
||||||
CDState state = fCDDrive.GetState();
|
CDState state = fCDDrive.GetState();
|
||||||
if (state == kPlaying) {
|
if (state == kPlaying) {
|
||||||
while(!fCDDrive.Play(prev)) {
|
while (!fCDDrive.Play(prev)) {
|
||||||
prev = fPlayList.GetPreviousTrack();
|
prev = fPlayList.GetPreviousTrack();
|
||||||
if (prev < 1) {
|
if (prev < 1) {
|
||||||
fWindowState = kStopped;
|
fWindowState = kStopped;
|
||||||
@@ -344,25 +350,26 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
fPlayList.SetCurrentTrack(prev);
|
fPlayList.SetCurrentTrack(prev);
|
||||||
|
|
||||||
// Force an update for better responsiveness
|
// Force an update for better responsiveness
|
||||||
WatchCDState();
|
_WatchCDState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case M_FFWD: {
|
|
||||||
|
case M_FFWD:
|
||||||
if (fFastFwd->Value() == B_CONTROL_ON)
|
if (fFastFwd->Value() == B_CONTROL_ON)
|
||||||
fCDDrive.StartFastFwd();
|
fCDDrive.StartFastFwd();
|
||||||
else
|
else
|
||||||
fCDDrive.StopFastFwd();
|
fCDDrive.StopFastFwd();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_REWIND: {
|
case M_REWIND:
|
||||||
if (fRewind->Value() == B_CONTROL_ON)
|
if (fRewind->Value() == B_CONTROL_ON)
|
||||||
fCDDrive.StartRewind();
|
fCDDrive.StartRewind();
|
||||||
else
|
else
|
||||||
fCDDrive.StopRewind();
|
fCDDrive.StopRewind();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_SHUFFLE: {
|
case M_SHUFFLE:
|
||||||
if (fPlayList.IsShuffled()) {
|
if (fPlayList.IsShuffled()) {
|
||||||
int16 track = fPlayList.GetCurrentTrack();
|
int16 track = fPlayList.GetCurrentTrack();
|
||||||
fPlayList.SetShuffle(false);
|
fPlayList.SetShuffle(false);
|
||||||
@@ -375,8 +382,8 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
fShuffle->SetState(1);
|
fShuffle->SetState(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case M_REPEAT: {
|
case M_REPEAT:
|
||||||
if (fPlayList.IsLoop()) {
|
if (fPlayList.IsLoop()) {
|
||||||
fPlayList.SetLoop(false);
|
fPlayList.SetLoop(false);
|
||||||
fRepeat->SetState(0);
|
fRepeat->SetState(0);
|
||||||
@@ -385,11 +392,11 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
fRepeat->SetState(1);
|
fRepeat->SetState(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,203 +419,206 @@ CDPlayer::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
CDPlayer::Pulse()
|
CDPlayer::Pulse()
|
||||||
{
|
{
|
||||||
WatchCDState();
|
_WatchCDState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CDPlayer::WatchCDState(void)
|
CDPlayer::_WatchCDState()
|
||||||
{
|
{
|
||||||
// One watcher function to rule them all
|
// One watcher function to rule them all
|
||||||
|
|
||||||
// first, watch the one setting independent of having a CD: volume
|
// first, watch the one setting independent of having a CD: volume
|
||||||
uint8 drivevolume = fCDDrive.GetVolume();
|
uint8 driveVolume = fCDDrive.GetVolume();
|
||||||
if (fVolume == drivevolume) {
|
if (fVolume == driveVolume) {
|
||||||
fVolume = drivevolume;
|
fVolume = driveVolume;
|
||||||
fVolumeSlider->SetValue(fVolume);
|
fVolumeSlider->SetValue(fVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second, establish whether or not we have a CD in the drive
|
// Second, establish whether or not we have a CD in the drive
|
||||||
CDState playstate = fCDDrive.GetState();
|
CDState playState = fCDDrive.GetState();
|
||||||
bool internal_track_change = false;
|
bool internalTrackChange = false;
|
||||||
|
|
||||||
if (playstate == kNoCD) {
|
if (playState == kNoCD) {
|
||||||
// Yes, we have no bananas!
|
// Yes, we have no bananas!
|
||||||
|
|
||||||
// Do something only if there is a change in the app's play state
|
// Do something only if there is a change in the app's play state
|
||||||
if (fWindowState != kNoCD) {
|
if (fWindowState != kNoCD) {
|
||||||
// We have just discovered that we have no bananas
|
// We have just discovered that we have no bananas
|
||||||
fWindowState = kNoCD;
|
fWindowState = kNoCD;
|
||||||
|
|
||||||
// Because we are changing play states, we will need to update the GUI
|
// Because we are changing play states, we will need to update the GUI
|
||||||
fCDData.SetDiscID(-1);
|
fCDData.SetDiscID(-1);
|
||||||
SetLabel(fCDTitle,"CD drive is empty");
|
SetLabel(fCDTitle, "CD drive is empty");
|
||||||
|
|
||||||
SetLabel(fCurrentTrack,"");
|
SetLabel(fCurrentTrack, "");
|
||||||
SetLabel(fTrackTime,"Track: --:-- / --:--");
|
SetLabel(fTrackTime, "Track: --:-- / --:--");
|
||||||
SetLabel(fDiscTime,"Disc: --:-- / --:--");
|
SetLabel(fDiscTime, "Disc: --:-- / --:--");
|
||||||
fPlayList.SetTrackCount(0);
|
fPlayList.SetTrackCount(0);
|
||||||
fPlayList.SetStartingTrack(1);
|
fPlayList.SetStartingTrack(1);
|
||||||
fPlayList.SetCurrentTrack(1);
|
fPlayList.SetCurrentTrack(1);
|
||||||
|
|
||||||
if (fPlay->GetState() == 1)
|
if (fPlay->GetState() == 1)
|
||||||
fPlay->SetState(0);
|
fPlay->SetState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now otherwise handle the play state
|
// Now otherwise handle the play state
|
||||||
if (playstate == kStopped) {
|
if (playState == kStopped) {
|
||||||
if (fWindowState == kPlaying) {
|
if (fWindowState == kPlaying) {
|
||||||
internal_track_change = true;
|
internalTrackChange = true;
|
||||||
|
|
||||||
// This means that the drive finished playing the song, so get the next one
|
// This means that the drive finished playing the song, so get the next one
|
||||||
// from the list and play it
|
// from the list and play it
|
||||||
int16 next = fPlayList.GetNextTrack();
|
int16 next = fPlayList.GetNextTrack();
|
||||||
if (next > 0)
|
if (next > 0)
|
||||||
fCDDrive.Play(next);
|
fCDDrive.Play(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlay->GetState() == 1)
|
if (fPlay->GetState() == 1)
|
||||||
fPlay->SetState(0);
|
fPlay->SetState(0);
|
||||||
} else if (playstate == kPlaying) {
|
} else if (playState == kPlaying) {
|
||||||
if (fPlay->GetState() == 0)
|
if (fPlay->GetState() == 0)
|
||||||
fPlay->SetState(1);
|
fPlay->SetState(1);
|
||||||
} else if (playstate == kPaused) {
|
} else if (playState == kPaused)
|
||||||
fPlay->SetState(0);
|
fPlay->SetState(0);
|
||||||
}
|
|
||||||
|
|
||||||
// If we got this far, then there must be a CD in the drive. The next order on the agenda
|
// If we got this far, then there must be a CD in the drive. The next order on the agenda
|
||||||
// is to find out which CD it is
|
// is to find out which CD it is
|
||||||
int32 discid = fCDDrive.GetDiscID();
|
int32 discId = fCDDrive.GetDiscID();
|
||||||
bool update_track_gui = false;
|
bool updateTrackGui = false;
|
||||||
|
|
||||||
if (discid != fCDData.DiscID()) {
|
if (discId != fCDData.DiscID()) {
|
||||||
update_track_gui = true;
|
updateTrackGui = true;
|
||||||
|
|
||||||
// Apparently the disc has changed since we last looked.
|
// Apparently the disc has changed since we last looked.
|
||||||
if (fCDQuery.CurrentDiscID() != discid)
|
if (fCDQuery.CurrentDiscID() != discId)
|
||||||
fCDQuery.SetToCD(fCDDrive.GetDrivePath());
|
fCDQuery.SetToCD(fCDDrive.GetDrivePath());
|
||||||
|
|
||||||
if (fCDQuery.Ready()) {
|
if (fCDQuery.Ready()) {
|
||||||
// Note that we only update the CD title for now. We still need a track number
|
// Note that we only update the CD title for now. We still need a track number
|
||||||
// in order to update the display for the selected track
|
// in order to update the display for the selected track
|
||||||
if (fCDQuery.GetData(&fCDData, 1000000)) {
|
if (fCDQuery.GetData(&fCDData, 1000000)) {
|
||||||
BString display(fCDData.Artist());
|
BString display(fCDData.Artist());
|
||||||
display << " - " << fCDData.Album();
|
display << " - " << fCDData.Album();
|
||||||
SetLabel(fCDTitle,display.String());
|
SetLabel(fCDTitle, display.String());
|
||||||
} else {
|
} else
|
||||||
SetLabel(fCDTitle,"Audio CD");
|
SetLabel(fCDTitle, "Audio CD");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we know which CD it is, update the track info
|
// Now that we know which CD it is, update the track info
|
||||||
int16 drivecount = fCDDrive.CountTracks();
|
int16 driveCount = fCDDrive.CountTracks();
|
||||||
int16 drivetrack = fCDDrive.GetTrack();
|
int16 driveTrack = fCDDrive.GetTrack();
|
||||||
|
|
||||||
int16 playlisttrack = fPlayList.GetCurrentTrack();
|
int16 playlistTrack = fPlayList.GetCurrentTrack();
|
||||||
int16 playlistcount = fPlayList.TrackCount();
|
int16 playlistCount = fPlayList.TrackCount();
|
||||||
|
|
||||||
if (playstate == kPlaying) {
|
if (playState == kPlaying) {
|
||||||
if (playlisttrack != drivetrack) {
|
if (playlistTrack != driveTrack) {
|
||||||
playlisttrack = drivetrack;
|
playlistTrack = driveTrack;
|
||||||
|
|
||||||
if (!internal_track_change) {
|
if (!internalTrackChange) {
|
||||||
// The main thing is that we need to make sure that the playlist and the drive's track
|
// The main thing is that we need to make sure that the playlist and the drive's track
|
||||||
// stay in sync. The CD's track may have been changed by an outside source, so if
|
// stay in sync. The CD's track may have been changed by an outside source, so if
|
||||||
// the drive is playing, check for playlist sync.
|
// the drive is playing, check for playlist sync.
|
||||||
fPlayList.SetTrackCount(drivecount);
|
fPlayList.SetTrackCount(driveCount);
|
||||||
fPlayList.SetCurrentTrack(drivetrack);
|
fPlayList.SetCurrentTrack(driveTrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_track_gui = true;
|
updateTrackGui = true;
|
||||||
} else {
|
} else {
|
||||||
if (playlistcount != drivecount) {
|
if (playlistCount != driveCount) {
|
||||||
// This happens only when CDs are changed
|
// This happens only when CDs are changed
|
||||||
if (drivecount < 0) {
|
if (driveCount < 0) {
|
||||||
// There is no CD in the drive. The playlist needs to have its track
|
// There is no CD in the drive. The playlist needs to have its track
|
||||||
// count set to 0 and it also needs to be rewound.
|
// count set to 0 and it also needs to be rewound.
|
||||||
fPlayList.SetStartingTrack(1);
|
fPlayList.SetStartingTrack(1);
|
||||||
fPlayList.SetTrackCount(0);
|
fPlayList.SetTrackCount(0);
|
||||||
playlisttrack = 1;
|
playlistTrack = 1;
|
||||||
playlistcount = 0;
|
playlistCount = 0;
|
||||||
} else {
|
} else {
|
||||||
// Two possible cases here: playlist is empty or playlist has a different
|
// Two possible cases here: playlist is empty or playlist has a different
|
||||||
// number of tracks. In either case, the playlist needs to be reinitialized
|
// number of tracks. In either case, the playlist needs to be reinitialized
|
||||||
// to the current track data
|
// to the current track data
|
||||||
fPlayList.SetStartingTrack(1);
|
fPlayList.SetStartingTrack(1);
|
||||||
fPlayList.SetTrackCount(drivecount);
|
fPlayList.SetTrackCount(driveCount);
|
||||||
playlisttrack = fPlayList.GetCurrentTrack();
|
playlistTrack = fPlayList.GetCurrentTrack();
|
||||||
playlistcount = drivecount;
|
playlistCount = driveCount;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// update only with a track change
|
// update only with a track change
|
||||||
if (playlisttrack != drivetrack)
|
if (playlistTrack != driveTrack)
|
||||||
update_track_gui = true;
|
updateTrackGui = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_track_gui) {
|
if (updateTrackGui) {
|
||||||
BString currentTrackName;
|
BString currentTrackName;
|
||||||
|
|
||||||
if (playlisttrack >= 0) {
|
if (playlistTrack >= 0) {
|
||||||
int16 whichtrack = playlisttrack;
|
int16 whichTrack = playlistTrack;
|
||||||
|
|
||||||
if (whichtrack == 0)
|
if (whichTrack == 0)
|
||||||
whichtrack++;
|
whichTrack++;
|
||||||
|
|
||||||
currentTrackName << "Track " << whichtrack << ": " << fCDData.TrackAt(whichtrack-1);
|
currentTrackName << "Track " << whichTrack << ": " << fCDData.TrackAt(whichTrack - 1);
|
||||||
|
|
||||||
SetLabel(fCurrentTrack,currentTrackName.String());
|
SetLabel(fCurrentTrack, currentTrackName.String());
|
||||||
|
|
||||||
} else {
|
} else
|
||||||
SetLabel(fCurrentTrack,"");
|
SetLabel(fCurrentTrack, "");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now update the time info
|
// Now update the time info
|
||||||
cdaudio_time tracktime;
|
CDAudioTime trackTime;
|
||||||
cdaudio_time disctime;
|
CDAudioTime discTime;
|
||||||
cdaudio_time tracktotal;
|
CDAudioTime trackTotal;
|
||||||
cdaudio_time disctotal;
|
CDAudioTime discTotal;
|
||||||
char timestring[1024];
|
char timeString[1024];
|
||||||
|
|
||||||
if (fCDDrive.GetTime(tracktime, disctime)) {
|
if (fCDDrive.GetTime(trackTime, discTime)) {
|
||||||
fCDDrive.GetTimeForDisc(disctotal);
|
fCDDrive.GetTimeForDisc(discTotal);
|
||||||
sprintf(timestring,"Disc: %ld:%.2ld / %ld:%.2ld",disctime.minutes,disctime.seconds,
|
sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld", discTime.GetMinutes(),
|
||||||
disctotal.minutes,disctotal.seconds);
|
discTime.GetSeconds(), discTotal.GetMinutes(), discTotal.GetSeconds());
|
||||||
SetLabel(fDiscTime,timestring);
|
SetLabel(fDiscTime, timeString);
|
||||||
|
|
||||||
fCDDrive.GetTimeForTrack(playlisttrack,tracktotal);
|
fCDDrive.GetTimeForTrack(playlistTrack, trackTotal);
|
||||||
sprintf(timestring,"Track: %ld:%.2ld / %ld:%.2ld",tracktime.minutes,tracktime.seconds,
|
sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld", trackTime.GetMinutes(),
|
||||||
tracktotal.minutes,tracktotal.seconds);
|
trackTime.GetSeconds(), trackTotal.GetMinutes(), trackTotal.GetSeconds());
|
||||||
SetLabel(fTrackTime,timestring);
|
SetLabel(fTrackTime, timeString);
|
||||||
} else {
|
} else {
|
||||||
SetLabel(fTrackTime,"Track: --:-- / --:--");
|
SetLabel(fTrackTime, "Track: --:-- / --:--");
|
||||||
SetLabel(fDiscTime,"Disc: --:-- / --:--");
|
SetLabel(fDiscTime, "Disc: --:-- / --:--");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CDPlayerWindow::CDPlayerWindow(void)
|
// #pragma mark -
|
||||||
: BWindow(BRect (100, 100, 405, 280), "CD Player", B_TITLED_WINDOW, B_NOT_RESIZABLE |
|
|
||||||
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
|
||||||
|
CDPlayerWindow::CDPlayerWindow()
|
||||||
|
: BWindow(BRect (100, 100, 405, 280), "CD Player", B_TITLED_WINDOW, B_NOT_RESIZABLE |
|
||||||
|
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CDPlayerWindow::QuitRequested(void)
|
CDPlayerWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
CDPlayerApplication::CDPlayerApplication()
|
CDPlayerApplication::CDPlayerApplication()
|
||||||
: BApplication("application/x-vnd.Haiku-CDPlayer")
|
: BApplication("application/x-vnd.Haiku-CDPlayer")
|
||||||
{
|
{
|
||||||
BWindow *window = new CDPlayerWindow();
|
BWindow *window = new CDPlayerWindow();
|
||||||
BView *view = new CDPlayer(window->Bounds(), "CD");
|
BView *view = new CDPlayer(window->Bounds(), "CD");
|
||||||
|
|||||||
@@ -7,84 +7,81 @@
|
|||||||
#ifndef CDPLAYER_H
|
#ifndef CDPLAYER_H
|
||||||
#define CDPLAYER_H
|
#define CDPLAYER_H
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
|
|
||||||
#include "CDAudioDevice.h"
|
#include "CDAudioDevice.h"
|
||||||
#include "CDDBSupport.h"
|
#include "CDDBSupport.h"
|
||||||
#include "PlayList.h"
|
#include "PlayList.h"
|
||||||
#include "VolumeSlider.h"
|
#include "VolumeSlider.h"
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class DrawButton;
|
class DrawButton;
|
||||||
class DoubleShotDrawButton;
|
class DoubleShotDrawButton;
|
||||||
class TwoStateDrawButton;
|
class TwoStateDrawButton;
|
||||||
|
|
||||||
class CDPlayer : public BView
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDPlayer(BRect frame, const char *name,
|
|
||||||
uint32 resizeMask = B_FOLLOW_ALL,
|
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE |
|
|
||||||
B_PULSE_NEEDED);
|
|
||||||
virtual ~CDPlayer();
|
|
||||||
|
|
||||||
void BuildGUI(void);
|
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void Pulse();
|
|
||||||
virtual void MessageReceived(BMessage *);
|
|
||||||
|
|
||||||
private:
|
class CDPlayer : public BView {
|
||||||
void WatchCDState(void);
|
public:
|
||||||
|
CDPlayer(BRect frame, const char *name, uint32 resizeMask = B_FOLLOW_ALL,
|
||||||
DrawButton *fStop,
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED);
|
||||||
*fNextTrack,
|
virtual ~CDPlayer();
|
||||||
*fPrevTrack,
|
|
||||||
*fEject;
|
void BuildGUI();
|
||||||
|
|
||||||
DoubleShotDrawButton
|
virtual void AttachedToWindow();
|
||||||
*fFastFwd,
|
virtual void Pulse();
|
||||||
*fRewind;
|
virtual void MessageReceived(BMessage *);
|
||||||
|
|
||||||
TwoStateDrawButton *fShuffle,
|
private:
|
||||||
*fRepeat,
|
void _WatchCDState();
|
||||||
*fPlay;
|
|
||||||
|
DrawButton *fStop,
|
||||||
VolumeSlider *fVolumeSlider;
|
*fNextTrack,
|
||||||
|
*fPrevTrack,
|
||||||
BStringView *fCDTitle,
|
*fEject;
|
||||||
*fCurrentTrack,
|
|
||||||
*fTrackTime,
|
DoubleShotDrawButton
|
||||||
*fDiscTime;
|
*fFastFwd,
|
||||||
|
*fRewind;
|
||||||
BBox *fCDBox,
|
|
||||||
*fTrackBox,
|
TwoStateDrawButton *fShuffle,
|
||||||
*fTimeBox;
|
*fRepeat,
|
||||||
|
*fPlay;
|
||||||
CDState fCDState;
|
|
||||||
|
VolumeSlider *fVolumeSlider;
|
||||||
rgb_color fStopColor;
|
|
||||||
rgb_color fPlayColor;
|
BStringView *fCDTitle,
|
||||||
|
*fCurrentTrack,
|
||||||
CDAudioDevice fCDDrive;
|
*fTrackTime,
|
||||||
PlayList fPlayList;
|
*fDiscTime;
|
||||||
CDState fWindowState;
|
|
||||||
CDDBQuery fCDQuery;
|
BBox *fCDBox,
|
||||||
CDDBData fCDData;
|
*fTrackBox,
|
||||||
uint8 fVolume;
|
*fTimeBox;
|
||||||
|
|
||||||
|
CDState fCDState;
|
||||||
|
|
||||||
|
rgb_color fStopColor;
|
||||||
|
rgb_color fPlayColor;
|
||||||
|
|
||||||
|
CDAudioDevice fCDDrive;
|
||||||
|
PlayList fPlayList;
|
||||||
|
CDState fWindowState;
|
||||||
|
CDDBQuery fCDQuery;
|
||||||
|
CDDBData fCDData;
|
||||||
|
uint8 fVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CDPlayerApplication : public BApplication
|
class CDPlayerApplication : public BApplication {
|
||||||
{
|
public:
|
||||||
public:
|
CDPlayerApplication();
|
||||||
CDPlayerApplication();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif // CDPLAYER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user