Currently in blender 2.8 you can not use Animation Player, because the immediatemode is not initialized.
I tried to initialize and finalize the imm in the WM_main_playanim function, but apparently it is only possible to initialize it after calling playanim_window_open.
With this solution, immediate mode can be initialized and finalized consecutively, and I do not know if this is problematic.
https://docs.blender.org/manual/en/dev/render/output/animation_player.html