Then yesterday's broadcast said
Yesterday's playback can only be accurate to the second level. After testing, I found that it needs to be accurate to the level of milliseconds (at least 100 milliseconds) so that people can't hear any problems.
So I researched and found that I can use the file size / bit rate * 8 to get a more accurate playback time (my own demand is to control it to 100ms)
int bps = 0, timeLength;
float size = 0.0, fBase = 0.1;
int base = 1, index = 0;
string bpsValue = ptrFolder->GetDetailsOf(_variant_t((IDispatch *)ptrItem), 28);
string fileSize = ptrFolder->GetDetailsOf(_variant_t((IDispatch *)ptrItem), 1);
for (int i = bpsValue.size() - 1; i >= 0; i--)
{
char bpsChar = bpsValue[i];
if (bpsChar >= '0' && '9' >= bpsChar)
{
bps = bps + (bpsChar - '0') * base;
base *= 10;
}
}
base = 1;
//Calculate decimals first and then integers
//In the case of decimals
index = fileSize.find_first_of('.');
if (index != -1)
{
for (int i = index + 1; i < fileSize.size(); i++)
{
char sizeChar = fileSize[i];
if (sizeChar >= '0' && '9' >= sizeChar)
{
size = size + (sizeChar - '0') * fBase;
fBase *= 0.1;
}
}
}
else
{
index = fileSize.size();
}
for (int i = index - 1; i >= 0; i--)
{
char sizeChar = fileSize[i];
if (sizeChar >= '0' && '9' >= sizeChar)
{
size = size + (sizeChar - '0') * base;
base *= 10;
}
}
//Accuracy in 100MS units
timeLength = size / bps * 8 * 10;
timeLength = timeLength * 100;
Write very casually, please advise