public function remoteVideoByIdAction(Request $request)
 {
     $id = $request->request->get('id');
     $player = new PolyvVideo();
     $data = $player->getNewList($id);
     $videos = json_decode($data, true);
     $videos = $videos['data'];
     return $this->render('TopxiaAdminBundle:Remote:video-item-list.html.twig', array('videos' => $videos));
 }
 public function updateCourseLessonsAction(Request $request, $id)
 {
     $player = new PolyvVideo();
     $course = $this->getCourseService()->tryManageCourse($id);
     $jsonLessons = $player->getNewList($course["catetree"]);
     $jsonLessons = json_decode($jsonLessons, true);
     $lessons = array_reverse($jsonLessons['data']);
     $lessonNum = $course['lessonNum'];
     if ($lessonNum < $jsonLessons['total']) {
         for ($i = $lessonNum; $i <= $jsonLessons['total']; $i++) {
             //课程的同步数总不能大于 远程的课件总数 (备注:本地如果删除视频会同步删除远程的)
             $lesson = ArrayToolkit::parts($lessons[$i], array('title', 'duration', 'vid', 'first_image'));
             $lesson['courseId'] = $id;
             $lesson['type'] = "video";
             $this->getCourseService()->createLesson($lesson);
         }
         $course['lessonNum'] = $jsonLessons['total'];
         $this->getCourseService()->updateCourse($id, $course);
     }
     $response = array('success' => true, 'message' => '课程同步成功');
     return $this->createJsonResponse($response);
 }
 public function deleteAction(Request $request, $courseId, $lessonId)
 {
     $course = $this->getCourseService()->tryManageCourse($courseId);
     $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId);
     $player = new PolyvVideo();
     echo $lesson['vid'];
     $remoteLessonDelete = $player->deleteRemoteLesson($lesson['vid']);
     var_dump($remoteLessonDelete);
     if ($course['type'] == 'live') {
         $client = LiveClientFactory::createClient();
         $result = $client->deleteLive($lesson['mediaId'], $lesson['liveProvider']);
         $this->getCourseService()->deleteCourseLessonReplayByLessonId($lessonId);
     }
     $this->getCourseService()->deleteLesson($course['id'], $lessonId);
     //$this->getCourseMaterialService()->deleteMaterialsByLessonId($lessonId);
     return $this->createJsonResponse(true);
 }