-
Notifications
You must be signed in to change notification settings - Fork 26
/
PlayerModuleDefault.java
163 lines (136 loc) · 4.39 KB
/
PlayerModuleDefault.java
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
package com.tubitv.media.di;
import android.support.annotation.Nullable;
import com.tubitv.media.controller.PlayerAdLogicController;
import com.tubitv.media.controller.PlayerUIController;
import com.tubitv.media.di.annotation.ActicityScope;
import com.tubitv.media.fsm.callback.AdInterface;
import com.tubitv.media.fsm.callback.CuePointCallBack;
import com.tubitv.media.fsm.callback.RetrieveAdCallback;
import com.tubitv.media.fsm.concrete.FetchCuePointState;
import com.tubitv.media.fsm.concrete.factory.StateFactory;
import com.tubitv.media.fsm.listener.AdPlayingMonitor;
import com.tubitv.media.fsm.listener.CuePointMonitor;
import com.tubitv.media.fsm.state_machine.FsmPlayer;
import com.tubitv.media.fsm.state_machine.FsmPlayerImperial;
import com.tubitv.media.models.AdMediaModel;
import com.tubitv.media.models.AdRetriever;
import com.tubitv.media.models.CuePointsRetriever;
import com.tubitv.media.models.MediaModel;
import com.tubitv.media.models.VpaidClient;
import dagger.Module;
import dagger.Provides;
import java.util.ArrayList;
import java.util.List;
/**
* Created by allensun on 8/7/17.
* on Tubitv.com, [email protected]
*/
@Module
public class PlayerModuleDefault {
public PlayerModuleDefault() {
}
@ActicityScope
@Provides
StateFactory provideStateFactory() {
return new StateFactory();
}
@ActicityScope
@Provides
FsmPlayer provideFsmPlayer(StateFactory factory) {
return new FsmPlayerImperial(factory) {
@Override
public Class initializeState() {
return FetchCuePointState.class;
}
};
}
@ActicityScope
@Provides
PlayerUIController provideController() {
return new PlayerUIController();
}
@ActicityScope
@Provides
PlayerAdLogicController provideComponentController() {
return new PlayerAdLogicController();
}
@ActicityScope
@Provides
AdRetriever provideAdRetriever() {
return new AdRetriever();
}
@ActicityScope
@Provides
CuePointsRetriever provideCuePointsRetriever() {
return new CuePointsRetriever();
}
@ActicityScope
@Provides
AdPlayingMonitor provideAdPlayingMonitor(FsmPlayer player) {
return new AdPlayingMonitor(player);
}
@ActicityScope
@Provides
CuePointMonitor provideCuePointMonitor(FsmPlayer fsmPlayer) {
CuePointMonitor cuePointMonitor = new CuePointMonitor(fsmPlayer) {
@Override
public int networkingAhead() {
return 5000;
}
};
return cuePointMonitor;
}
@ActicityScope
@Provides
AdMediaModel provideAdMediaModel() {
MediaModel ad_1 = MediaModel
.ad("http://devimages.apple.com/samplecode/adDemo/ad.m3u8",
"https://tubitv.com/", false);
final List<MediaModel> list = new ArrayList<>();
list.add(ad_1);
AdMediaModel adMediaModel = new AdMediaModel(list) {
@Nullable
@Override
public MediaModel nextAD() {
return list != null && list.size() > 0 ? list.get(0) : null;
}
};
return adMediaModel;
}
@ActicityScope
@Provides
AdInterface provideAdInterfaceNoPreroll() {
// using the fake generated AdMediaModel to do has the returned data.
return new AdInterface() {
@Override
public void fetchAd(AdRetriever retriever, RetrieveAdCallback callback) {
callback.onReceiveAd(provideAdMediaModel());
}
@Override
public void fetchQuePoint(CuePointsRetriever retriever, CuePointCallBack callBack) {
callBack.onCuePointReceived(null);
//"AdBreak point at 0s, 1min, 15min, 30min, 60min. With each adbreak showing one ads"
//new long[] { 60000, 900000, 1800000, 3600000 }
}
};
}
@ActicityScope
@Provides
VpaidClient provideVpaidClient() {
return new VpaidClient() {
@Override
public void init(MediaModel ad) {
}
@Override
public void notifyAdError(int code, String error) {
}
@Override
public void notifyVideoEnd() {
}
@Override
public String getVastXml() {
return null;
}
};
}
}