danog/MadelineProto

Parameters $speed and $time will always 0 when we use callback for uploadTo* methods!

mtalaeii opened this issue · 0 comments

Description

When we use parameter callback (or cb with messages.sendMedia) with uploadTo* or send* (for media methods only !sendVideo sendAudio and ...)
The parameters $speed and $time will always eqauls to 0 and doesn't changed on upload progress
Its happen about FileCallback class to!!! (and remember it was only affect on upload proccess its ok for downloadTo* methods)

Reproduce

use the code below

$videoUrl  = 'http://t1.dl150m.ir/filmjadid/Talk.to.Me.2022.480p.WEB-DL.PAHE.Farsi.Sub.Film2Media.mkv';
$sent      = $message->sendText('Start');
$this->sendVideo(
    peer   : $message->chatId,
    file   : $message->getReply()->media,
    callback: static function (float $progress,float $speed,float $time) use ($sent): void {
        static $prev = 0;
        $now = time();
        if ($now - $prev < 3 && $progress < 100) {
            return;
        }

        $prev = $now;
        try {
            $sent->editText("[$progress%]\n[$time s]\n[$speed Mb/s]");
        } catch (danog\MadelineProto\RPCErrorException $e) {

        }
    }
);