use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class CourseUnitVideoFragment method onPlaybackComplete.
public void onPlaybackComplete() {
try {
DownloadEntry v = videoModel;
if (v != null && v.watched == DownloadEntry.WatchedState.PARTIALLY_WATCHED) {
videoModel.watched = DownloadEntry.WatchedState.WATCHED;
// mark this as partially watches, as playing has started
DatabaseFactory.getInstance(DatabaseFactory.TYPE_DATABASE_NATIVE).updateVideoWatchedState(v.videoId, DownloadEntry.WatchedState.WATCHED, watchedStateCallback);
}
} catch (Exception ex) {
logger.error(ex);
}
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class CourseUnitVideoFragment method getVideoPath.
private String getVideoPath(DownloadEntry video) {
String filepath = null;
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) DatabaseFactory.getInstance(DatabaseFactory.TYPE_DATABASE_NATIVE).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 (TextUtils.isEmpty(filepath)) {
// not available on local, so play online
logger.warn("Local file path not available");
filepath = video.getBestEncodingUrl(getActivity());
}
return filepath;
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testupdateDownloadingVideoInfoByVideoId.
@Test
public void testupdateDownloadingVideoInfoByVideoId() throws Exception {
db.clearDataByUser(username);
DownloadEntry model = getDummyVideoModel();
db.updateDownloadingVideoInfoByVideoId(model, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 0);
print("Result for update Downloading Video Info By VideoId for 0= " + result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.downloaded = DownloadedState.DOWNLOADING;
de.id = 1;
db.addVideoData(de, null);
db.updateDownloadingVideoInfoByVideoId(de, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 1);
print("Result for update Downloading Video Info By VideoId for 1= " + result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testisDmIdExists.
@Test
public void testisDmIdExists() throws Exception {
db.clearDataByUser(username);
final long dmId = 1;
db.isDmIdExists(dmId, new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertFalse("DmId should not be present for " + dmId, result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.dmId = 1;
db.addVideoData(de, null);
db.isDmIdExists(dmId, new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertTrue("DmId should be present for " + dmId, result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testupdateVideosActivatedForCourse.
@Test
public void testupdateVideosActivatedForCourse() throws Exception {
db.clearDataByUser(username);
String enrollmentId = "enrollmentId";
db.updateVideosActivatedForCourse(enrollmentId, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 0);
// assertFalse("something is downloading", result);
print("Result for update Videos Activated For Course is:" + result.intValue());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.eid = "enrollmentId";
db.addVideoData(de, null);
db.updateVideosActivatedForCourse(enrollmentId, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 1);
// assertFalse("something is downloading", result);
print("Result for update Videos Activated For Course is:" + result.intValue());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
Aggregations