class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(500, 360)
        self.button_play = QtWidgets.QPushButton(Form)
        self.button_play.setGeometry(QtCore.QRect(9, 290, 40, 40))
        self.button_play.setText("")
        icon = QtGui.QIcon.fromTheme("SP_MediaPlay")
        self.button_play.setIcon(icon)
        self.button_play.setObjectName("button_play")
        self.button_play.setIcon(self.style().standardIcon(
            QStyle.SP_MediaPlay))
        self.video = None
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.video = QMacCocoaViewContainer(0, parent=Form)
        else:
            self.video = QtWidgets.QFrame(parent=Form)
        self.video.setGeometry(QtCore.QRect(9, 0, 500, 280))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.video.sizePolicy().hasHeightForWidth())
        self.video.setSizePolicy(sizePolicy)
        self.video.setObjectName("video")
        self.button_pause = QtWidgets.QPushButton(Form)
        self.button_pause.setGeometry(QtCore.QRect(54, 290, 40, 40))
        self.button_pause.setText("")
        self.button_pause.setObjectName("button_pause")
        self.button_pause.setIcon(self.style().standardIcon(
            QStyle.SP_MediaPause))
        self.time_slider = QtWidgets.QSlider(Form)
        self.time_slider.setGeometry(QtCore.QRect(140, 300, 301, 22))
        self.time_slider.setOrientation(QtCore.Qt.Horizontal)
        self.time_slider.setObjectName("time_slider")
        self.label_time_passed = QtWidgets.QLabel(Form)
        self.label_time_passed.setGeometry(QtCore.QRect(100, 300, 61, 20))
        self.label_time_passed.setObjectName("label_time_passed")
        self.label_time_left = QtWidgets.QLabel(Form)
        self.label_time_left.setGeometry(QtCore.QRect(450, 300, 60, 16))
        self.label_time_left.setObjectName("label_time_left")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.label_time_passed.setText(_translate("Form", "00:00"))
        self.label_time_left.setText(_translate("Form", "-00:00"))
    def createUI(self):
        """Set up the user interface, signals & slots
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)
        self.widget.setStyleSheet("background: '#EEEEEE';")

        image_path = os.getcwd() + "/mamaro/babybedPNG/login0.png"
        image_profile = QtGui.QImage(image_path)  #QImage object

        lbl1 = QtWidgets.QLabel('bluetoothstate', self)
        lbl1.setObjectName('bluetoothstate')
        lbl1.setPixmap(QtGui.QPixmap.fromImage(image_profile))
        lbl1.setScaledContents(True)
        lbl1.setGeometry(48, 38, 195, 120)
        lbl1.resize(lbl1.sizeHint())

        #create background
        lbl1 = QtWidgets.QLabel('back1', self)
        lbl1.setObjectName('back1')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(0, 120, 297, 296)

        lbl1 = QtWidgets.QLabel('back2', self)
        lbl1.setObjectName('back2')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(0, 420, 297, 296)

        lbl1 = QtWidgets.QLabel('back3', self)
        lbl1.setObjectName('back3')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(0, 720, 297, 296)
        #create background

        #create icon
        image_path = os.getcwd() + "/mamaro/babybedPNG/height0.png"
        image_profile = QtGui.QImage(image_path)  #QImage object

        lbl1 = QtWidgets.QLabel('heighticon', self)
        lbl1.setObjectName('heighticon')
        lbl1.setPixmap(QtGui.QPixmap.fromImage(image_profile))
        lbl1.setScaledContents(True)
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(91, 180, 115, 104)

        image_path = os.getcwd() + "/mamaro/babybedPNG/weight0.png"
        image_profile = QtGui.QImage(image_path)  #QImage object

        lbl1 = QtWidgets.QLabel('weighticon', self)
        lbl1.setObjectName('weighticon')
        lbl1.setPixmap(QtGui.QPixmap.fromImage(image_profile))
        lbl1.setScaledContents(True)
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(91, 480, 115, 104)

        image_path = os.getcwd() + "/mamaro/babybedPNG/temp0.png"
        image_profile = QtGui.QImage(image_path)  #QImage object

        lbl1 = QtWidgets.QLabel('tempicon', self)
        lbl1.setObjectName('tempicon')
        lbl1.setPixmap(QtGui.QPixmap.fromImage(image_profile))
        lbl1.setScaledContents(True)
        lbl1.setStyleSheet("background: 'white';")
        lbl1.setGeometry(91, 780, 115, 104)
        # lbl1.resize(lbl1.sizeHint());

        #create text
        lbl1 = None

        lbl1 = QtWidgets.QLabel('heighttext', self)
        lbl1.setObjectName('heighttext')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("color:#9EA2A2;")
        #lbl1.setAlignment(QtCore.Qt.AlignTop)
        lbl1.setAlignment(QtCore.Qt.AlignCenter)
        lbl1.setGeometry(91, 314, 115, 46)

        lbl1 = QtWidgets.QLabel('weighttext', self)
        lbl1.setObjectName('weighttext')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("color:#9EA2A2;")
        #lbl1.setAlignment(QtCore.Qt.AlignTop)
        lbl1.setAlignment(QtCore.Qt.AlignCenter)
        lbl1.setGeometry(91, 614, 115, 52)

        lbl1 = QtWidgets.QLabel('temptext', self)
        lbl1.setObjectName('temptext')
        lbl1.setText("")
        lbl1.setFont(QtGui.QFont("ms gothic", 28))
        lbl1.setStyleSheet("color:#9EA2A2;")
        #lbl1.setAlignment(QtCore.Qt.AlignTop)
        lbl1.setAlignment(QtCore.Qt.AlignCenter)
        lbl1.setGeometry(91, 914, 115, 46)

        lbl1 = QtWidgets.QLabel('contentcover', self)
        lbl1.setObjectName('contentcover')
        lbl1.setText("")
        lbl1.setCursor(Qt.PointingHandCursor)
        lbl1.setGeometry(0, 0, 297, 1080)

        lbl1.mousePressEvent = self.contentclick

        # In this widget, the video will be drawn
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            videoframe = QMacCocoaViewContainer(0)
        else:
            videoframe = QtWidgets.QFrame(self)
        self.palette = videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        videoframe.setObjectName('videoview')
        videoframe.setPalette(self.palette)
        videoframe.setAutoFillBackground(True)
        videoframe.mousePressEvent = self.contentclick
        videoframe.setGeometry(QtCore.QRect(298, 0, 1622, 1080))

        global connection, roomid, readcheck, playlist, sorted_x, totalfile, oneloopindex, totalindexx, checkonetime, strings2, cou
        self.OpenFile(strings2[cou])
        insertdata(sorted_x[cou].DBindex, sorted_x[cou].playindex, totalindexx)
        cou += 1
        totalindexx += 1
        print(self.mediaplayer.get_state())