回放资源服务管理

com.talkfun.cloudlivepublish.vod.VODResServiceManager

 /**
     * 绑定启动回放资源管理服务
     * @param context
     * @param callback ServiceConnection回调
     * @return
     */
public static boolean bindService(Context context,final ServiceConnection callback);

 /**
     * 解绑启动回放资源管理服务
     * @param context
     */
 public static void unBindService(Context context);


/**
 * 在上传回放页--获取所有的课程上传信息
 *
 * @return List<CourseUploadInfo> 上传资源信息列表
 */
public static List<CourseUploadInfo> getCourseUploadInfos()


/**
 * 上传全部的课程回放资源
 */
public static void uploadAll()

/**
     * 上传指定课程回放资源
     *
     * @param courseId 课程id
     */
    public static void upload(String courseId) ;

    /**
     * 上传指定课程回放资源
     * @param uploadInfo 课程上传信息
     */
    public static void upload(CourseUploadInfo uploadInfo);

    /**
     * 重新上传指定课程回放资源
     * @param courseId 课程id
     */
    public static void reUpload(String courseId);

    /**
     * 重新上传指定课程回放资源
     * @param uploadInfo 课程上传信息
     */
    public static void reUpload(CourseUploadInfo uploadInfo) ;

    /**
     * 暂停上传指定课程回放资源
     * @param courseId 课程id
     */
    public static void pause(String courseId) ;

    /**
     * 暂停上传指定课程回放资源
     * @param uploadInfo 课程上传信息
     */
    public static void pause(CourseUploadInfo uploadInfo);

    /**
     * 暂停上传所有课程回放资源
     */
    public static void pauseAll() ;

    /**
     * 判断课程是否正在上传回放资源
     * @param uploadInfo 课程上传信息
     * @return
     */
    public static boolean isUploading(CourseUploadInfo uploadInfo);

    /**
     * 判断课程是否正在上传回放资源
     * @param courseId 课程id
     * @return
     */
    public static boolean isUploading(String courseId);

    /**
     * 获取所有上传课程回放资源信息
     * @return
     */
    public static List<CourseUploadInfo> getCourseUploadInfos();

    /**
     * 删除课程上传数据
     * @param courseId 课程id
     */
    public static void deleteCourseData(String courseId);

    /**
     * 删除课程上传数据
     * @param uploadInfo 上传信息
     */
    public static void deleteCourseData(CourseUploadInfo uploadInfo);

    /**
     * 设置课程上传状态改变监听
     * @param courseId 课程id
     * @param listener 状态监听
     */
    public static void setOnCourseUploadStatusChangeListener(String courseId, OnCourseUploadStatusChangeListener listener);

    /**
     * 删除所有课程上传状态改变监听
     */
    public static void removeAllOnCourseUploadStateListener();    //回放资源上传列表的适配器
class MyUploadAdapter extends UploadAdapter<UploadInfoBean> {
        public MyUploadAdapter(@NonNull Context context, @LayoutRes int resource, List list) {
            super(context, resource, list);
        }

        @Override
        public void onBindViewHolder(ViewHolder holder, int position) {
                //添加观察对象
             PlaybackResServiceManager.getInstance(context)
                             .addObserver(uploadInfoBean.courseId, holder);  
        }
 }

 class ViewHolder implements PlaybackResServiceManager.UploadObserver{
        public ViewHolder(Context context) {
            ......
        }
           //实现该方法
        @Override
        public void onUploadInfoChange(final UploadInfoBean uploadInfoBean) {
         if (uploadInfoBean.state == UploadInfoBean.State.SUCCESS_UPLOAD) {
            //移除上传完成的对象
             PlaybackResServiceManager.getInstance(context)
                             .removeObserver(uploadInfoBean.courseId);
                CommomUtil.showShortToast("上传成功");
            }
            ......
        }
 }

 @Override
    protected void onDestroy() {
        super.onDestroy();
        //移除所有观察对象
        PlaybackResServiceManager.getInstance(UploadActivity.this).removeAllObserver();
    }

上传信息

com.talkfun.cloudlivepublish.model.bean.CourseUploadInfo

public class CourseUploadInfo implements Parcelable{

    //上传的课程title
    public String title;

    //上传的课程id
    public String courseId;

    //上传的状态
    public int state;

    //上传的完成的大小
    public long finishSize;

    //文件总大小
    public long totalSize;

}

回放资源上传状态

com.talkfun.cloudlivepublish.consts.VODResUploadStatus

public class VODResUploadStatus {
    public final static int UN_UPLOAD = 1;   //还未上传
    public final static int LIVEING = 0; //正在直播中
    public final static int UN_COMPRESS = 1;   //还未压缩
    public final static int COMPRESSING = 2;  //压缩中
    public final static int SUCCESS_COMPRESS = 3;  //压缩成功

    public final static int UN_UPLOAD = 4;   //还未上传
    public final static int PAUSE_UPLOAD = 5;   //暂停上传
    public final static int WAITING_UPLOAD = 6;  //等待上传
    public final static int UPLOADING = 7;    //正在上传
    public final static int FAIL_UPLOAD = 8;  //上传失败
    public final static int SUCCESS_UPLOAD = 9;  //上传成功
}

results matching ""

    No results matching ""