source: branches/classes/mm-progs/MMPlayer/display.c@ 222

Last change on this file since 222 was 104, checked in by gyoung, 23 months ago

Remaining changes from merge with Lars 2.9 branch

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#include <string.h>
45
46/* 0: time, 1: remaining, 2: filename */
47extern int iWhichDisplay;
48/* Display timer for changing between track info */
49extern ULONG ulDisplayTimer;
50extern ULONG ulTotalLength;
51/* Current time in track */
52extern ULONG ulPos;
53char * chrPtrName; /* Pointer to filename */
54
55void _resetDisplay(HWND hwndFrame)
56{
57 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), "0:00");
58 //WinSetWindowULong(WinWindowFromID(WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDST_PLAYTIME), QWL_USER, 0);
59 WinPostMsg( WinWindowFromID(hwndFrame, IDSL_MMPLAYERPOSBAR),
60 SLM_SETSLIDERINFO,
61 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
62 MPFROMLONG(0L));
63}
64
65
66
67/* Set the text in the playtime area to 'theText' */
68void setPlayTimeText2( HWND hwndDialog, char * theText)
69{
70 WinSetWindowText(WinWindowFromID(hwndDialog, IDST_MMPLAYERPLAYTIME), theText);
71}
72
73
74/* Toggle the visibility of the text in the playtime area. Useful for blinking. */
75void togglePlayTimeDisplayVisibility(HWND hwndFrame)
76{
77 if(WinIsWindowVisible(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME)))
78 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), FALSE);
79 else
80 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), TRUE);
81}
82
83
84/* Show/hide the text in the playtime area. Useful for blinking. */
85void showPlayTimeDisplay(HWND hwndFrame, BOOL bShow)
86{
87 WinShowWindow(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), bShow);
88}
89
90
91/* This function sets the playtime display according to the user settings.
92 Supported are remaining time, elapsed time and ID3-tag display */
93void setPlayTimeText(HWND hwndFrame)
94{
95 char text[CCHMAXPATH];
96 ULONG ulTemp;
97
98 switch(iWhichDisplay)
99 {
100 case 1:
101 /* Remaining */
102 ulTemp=ulTotalLength/1000-ulPos;
103 sprintf(text,"-%d:%02d",
104 (int)ulTemp/60,
105 (int)ulTemp%60);
106 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
107 break;
108
109 case 2:
110 {
111 ULONG ulTemp=ulDisplayTimer;
112
113 /* Show filename */
114 text[0]=0;
115
116 if(ulTemp>=3)
117 text[0]=0;
118 else if(ulTemp>=0)
119 strcpy(text, chrPtrName);
120
121#if 0
122 else
123 ulTemp=15; /* Show playtime for midi files */
124#endif
125
126 if(ulTemp>=3||!strlen(text)) {
127 /* Play time */
128 sprintf(text,"%d:%02d",
129 (int)ulPos/60,
130 (int)ulPos%60);
131 }
132 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
133 ulTemp++;
134 if(ulTemp>=6)
135 ulTemp=0;
136 ulDisplayTimer=ulTemp;
137 break;
138
139#if 0
140 /* Show ID3 tag */
141 cwAudio=thisPtr->cwQueryCurrentlyPlayingObject();
142 if(somIsObj(cwAudio)) {
143 if(!methodPtr)
144 somhlpQueryCWAudioMethodPtr(thisPtr);
145 sprintf(text,"");
146 if(methodPtr && somIsObj(cwAudioClass) && cwAudio->somIsA(cwAudioClass) ){/* Query playtime in secs */
147 char* chrPtr=text;
148 text[0]=0;
149
150 if(ulTemp>=15)
151 text[0]=0;
152 else if(ulTemp>=12)
153 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_GENRE);
154 else if(ulTemp>=9)
155 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_COMMENT);
156 else if(ulTemp>=6)
157 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_ALBUM);
158 else if(ulTemp>=3)
159 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_NAME);
160 else if(ulTemp>=0)
161 methodPtr(cwAudio, &chrPtr, sizeof(text), IDINFO_ARTIST);
162 }
163 else
164 ulTemp=15; /* Show playtime for midi files */
165
166 if(ulTemp>=15||!strlen(text)) {
167 /* Play time */
168 sprintf(text,"%d:%02d",
169 thisPtr->ulPos/60,
170 thisPtr->ulPos%60);
171 }
172 WinSetWindowText(WinWindowFromID(thisPtr->hwndTopMiddle, IDST_PLAYTIME), text);
173 ulTemp++;
174 if(ulTemp>=18)
175 ulTemp=0;
176 ulDisplayTimer=ulTemp;
177 break;
178 }
179#endif
180 }
181 /* Fall through to playtime */
182 case 0:
183 /* Elapsed time */
184 sprintf(text,"%d:%02d",
185 (int)ulPos/60,
186 (int)ulPos%60);
187 WinSetWindowText(WinWindowFromID(hwndFrame, IDST_MMPLAYERPLAYTIME), text);
188 break;
189 default:
190 break;
191 }
192}
193
Note: See TracBrowser for help on using the repository browser.