admin
2020-08-12 cefe2a41db4a275fb1e940a902cb156f1ed68d80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
/*
 * Copyright © 2012-2013 LiuZhongnan. All rights reserved.
 * 
 * Email:qq81595157@126.com
 * 
 * PROPRIETARY/CONFIDENTIAL.
 */
 
package com.youku.service.download;
 
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
 
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
 
import com.baseproject.utils.Logger;
import com.youku.player.YoukuPlayerConfiguration;
import com.youku.player.util.PlayerUtil;
 
/**
 * DownloadManager.缓存管理
 * 
 * @author 刘仲男 qq81595157@126.com
 * @version v3.5
 * @created time 2012-11-5 下午1:16:02
 */
public class DownloadManager extends BaseDownload {
 
    private static final String TAG = "Download_Manager";
 
//    private AcceleraterManager acceleraterManager;
    
    private static DownloadManager instance;
 
    private OnChangeListener listener;
 
    // 服务接口
    private IDownloadService downloadService;
 
    /** 已缓存完成的对象列表 */
    private static HashMap<String, DownloadInfo> downloadedData;
 
    private ICallback mCallback = new ICallback.Stub() {
 
        @Override
        public void onChanged(DownloadInfo info) throws RemoteException {
            if (listener != null)
                listener.onChanged(info);
        }
 
        @Override
        public void onFinish(DownloadInfo info) throws RemoteException {
            if (downloadedData != null)
                downloadedData.put(info.videoid,
                        getDownloadInfoBySavePath(info.savePath));
            if (listener != null)
                listener.onFinish();
        }
 
        @Override
        public void refresh() throws RemoteException {
            downloadedData = getNewDownloadedData();
        }
 
    };
 
