public synchronized void playVideoModel(final DownloadEntry video) { try { if (playerFragment.isPlaying()) { if (video.getVideoId().equals(playerFragment.getPlayingVideo().getVideoId())) { logger.debug("this video is already being played, skipping play event"); return; } } } catch (Exception ex) { } try { if (playerFragment == null) { return; } // set callback for player events if (playerFragment != null) { playerFragment.setCallback(this); } playerFragment.setPrevNxtListners(next, prev); // reload this model environment.getStorage().reloadDownloadEntry(video); logger.debug("Resumed= " + playerFragment.isResumed()); if (!playerFragment.isResumed()) { // playback can work only if fragment is resume if (playPending != null) { playHandler.removeCallbacks(playPending); } playPending = new Runnable() { public void run() { playVideoModel(video); } }; playHandler.postDelayed(playPending, 200); return; } else { if (playPending != null) { playHandler.removeCallbacks(playPending); } } TranscriptModel transcript = null; try { transcript = environment.getServiceManager().getTranscriptsOfVideo(video.eid, video.videoId); } catch (Exception e) { logger.error(e); } String filepath = null; // check if file available on local if (video.filepath != null && video.filepath.length() > 0) { if (video.isDownloaded()) { File f = new File(video.filepath); if (f.exists()) { // play from local filepath = video.filepath; logger.debug("Playing from local file"); } } } else { DownloadEntry de = (DownloadEntry) environment.getDatabase().getIVideoModelByVideoUrl(video.url, null); if (de != null) { if (de.filepath != null) { File f = new File(de.filepath); if (f.exists()) { // play from local filepath = de.filepath; logger.debug("Playing from local file for " + "another Download Entry"); } } } } if (filepath == null || filepath.length() <= 0) { // not available on local, so play online logger.warn("Local file path not available"); filepath = video.getBestEncodingUrl(this); } playerFragment.play(filepath, video.lastPlayedOffset, video.getTitle(), transcript, video); } catch (Exception e) { logger.error(e); } }