Repository: godot
Issue: AnimationTree does not stop playing looping AnimationPlayer's Animation Playback tracks
Labels: bug,enhancement,usability,topic:animation

### Godot version

4.0-beta9

### System information

Windows 10

### Issue description

If a SkeletalMesh has an AnimationPlayer with a looping Animation with Animation Playback Track that loops, here called "Outer Loop":

![imagen](https://user-images.githubusercontent.com/248383/208613618-de7bc71a-937f-4d97-8383-7cd7fb4a9dce.png)

... and the base "Loop" animation:

![imagen](https://user-images.githubusercontent.com/248383/208613695-720c57fd-e2b3-4d4e-ba39-a1468238f43a.png)

...then when the "OuterLoop" is played by an AnimationTree, the AnimationTree will never stop playing "Outer Loop" even after the tree reaches the end state or if you tree to transition to another state, clearly seem by this video:

https://user-images.githubusercontent.com/248383/208615084-bf4947e3-5fbc-4e55-8ce6-50dbeca2de8c.mp4

#### Working Scenario
As a comparison, the AnimationTree correctly transitions:
- If you play the looping "Loop" animation directly (not via a Playback Track).
- If you play a non-looping Animation Playback Track.

Sample working - the looping animation correctly stops:

https://user-images.githubusercontent.com/248383/208615238-97a00283-d315-43c7-b5fa-751f35e0d901.mp4

### Steps to reproduce

- NOTICE: the steps are similar to the ones from #69930 but they are adjusted here to reproduce THIS bug.
- Import a skeletal mesh with at least two animations, one animation MUST be set to Linear Looping.
- Create an Inherited Scene from the Mesh
- Add an `AnimationTree `and an `AnimationPlayer`
- Create two animations in the AnimationPlayer

![imagen](https://user-images.githubusercontent.com/248383/206927519-4f468f7e-2e9f-4867-9345-ce24e349e5c1.png)

**Animation 1 (ex: "TurnOn)"**:
- Add an `AnimationPlayback` Track, and insert a key playing an animation from the inherited `AnimationPlayer`

**Animation 2 (ex: "Outer Loop)"**:
- Add an `AnimationPlayback` Track, and insert a key playing the "Loop" animation from the inherited `AnimationPlayer`
- Make the "Outer Loop" animation set to loop.

![imagen](https://user-images.githubusercontent.com/248383/208617742-39497a44-a138-4579-86b5-7fbb573033ff.png)

**AnimationTree**:
- Add a State Machine as the root
- Select the custom AnimationPlayer as the `Anim Player` param
- Add a state for each one of the animations
- Add a transition to End the "Outer Loop" animation
- Then click the arrow next to End, to simulate the AnimationTree
- State will transition until the end, but the loop will keep playing

![imagen](https://user-images.githubusercontent.com/248383/208616046-3d3f49d6-bfd1-4cfd-95c2-27b1d73cb8e4.png)


### Minimal reproduction project

### Minimal reproduction project

NOTICE: the reproduction project is similar to the one from #69930 but it's adjusted here to reproduce THIS bug, the attached file is a new project for this bug.

[OuterLoopAnimationDemo.zip](https://github.com/godotengine/godot/files/10266554/OuterLoopAnimationDemo.zip)

Updated for 4.0.1: [OuterLoopAnimationDemo-4.0.1.zip](https://github.com/godotengine/godot/files/11037432/OuterLoopAnimationDemo-4.0.1.zip)

- **AnimationPlayerOriginal.tscn** (red machine): the Inherited scene from the `MachineMock.glb` mesh, with an AnimationTree, using the original AnimationPlayer. **This scene works correctly and simulates the "Working Scenario" described above.**
- **AnimationPlayerCustom.tscn**: the inherited scene with the **steps that lead to the bug**. This scene has the scenario with custom animation player and that reproduces the steps I mentioned, **and it doesn't work correctly**.
- **RunTest.tscn**: run to see it at runtime.

The **Red Machine correctly loops and stops** ("Working Scenario").

The **White Machine is the one bugged**, it loops and never stops.

![imagen](https://user-images.githubusercontent.com/248383/206927781-84a6b543-01e6-4b41-9bd4-40b7265419ef.png)