use Tcl::Tk; use MPV::Simple; my $int =Tcl::Tk->new(); my $mw = $int->mainwindow(); # Bind MPV Event to the event handler $mw->bind('<>' => \&on_mpv); my $f = $mw->Frame(-background => "green",-width => 640, -height => 480)->pack(-expand =>1,-fill => "both"); my $id; $id = $f->id(); # MPV part $MPV::Simple::callback_data=$f; my $ctx = MPV::Simple->new(); $ctx->initialize(); $ctx->set_wakeup_callback(\&wakeup_callback, \$f); $ctx->set_property_string("wid",$id); $ctx->command("loadfile", "./einladung2.mp4"); $mw->Button(-text => "Restart", -command => sub {$ctx->command("loadfile", "./einladung2.mp4")})->pack; $int->MainLoop(); # Wake up callback sub wakeup_callback { print "IN WAKEUP\n"; $int->Eval("event generate $f <> -when head" or die "Did not work\n"); return; } # Event handler sub on_mpv { print "YEAH, im Event handler\n"; return }