source: branches/classes/mm-progs/volume/display.c

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 5.8 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 2002
3 * It is part of the MediaFolder package
4 */
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20/*
21 * If you need another license for your project/product (commercial,
22 * noncommercial, whatever) contact me at
23 *
24 * http://www.os2world.com/cdwriting
25 * http://www.geocities.com/SiliconValley/Sector/5785/
26 *
27 */
28
29#define INCL_GPILCIDS
30#define INCL_GPIPRIMITIVES
31#define INCL_GPIBITMAPS
32#define INCL_GPILOGCOLORTABLE
33#define INCL_SW
34#define INCL_GPIREGIONS
35#define INCL_WIN
36
37#include <os2.h>
38
39#include "common.h"
40#include "mmres.h"
41#include "mmplayer.h"
42#include <stdio.h>
43#include <stdlib.h>
44
45/* 0: time, 1: remaining, 2: filename */
46extern int iWhichDisplay;
47/* Display timer for changing between track info */
48extern ULONG ulDisplayTimer;
49extern ULONG ulTotalLength;
50/* Current time in track */
51extern ULONG ulPos;
52char * chrPtrName; /* Pointer to filename */
53
54void _resetDisplay(HWND hwndFrame)
55{
56 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), "0:00");
57 //WinSetWindowULong(WinWindowFromID(WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDST_PLAYTIME), QWL_USER, 0);
58 WinPostMsg( WinWindowFromID(hwndFrame, IDSL_MMPLAYERPOSBAR),
59 SLM_SETSLIDERINFO,
60 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
61 MPFROMLONG(0L));
62}
63
64
65
66/* Set the text in the playtime area to 'theText' */
67void setPlayTimeText2( HWND hwndDialog, char * theText)
68{
69 WinSetWindowText(WinWindowFromID(hwndDialog, IDST_MMPLAYERPLAYTIME), theText);
70}
71
72
73/* Toggle the visibility of the text in the playtime area. Useful for blinking. */
74void togglePlayTimeDisplayVisibility(HWND hwndFrame)
75{
76 if(WinIsWindowVisible(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME)))
77 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), FALSE);
78 else
79 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), TRUE);
80}
81
82
83/* Show/hide the text in the playtime area. Useful for blinking. */
84void showPlayTimeDisplay(HWND hwndFrame, BOOL bShow)
85{
86 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), bShow);
87}
88
89
90/* This funktion sets the playtime display according to the user settings.
91 Supported are remaining time, elapsed time and ID3-tag display */
92void setPlayTimeText(hwndFrame)
93{
94 char text[CCHMAXPATH];
95 ULONG ulTemp;
96
97 switch(iWhichDisplay)
98 {
99 case 1:
100 /* Remaining */
101 ulTemp=ulTotalLength/1000-ulPos;
102 sprintf(text,"-%d:%02d",
103 (int)ulTemp/60,
104 (int)ulTemp%60);
105 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
106 break;
107
108 case 2:
109 {
110 ULONG ulTemp=ulDisplayTimer;
111
112 /* Show filename */
113 text[0]=0;
114
115 if(ulTemp>=3)
116 text[0]=0;
117 else if(ulTemp>=0)
118 strcpy(text, chrPtrName);
119
120#if 0
121 else
122 ulTemp=15; /* Show playtime for midi files */
123#endif
124
125 if(ulTemp>=3||!strlen(text)) {
126 /* Play time */
127 sprintf(text,"%d:%02d",
128 (int)ulPos/60,
129 (int)ulPos%60);
130 }
131 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
132 ulTemp++;
133 if(ulTemp>=6)
134 ulTemp=0;
135 ulDisplayTimer=ulTemp;
136 break;
137
138#if 0
139 /* Show ID3 tag */
140 cwAudio=thisPtr->cwQueryCurrentlyPlayingObject();
141 if(somIsObj(cwAudio)) {
142 if(!methodPtr)
143 somhlpQueryCWAudioMethodPtr(thisPtr);
144 sprintf(text,"");
145 if(methodPtr && somIsObj(cwAudioClass) && cwAudio->somIsA(cwAudioClass) ){/* Query playtime in secs */
146 char* chrPtr=text;
147 text[0]=0;
148
149 if(ulTemp>=15)
150 text[0]=0;
151 else if(ulTemp>=12)
152 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_GENRE);
153 else if(ulTemp>=9)
154 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_COMMENT);
155 else if(ulTemp>=6)
156 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_ALBUM);
157 else if(ulTemp>=3)
158 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_NAME);
159 else if(ulTemp>=0)
160 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_ARTIST);
161 }
162 else
163 ulTemp=15; /* Show playtime for midi files */
164
165 if(ulTemp>=15||!strlen(text)) {
166 /* Play time */
167 sprintf(text,"%d:%02d",
168 thisPtr->ulPos/60,
169 thisPtr->ulPos%60);
170 }
171 WinSetWindowText(WinWindowFromID(thisPtr->hwndTopMiddle, IDST_PLAYTIME), text);
172 ulTemp++;
173 if(ulTemp>=18)
174 ulTemp=0;
175 ulDisplayTimer=ulTemp;
176 break;
177 }
178#endif
179 }
180 /* Fall through to playtime */
181 case 0:
182 /* Elapsed time */
183 sprintf(text,"%d:%02d",
184 (int)ulPos/60,
185 (int)ulPos%60);
186 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
187 break;
188 default:
189 break;
190 }
191}
192
Note: See TracBrowser for help on using the repository browser.