    // 服务绑定器
    private ServiceConnection sConnect = new ServiceConnection() {
 
        @Override
        public void onServiceDisconnected(ComponentName name) {
            Logger.d(TAG, "onServiceDisconnected() called");
        }
 
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            // 绑定到服务
            Logger.d(TAG, "onServiceConnected() called");
            downloadService = IDownloadService.Stub.asInterface(service);
            try {
                downloadService.registerCallback(mCallback);
            } catch (RemoteException e) {
                Logger.e(TAG, e);
            }
        }
    };
 
    public synchronized static DownloadManager getInstance() {
        if (instance == null) {
            Logger.d(TAG, "getInstance()");
            instance = new DownloadManager(YoukuPlayerConfiguration.context);
        }
        return instance;
    }
 
    private DownloadManager(Context context) {
//        acceleraterManager = AcceleraterManager.getInstance(context);
//        setDownloadPath();
        this.context = context;
        bindService(context);
    }
 
    private void bindService(Context context) {
        Intent intent = new Intent(context, DownloadService.class);
        context.bindService(intent, sConnect, Context.BIND_AUTO_CREATE);
    }
 
    public void unregister() {
        try {
            downloadService.unregister();
        } catch (RemoteException e) {
            Logger.e(TAG, e);
        }catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    public void setOnChangeListener(OnChangeListener listener) {
        this.listener = listener;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public HashMap<String, DownloadInfo> getDownloadingData() {
        if (downloadService != null) {
            try {
                return (HashMap<String, DownloadInfo>) downloadService
                        .getDownloadingData();
            } catch (RemoteException e) {
                Logger.e(TAG, e);
            }
        }
 
        HashMap<String, DownloadInfo> downloadingData = new HashMap<String, DownloadInfo>();
        if (sdCard_list == null
                && (sdCard_list = SDCardManager.getExternalStorageDirectory()) == null) {
            return downloadingData;
        }
        for (int j = 0; j < sdCard_list.size(); j++) {
            File dir = new File(sdCard_list.get(j).path + YoukuPlayerConfiguration.getDownloadPath());
            if (!dir.exists())
                continue;
            String[] dirs = dir.list();
            for (int i = dirs.length - 1; i >= 0; i--) {
                String vid = dirs[i];
                DownloadInfo info = getDownloadInfoBySavePath(sdCard_list
                        .get(j).path + YoukuPlayerConfiguration.getDownloadPath() + vid + "/");
                if (info != null
                        && info.getState() != DownloadInfo.STATE_FINISH
                        && info.getState() != DownloadInfo.STATE_CANCEL) {
                    // info.downloadListener = new DownloadListenerImpl(context,
                    // info);
                    downloadingData.put(info.taskId, info);
                }
            }
        }
        return downloadingData;
    }
 
    /**
     * 已经完成的视频缓存列表
     * 
     * @return Map<String, DownloadInfo>
     */
    public HashMap<String, DownloadInfo> getDownloadedData() {
//        if (downloadedData == null) {
            downloadedData = getNewDownloadedData();
//        }
        return downloadedData;
    }
 
    private HashMap<String, DownloadInfo> getNewDownloadedData() {
        downloadedData = new HashMap<String, DownloadInfo>();
        if ((sdCard_list = SDCardManager.getExternalStorageDirectory()) == null) {
            return downloadedData;
        }
        for (int j = 0; j < sdCard_list.size(); j++) {
            File dir = new File(sdCard_list.get(j).path + YoukuPlayerConfiguration.getDownloadPath());
            if (!dir.exists())
                continue;
            String[] dirs = dir.list();
            for (int i = dirs.length - 1; i >= 0; i--) {
                String vid = dirs[i];
                final DownloadInfo d = getDownloadInfoBySavePath(sdCard_list
                        .get(j).path + YoukuPlayerConfiguration.getDownloadPath() + vid + "/");
                if (d != null && d.getState() == DownloadInfo.STATE_FINISH) {
                    downloadedData.put(d.videoid, d);
                    if (d.segCount != d.segsSeconds.length) {
                        new Thread() {
                            public void run() {
                                try {
                                    DownloadUtils.getDownloadData(d);
                                    downloadedData.put(d.videoid, d);
                                    DownloadUtils.makeDownloadInfoFile(d);
                                    DownloadUtils.makeM3U8File(d);
                                } catch (Exception e) {
                                }
                            };
                        }.start();
                    }
                }
            }
        }
        return downloadedData;
    }
 
    @SuppressWarnings("rawtypes")
    public ArrayList<DownloadInfo> getDownloadedList() {
        ArrayList<DownloadInfo> list = new ArrayList<DownloadInfo>();
        Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
        while (iter.hasNext()) {
            Entry entry = (Entry) iter.next();
            list.add((DownloadInfo) entry.getValue());
        }
        return list;
    }
 
    /**
     * TODO 根据showid和集数号查本地视频,为null则不存在
     */
    @SuppressWarnings("rawtypes")
    public DownloadInfo getDownloadInfo(String showId, int show_videoseq) {
        if (showId == null)
            return null;
        Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
        while (iter.hasNext()) {
            Entry entry = (Entry) iter.next();
            DownloadInfo info = (DownloadInfo) entry.getValue();
            if (showId.equals(info.showid)
                    && info.show_videoseq == show_videoseq
                    && info.getState() != DownloadInfo.STATE_CANCEL) {
                return info;
            }
        }
        return null;
    }
 
    @SuppressWarnings("rawtypes")
    public ArrayList<DownloadInfo> getDownloadInfoListById(
            String videoIdOrShowId) {
        if (videoIdOrShowId == null) {
            return null;
        }
        ArrayList<DownloadInfo> list = null;
        if (getDownloadedData().containsKey(videoIdOrShowId)) {
            if (list == null)
                list = new ArrayList<DownloadInfo>();
            list.add(getDownloadedData().get(videoIdOrShowId));
        } else {
            Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
            while (iter.hasNext()) {
                Entry entry = (Entry) iter.next();
                DownloadInfo info = (DownloadInfo) entry.getValue();
                if (videoIdOrShowId.equals(info.showid)) {
                    if (list == null)
                        list = new ArrayList<DownloadInfo>();
                    list.add(info);
                }
            }
            if (list != null && list.size() > 1) {
                DownloadInfo.compareBySeq = true;// 按剧集排序
                Collections.sort(list);// 排序
            }
        }
        return list;
    }
 
    /**
     * TODO Comment:获得本地下一集视频的相关信息
     * 
     * @param vid
     * @return DownloadInfo下一个视频信息,若无下一集则返回null
     */
    @SuppressWarnings("rawtypes")
    public DownloadInfo getNextDownloadInfo(String videoId) {
        DownloadInfo thisinfo = getDownloadInfo(videoId);
        ArrayList<DownloadInfo> temp = new ArrayList<DownloadInfo>();
        Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
 
        if (thisinfo == null)
            return null;
        boolean isthis = false;
        if (thisinfo.isSeries()) {// 是剧集
            while (iter.hasNext()) {
                Entry entry = (Entry) iter.next();
                DownloadInfo info = (DownloadInfo) entry.getValue();
                if (info.showid.equals(thisinfo.showid)) {
                    temp.add(info);
                }
            }
            DownloadInfo.compareBySeq = true;// 按剧集排序
            Collections.sort(temp);// 排序
            for (DownloadInfo info : temp) {
                if (isthis) {
                    return info;
                } else if (info.videoid.equals(videoId)) {
                    isthis = true;
                }
            }
        } else {// 非剧集
            while (iter.hasNext()) {
                Entry entry = (Entry) iter.next();
                DownloadInfo info = (DownloadInfo) entry.getValue();
                temp.add(info);
            }
            DownloadInfo.compareBySeq = false;// 按时间排序
            Collections.sort(temp);// 排序
            for (DownloadInfo info : temp) {
                if (isthis && !info.isSeries()) {
                    return info;
                } else if (thisinfo.videoid.equals(info.videoid)) {
                    isthis = true;
                }
            }
        }
        return null;
    }
    
    /**
     * 根据showId获得已缓存的视频数
     * @param showId
     * @return
     */
    @SuppressWarnings("rawtypes")
    public int getHowManyDownloadsByShowId(String showId) {
        if (showId == null || showId.length() == 0)
            return 0;
        int count = 0;
        Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
        while (iter.hasNext()) {
            Entry entry = (Entry) iter.next();
            DownloadInfo info = (DownloadInfo) entry.getValue();
            if (showId.equals(info.showid)) {
                count++;
            }
        }
        return count;
    }
 
    private OnCreateDownloadListener lis = null;
 
    /**
     * TODO 创建下载任务
     */
    public void createDownload(String videoId, String videoName,
            OnCreateDownloadListener listener) {
        setOnCreateDownloadListener(listener);
        try {
            downloadService.createDownload(videoId, videoName);
        } catch (RemoteException e) {
            Logger.e(TAG, e);
        }
    }
 
    /**
     * TODO 创建下载任务(批量)
     */
    public void createDownloads(String[] videoIds, String[] videoNames,
            OnCreateDownloadListener listener) {
        setOnCreateDownloadListener(listener);
        try {
            downloadService.createDownloads(videoIds, videoNames);
        } catch (RemoteException e) {
            Logger.e(TAG, e);
        }
    }
 
    private void setOnCreateDownloadListener(OnCreateDownloadListener listener) {
        lis = listener;
        if (listener == null) {
            return;
        }
        OnCreateDownloadReceiver on = new OnCreateDownloadReceiver() {
            @Override
            public void onOneReady() {
                if (lis != null)
                    lis.onOneReady();
            }
 
            @Override
            public void onOneFailed() {
                if (lis != null)
                    lis.onOneFailed();
            }
 
            @Override
            public void onfinish(boolean isNeedRefresh) {
                if (lis != null)
                    lis.onfinish(isNeedRefresh);
                lis = null;
            }
        };
        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_CREATE_DOWNLOAD_ONE_READY);
        filter.addAction(ACTION_CREATE_DOWNLOAD_ONE_FAILED);
        filter.addAction(ACTION_CREATE_DOWNLOAD_ALL_READY);
        YoukuPlayerConfiguration.context.registerReceiver(on, filter);
    }
 
    public abstract class OnCreateDownloadReceiver extends BroadcastReceiver {
 
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (IDownload.ACTION_CREATE_DOWNLOAD_ONE_READY.equals(action)) {
                Logger.d("Download_OnCreateDownloadListener", "onOneReady()");
                onOneReady();
            } else if (IDownload.ACTION_CREATE_DOWNLOAD_ALL_READY
                    .equals(action)) {
                boolean value = intent.getBooleanExtra(
                        IDownload.KEY_CREATE_DOWNLOAD_IS_NEED_REFRESH, true);
                Logger.d("Download_OnCreateDownloadListener", "onAllReady():"
                        + value);
                onfinish(value);
            } else if (IDownload.ACTION_CREATE_DOWNLOAD_ONE_FAILED
                    .equals(action)) {
                Logger.d("Download_OnCreateDownloadListener", "onOneFailed()");
                onOneFailed();
            }
        }
 
        /** 当每一个下载已准备的时候 */
        public abstract void onOneReady();
 
        /** 当每一个下载失败 */
        public abstract void onOneFailed();
 
        /**
         * 当全部下载已准备的时候
         * 
         * @param isNeedRefresh
         *            是否需要刷新数据
         */
        public abstract void onfinish(boolean isNeedRefresh);
 
    }
 
    @Override
    public void startDownload(String taskId) {
        try {
            downloadService.down(taskId);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public void pauseDownload(String taskId) {
        try {
            downloadService.pause(taskId);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public void refresh() {
        try {
            downloadService.refresh();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public void startNewTask() {
        Intent i = new Intent(context, DownloadService.class);
        i.setAction(DownloadService.ACTION_STAER_NEWTASK);
        context.startService(i);
    }
 
    @Override
    public void stopAllTask() {
        try {
            downloadService.stopAllTask();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public boolean deleteDownloading(String taskId) {
        Logger.d(TAG, "deleteDownloading() :" + taskId);
        try {
            downloadService.delete(taskId);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return false;
    }
 
    @Override
    public boolean deleteAllDownloading() {
        Logger.d(TAG, "deleteAllDownloading()");
        try {
            return downloadService.deleteAll();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return false;
    }
 
    public boolean deleteDownloaded(final DownloadInfo info) {
        Logger.d(TAG, "deleteDownloaded() :" + info.title);
        // info.setState(DownloadInfo.STATE_CANCEL);
        downloadedData.remove(info.videoid);
        if (YoukuPlayerConfiguration.getPreference(KEY_LAST_NOTIFY_TASKID).equals(info.taskId)) {
            NotificationManager nm = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            nm.cancel(NOTIFY_ID);
            YoukuPlayerConfiguration.savePreference(KEY_LAST_NOTIFY_TASKID, "");
        }
        new Thread() {
            public void run() {
                PlayerUtil.deleteFile(new File(info.savePath));
            };
        }.start();
        startNewTask();
        return true;
    }
 
    public boolean deleteDownloadeds(final ArrayList<DownloadInfo> infos) {
        Logger.d(TAG, "deleteDownloadeds() : ArrayList");
        if (infos == null || infos.size() == 0)
            return true;
        String nId = YoukuPlayerConfiguration.getPreference(KEY_LAST_NOTIFY_TASKID);
        for (DownloadInfo info : infos) {
            downloadedData.remove(info.videoid);
            if (nId.equals(info.taskId)) {
                NotificationManager nm = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                nm.cancel(NOTIFY_ID);
                YoukuPlayerConfiguration.savePreference(KEY_LAST_NOTIFY_TASKID, "");
            }
        }
        new Thread() {
            public void run() {
                for (DownloadInfo info : infos) {
                    PlayerUtil.deleteFile(new File(info.savePath));
                }
            };
        }.start();
        return true;
    }
 
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public boolean deleteAllDownloaded() {
        Logger.d(TAG, "deleteAllDownloaded()");
        if (getDownloadedData().size() == 0)
            return true;
        final HashMap<String, DownloadInfo> clone = (HashMap<String, DownloadInfo>) getDownloadedData()
                .clone();
        String nId = YoukuPlayerConfiguration.getPreference(KEY_LAST_NOTIFY_TASKID);
        Iterator iter = getDownloadedData().entrySet().iterator(); // 获得map的Iterator
        while (iter.hasNext()) {
            Entry entry = (Entry) iter.next();
            DownloadInfo info = (DownloadInfo) entry.getValue();
            if (nId.equals(info.taskId)) {
                NotificationManager nm = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                nm.cancel(NOTIFY_ID);
                YoukuPlayerConfiguration.savePreference(KEY_LAST_NOTIFY_TASKID, "");
            }
        }
        new Thread() {
            public void run() {
                Iterator iter = clone.entrySet().iterator();
                while (iter.hasNext()) {
                    Entry entry = (Entry) iter.next();
                    DownloadInfo info = (DownloadInfo) entry.getValue();
                    PlayerUtil.deleteFile(new File(info.savePath));
                }
            };
        }.start();
        getDownloadedData().clear();
        return true;
    }
 
    @Override
    public final String getCurrentDownloadSDCardPath() {
        try {
            return downloadService.getCurrentDownloadSDCardPath();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return YoukuPlayerConfiguration.getPreference("download_file_path",
                SDCardManager.getDefauleSDCardPath());
    }
 
    @Override
    public void setCurrentDownloadSDCardPath(String path) {
        try {
            downloadService.setCurrentDownloadSDCardPath(path);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
 
    }
 
    @Override
    public boolean canUse3GDownload() {
        try {
            return downloadService.canUse3GDownload();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return YoukuPlayerConfiguration.getPreferenceBoolean("allowCache3G", false);
    }
 
    @Override
    public void setCanUse3GDownload(boolean flag) {
        try {
            downloadService.setCanUse3GDownload(flag);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public boolean canUseAcc() {
        try {
            return downloadService.canUseAcc();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return false;
    }
 
    @Override
    public void setP2p_switch(int value) {
        YoukuPlayerConfiguration.savePreference("p2p_switch", value);
        try {
            downloadService.setP2p_switch(value);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
//        if (value == 1) {
//            Logger.d("Download_ACCFlow", "获取P2P开关结果:打开");
//            if (canUseAcc()) {
//                acceleraterManager.startService();
//                IStaticsManager.p2pStart();
//            } else {
//                Logger.d("Download_ACCFlow", "ACC启动失败/不满足ACC运行条件");
//                acceleraterManager.stopService();
//                IStaticsManager.p2pFail("ACC启动失败/不满足ACC运行条件");
//            }
//        } else if (value == 0) {
//            Logger.d("Download_ACCFlow", "获取P2P开关结果:关闭");
//            acceleraterManager.stopService();
//            IStaticsManager.p2pFail("获取P2P开关结果:关闭");
//        } else if (value == -1) {
//            Logger.d("Download_ACCFlow", "获取P2P开关结果:获取失败,默认关闭");
//            acceleraterManager.stopService();
//            IStaticsManager.p2pFail("获取P2P开关结果:获取失败,默认关闭");
//        }
//        AccInitData.setP2pSwitch(YoukuPlayerConfiguration.context, value);
//        acceleraterManager.startService();
//        IStaticsManager.p2pStart();
    }
 
    @Override
    public String getAccPort() {
        try {
            return downloadService.getAccPort();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return "";
    }
 
    @Override
    public int getDownloadFormat() {
        try {
            return downloadService.getDownloadFormat();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return DownloadUtils.getDownloadFormat();
    }
 
    @Override
    public void setDownloadFormat(int format) {
        DownloadUtils.setDownloadFormat(format);
        try {
            downloadService.setDownloadFormat(format);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    @Override
    public int getDownloadLanguage() {
        try {
            return downloadService.getDownloadLanguage();
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
        return DownloadUtils.getDownloadLanguage();
    }
 
    @Override
    public void setDownloadLanguage(int language) {
        DownloadUtils.setDownloadLanguage(language);
        try {
            downloadService.setDownloadLanguage(language);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
 
    public void setTimeStamp(long time) {
        try {
            downloadService.setTimeStamp(time);
        } catch (Exception e) {
            Logger.e(TAG, e);
        }
    }
//
//    @Override
//    public void setDownloadPath() {
//        // TODO Auto-generated method stub
//        if(!TextUtils.isEmpty(YoukuPlayerBaseConfiguration.downloadRootFolderName)){
////            FILE_PATH = YoukuPlayerBaseConfiguration.downloadRootFolderName + FILE_PATH;
//        }
//    }
 
}