How to add a slider that allows you to control FuncAnimation?

I need a way that allows the QSlider slider/slider to control the animation.

The animation runs continuously and the slider also moves behind the current frame. At any moment I should be able to rewind the animation using the slider to the frame I need. The code in which you want to embed the slider:

import matplotlib
import numpy as np
from PyQt5 import QtCore, QtWidgets

# Make sure that we are using QT5
matplotlib.use('Qt5Agg')
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.animation as animation


class MyMplCanvas(FigureCanvas):
    def __init__(self, slider, parent=None, width=5, height=4, dpi=100):
        self.slider = slider  # Save reference to the slider
        self.slider_is_manual = False  # Flag to track if slider change is manual
        fig = Figure(figsize=(width, height), dpi=dpi)

        ax = fig.add_subplot(111)    # The big subplot
        self.ax = fig.add_subplot(211)
        self.bx = fig.add_subplot(212)

        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                                   QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

        ax.set_title('TMP102 Temperature over Time')
        ax.spines['top'].set_color('none')
        ax.spines['bottom'].set_color('none')
        ax.spines['left'].set_color('none')
        ax.spines['right'].set_color('none')
        ax.tick_params(labelcolor='w', top=False, bottom=False, left=False, right=False)
        ax.set_xlabel('Samples')
        ax.set_ylabel('Temperature (deg C)')

        self.x_len = 200         # Number of points to display
        self.y_range = [10, 40]  # Range of possible Y values to display
        self.xs = list(range(0, 200))

        self.ys = [0 for _ in range(self.x_len)]

        frames = np.arange(0, 200)
        self.anim = animation.FuncAnimation(fig, self.animate, frames=frames, init_func=self.init, interval=50, blit=True, repeat=False)

        # Connect the slider to the update_frame method
        self.slider.valueChanged.connect(self.update_frame)

    def init(self):
        y_range = [10, 40]
        self.ax.set_ylim(*y_range)
        self.bx.set_ylim(*y_range)
        self.line, = self.ax.plot(self.xs, self.ys)
        self.line2, = self.bx.plot(self.xs, self.ys)
        return self.line, self.line2

    def animate(self, i):
        temp_c = random.randint(15, 35)
        self.ys.append(temp_c)
        self.ys = self.ys[-self.x_len:]
        self.line.set_ydata(self.ys)
        self.line2.set_ydata(self.ys)
        if not self.slider_is_manual:
            self.slider.blockSignals(True)
            self.slider.setValue(i)  # Update slider value
            self.slider.blockSignals(False)
        return self.line, self.line2

    def update_frame(self, i):
        if self.slider_is_manual:
            temp_c = random.randint(15, 35)
            self.ys.append(temp_c)
            self.ys = self.ys[-self.x_len:]
            self.line.set_ydata(self.ys)
            self.line2.set_ydata(self.ys)
            self.draw()

    def start_manual_update(self):
        self.slider_is_manual = True

    def end_manual_update(self):
        self.slider_is_manual = False


class ApplicationWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super(ApplicationWindow, self).__init__(parent)
        main_widget = QtWidgets.QWidget()
        l = QtWidgets.QVBoxLayout(main_widget)

        self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.slider.setRange(0, 199)
        l.addWidget(self.slider)

        sc = MyMplCanvas(self.slider, main_widget, width=5, height=4, dpi=100)
        l.addWidget(sc)
        self.setCentralWidget(main_widget)

        # Connect signals to handle manual slider updates
        self.slider.sliderPressed.connect(sc.start_manual_update)
        self.slider.sliderReleased.connect(sc.end_manual_update)


if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)

    w = ApplicationWindow()
    w.show()
    sys.exit(app.exec_())```

I have no idea, how realize this. 

I try QMediaPlayer, but for my issue I need interaction between ```QSlider``` and ```FuncAnimation```

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật