├── .gitignore
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── jjr
│ │ └── dlna
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── jjr
│ │ │ └── dlna
│ │ │ ├── MainActivity.java
│ │ │ └── app
│ │ │ └── MyAppication.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ ├── selector_btn_next.xml
│ │ ├── selector_btn_pause.xml
│ │ ├── selector_btn_play.xml
│ │ ├── selector_btn_pre.xml
│ │ └── selector_volume.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_tv.png
│ │ ├── icon_pause_n.png
│ │ ├── icon_pause_p.png
│ │ ├── icon_play_n.PNG
│ │ ├── icon_play_next_normal.png
│ │ ├── icon_play_next_pressed.png
│ │ ├── icon_play_p.PNG
│ │ ├── icon_play_prev_normal.png
│ │ ├── icon_play_prev_pressed.png
│ │ ├── icon_stop.png
│ │ ├── icon_volume_mute.png
│ │ └── icon_volume_normal.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── jjr
│ └── dlna
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib-dlna
├── .gitignore
├── build.gradle
├── libs
│ ├── Cling-2.1.1.jar
│ ├── javax.servlet-3.0.0.v201112011016.jar
│ ├── jetty-client-8.1.8.v20121106.jar
│ ├── jetty-http-8.1.8.v20121106.jar
│ ├── jetty-io-8.1.8.v20121106.jar
│ ├── jetty-security-8.1.8.v20121106.jar
│ ├── jetty-server-8.1.14.v20131031.jar
│ ├── jetty-servlet-8.1.8.v20121106.jar
│ ├── jetty-util-8.1.8.v20121106.jar
│ ├── seamless-http-1.1.0.jar
│ ├── seamless-util-1.1.0.jar
│ └── seamless-xml-1.1.0.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── dongao
│ │ └── dlna
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── dongao
│ │ │ └── dlna
│ │ │ ├── DLNALibrary.java
│ │ │ ├── adapter
│ │ │ └── GeneralAdapter.java
│ │ │ ├── moduls
│ │ │ ├── avtransport
│ │ │ │ ├── bll
│ │ │ │ │ ├── MediaControlBiz.java
│ │ │ │ │ ├── MediaEventBiz.java
│ │ │ │ │ └── RealtimeUpdatePositionInfo.java
│ │ │ │ ├── callback
│ │ │ │ │ ├── avtransport
│ │ │ │ │ │ ├── GetCurrentTransportActions.java
│ │ │ │ │ │ ├── GetDeviceCapabilities.java
│ │ │ │ │ │ ├── GetMediaInfo.java
│ │ │ │ │ │ ├── GetPositionInfo.java
│ │ │ │ │ │ ├── GetTransportInfo.java
│ │ │ │ │ │ ├── Next.java
│ │ │ │ │ │ ├── Pause.java
│ │ │ │ │ │ ├── Play.java
│ │ │ │ │ │ ├── Previous.java
│ │ │ │ │ │ ├── Seek.java
│ │ │ │ │ │ ├── SetAVTransportURI.java
│ │ │ │ │ │ └── Stop.java
│ │ │ │ │ └── renderingcontrol
│ │ │ │ │ │ ├── GetMute.java
│ │ │ │ │ │ ├── GetVolume.java
│ │ │ │ │ │ ├── ListPresets.java
│ │ │ │ │ │ ├── SelectPreset.java
│ │ │ │ │ │ ├── SetMute.java
│ │ │ │ │ │ └── SetVolume.java
│ │ │ │ ├── constants
│ │ │ │ │ ├── MediaControlWhat.java
│ │ │ │ │ ├── MediaEventWhat.java
│ │ │ │ │ ├── TransportState.java
│ │ │ │ │ └── TransportStatus.java
│ │ │ │ ├── entity
│ │ │ │ │ ├── AVTransportInfo.java
│ │ │ │ │ ├── MediaInfo.java
│ │ │ │ │ ├── PositionInfo.java
│ │ │ │ │ └── RenderingControlInfo.java
│ │ │ │ └── event
│ │ │ │ │ ├── AVTransportEvent.java
│ │ │ │ │ └── RenderingControlEvent.java
│ │ │ └── searchdevice
│ │ │ │ ├── entity
│ │ │ │ └── DeviceDisplay.java
│ │ │ │ └── listener
│ │ │ │ └── DeviceRegistryListener.java
│ │ │ ├── upnp
│ │ │ ├── UpnpActionCallback.java
│ │ │ ├── UpnpRegistryListener.java
│ │ │ ├── UpnpServiceBiz.java
│ │ │ ├── UpnpSubscriptionCallback.java
│ │ │ ├── constants
│ │ │ │ └── HandlerWhat.java
│ │ │ └── service
│ │ │ │ └── UpnpDeviceService.java
│ │ │ ├── utils
│ │ │ └── ObjectParse.java
│ │ │ └── view
│ │ │ └── SelectDeviceDialog.java
│ └── res
│ │ ├── layout
│ │ └── dlna_select_device_dialog.xml
│ │ ├── mipmap-xxhdpi
│ │ └── btn_nav_close.png
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── dongao
│ └── dlna
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/*
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | defaultConfig {
6 | applicationId "com.example.jjr.dlna"
7 | minSdkVersion 15
8 | targetSdkVersion 25
9 | versionCode 1
10 | versionName "1.0.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'com.android.support:appcompat-v7:25.4.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28 | implementation project(':lib-dlna')
29 | }
30 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/jjr/dlna/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.jjr.dlna;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.jjr.dlna", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jjr/dlna/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.jjr.dlna;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.ImageButton;
11 | import android.widget.ImageView;
12 | import android.widget.SeekBar;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.dongao.dlna.DLNALibrary;
17 | import com.dongao.dlna.moduls.avtransport.bll.MediaControlBiz;
18 | import com.dongao.dlna.moduls.avtransport.bll.MediaEventBiz;
19 | import com.dongao.dlna.moduls.avtransport.bll.RealtimeUpdatePositionInfo;
20 | import com.dongao.dlna.moduls.avtransport.constants.MediaControlWhat;
21 | import com.dongao.dlna.moduls.avtransport.constants.MediaEventWhat;
22 | import com.dongao.dlna.moduls.avtransport.constants.TransportState;
23 | import com.dongao.dlna.moduls.avtransport.entity.AVTransportInfo;
24 | import com.dongao.dlna.moduls.avtransport.entity.RenderingControlInfo;
25 | import com.dongao.dlna.view.SelectDeviceDialog;
26 |
27 | import org.fourthline.cling.model.meta.Device;
28 | import org.fourthline.cling.support.model.item.Item;
29 |
30 | import java.util.HashMap;
31 |
32 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
33 |
34 | private ImageButton ibStop;
35 | protected ImageButton ibPlay;
36 | protected ImageButton ibPause;
37 | private ImageButton ibPlaypre;
38 | private ImageButton ibPlaynext;
39 | private SeekBar sbPlayback;
40 | protected TextView tvTotalTime;
41 | protected TextView tvCurrVol;
42 | private Button btnAddVol;
43 | private Button btnSubVol;
44 | private Item item;
45 | private ImageView ivMute;
46 |
47 | private Handler handler;
48 | private long mId; // item播放实例id
49 | protected MediaControlBiz controlBiz;
50 | private boolean currentMute;
51 | private MediaEventBiz eventBiz;
52 | protected int currVolume;
53 | private RealtimeUpdatePositionInfo realtimeUpdate;
54 | private TextView tvCurTime;
55 |
56 |
57 | @Override
58 | protected void onCreate(Bundle savedInstanceState) {
59 | super.onCreate(savedInstanceState);
60 | setContentView(R.layout.activity_main);
61 | handler = new Handler() {
62 | @Override
63 | public void handleMessage(Message msg) {
64 | switch (msg.what) {
65 | case MediaControlWhat.SET_AVTRANSPORT_URI:
66 | controlBiz.getVolume();
67 | break;
68 | case MediaControlWhat.PLAY:
69 | updatePlayingState(true);
70 | break;
71 | case MediaControlWhat.PAUSE:
72 | updatePlayingState(false);
73 | break;
74 | case MediaControlWhat.STOP:
75 | updatePlayingState(false);
76 | break;
77 | case MediaControlWhat.GET_VOLUME:
78 | currVolume = msg.arg2;
79 | tvCurrVol.setText(getString(R.string.current_volume)
80 | + currVolume);
81 | break;
82 | case MediaControlWhat.SET_VOLUME:
83 | tvCurrVol.setText(getString(R.string.current_volume)
84 | + currVolume);
85 | break;
86 | case MediaControlWhat.SET_MUTE:
87 | ivMute.setSelected(currentMute);
88 | break;
89 | case MediaEventWhat.RENDERING_CONTROL:
90 | RenderingControlInfo rcInfo = (RenderingControlInfo) msg.obj;
91 | HashMap vChange = rcInfo.getValueIsChange();
92 | if (vChange.get(RenderingControlInfo.MUTE)) {
93 | currentMute = rcInfo.isMute();
94 | ivMute.setSelected(currentMute);
95 | }
96 | if (vChange.get(RenderingControlInfo.VOLUME)) {
97 | currVolume = rcInfo.getVolume();
98 | tvCurrVol.setText(getString(R.string.current_volume)
99 | + currVolume);
100 | }
101 | break;
102 | case MediaEventWhat.AV_TRANSPORT:
103 | AVTransportInfo avtInfo = (AVTransportInfo) msg.obj;
104 | HashMap currStates = avtInfo.getValueIsChange();
105 | if (currStates.get(AVTransportInfo.CURRENT_MEDIA_DURATION)) {
106 | tvTotalTime.setText(avtInfo.getCurrentMediaDuration());
107 | }
108 | if (currStates.get(AVTransportInfo.TRANSPORT_STATE)) {
109 | String currState = avtInfo.getTransportState();
110 | if (TransportState.PLAYING.equals(currState)) {
111 | updatePlayingState(true);
112 | } else {
113 | updatePlayingState(false);
114 | }
115 | }
116 | break;
117 | }
118 |
119 | }
120 | };
121 | initView();
122 | }
123 |
124 | private void initView() {
125 | ImageView iv_tv = (ImageView) findViewById(R.id.iv_tv);
126 | iv_tv.setOnClickListener(this);
127 | TextView tv_device = (TextView) findViewById(R.id.tv_device);
128 | tv_device.setOnClickListener(this);
129 |
130 | // 停止
131 | ibStop = (ImageButton) findViewById(R.id.ib_stop);
132 | // 播放
133 | ibPlay = (ImageButton) findViewById(R.id.ib_play);
134 | // 暂停
135 | ibPause = (ImageButton) findViewById(R.id.ib_pause);
136 | // 上一首
137 | ibPlaypre = (ImageButton) findViewById(R.id.ib_playpre);
138 | // 下一首
139 | ibPlaynext = (ImageButton) findViewById(R.id.ib_playnext);
140 | // 静音
141 | ivMute = (ImageView) findViewById(R.id.iv_mute);
142 | // 当前音量大小
143 | tvCurrVol = (TextView) findViewById(R.id.tv_curr_vol);
144 | // 增加音量
145 | btnAddVol = (Button) findViewById(R.id.btn_add_vol);
146 | // 降低音量
147 | btnSubVol = (Button) findViewById(R.id.btn_sub_vol);
148 |
149 | // 播放音乐的进度
150 | sbPlayback = (SeekBar) findViewById(R.id.sb_playback);
151 | // 当前播放的时间
152 | tvCurTime = (TextView) findViewById(R.id.tv_curTime);
153 | // 总时间
154 | tvTotalTime = (TextView) findViewById(R.id.tv_totalTime);
155 |
156 | ibStop.setOnClickListener(this);
157 | ibPlay.setOnClickListener(this);
158 | ibPause.setOnClickListener(this);
159 | ibPlaypre.setOnClickListener(this);
160 | ibPlaynext.setOnClickListener(this);
161 | ivMute.setOnClickListener(this);
162 | btnAddVol.setOnClickListener(this);
163 | btnSubVol.setOnClickListener(this);
164 | sbPlayback.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
165 |
166 | @Override
167 | public void onStopTrackingTouch(SeekBar seekBar) {
168 | int prog = seekBar.getProgress();
169 | String totalTime = tvTotalTime.getText().toString();
170 | controlBiz.seek(totalTime, prog);
171 | }
172 |
173 | @Override
174 | public void onStartTrackingTouch(SeekBar seekBar) {
175 | }
176 |
177 | @Override
178 | public void onProgressChanged(SeekBar seekBar, int progress,
179 | boolean fromUser) {
180 | }
181 | });
182 | }
183 |
184 | @Override
185 | public void onClick(View v) {
186 | switch (v.getId()) {
187 | case R.id.iv_tv:
188 | if (DLNALibrary.getInstance().getDeviceDisplay() != null) {
189 | Device device = DLNALibrary.getInstance().getDeviceDisplay().getDevice();
190 | mId = 0;
191 | currentMute = false;
192 | controlBiz = new MediaControlBiz(device, handler, mId);
193 | eventBiz = new MediaEventBiz(device, handler);
194 |
195 | // 启动从DMP设备更新播放状态
196 | realtimeUpdate = new RealtimeUpdatePositionInfo(controlBiz, sbPlayback,
197 | tvCurTime, tvTotalTime);
198 | realtimeUpdate.execute();
199 | eventBiz.addRenderingEvent();
200 | eventBiz.addAVTransportEvent();
201 |
202 | controlBiz.setPlayUri("http://v.dongaocloud.com/2a86/2a86/12c/7f1/237c3f651d289196ac56186047c8e70a.mp4");
203 | } else {
204 | SelectDeviceDialog dialog = new SelectDeviceDialog();
205 | dialog.show(getSupportFragmentManager(), "select_device_dialog");
206 | }
207 | break;
208 | case R.id.tv_device:
209 | SelectDeviceDialog dialog = new SelectDeviceDialog();
210 | dialog.show(getSupportFragmentManager(), "select_device_dialog");
211 | break;
212 | case R.id.ib_stop:
213 | controlBiz.stop();
214 | break;
215 | case R.id.ib_play:
216 | controlBiz.play();
217 | break;
218 | case R.id.ib_pause:
219 | controlBiz.pause();
220 | break;
221 | case R.id.ib_playpre:
222 | controlBiz.previous();
223 | break;
224 | case R.id.ib_playnext:
225 | controlBiz.next();
226 | break;
227 | case R.id.iv_mute:
228 | if (currentMute) {
229 | currentMute = false;
230 | } else {
231 | currentMute = true;
232 | }
233 | controlBiz.setMute(currentMute);
234 | break;
235 | case R.id.btn_add_vol:
236 | currVolume++;
237 | if (currVolume > 100) {
238 | currVolume = 100;
239 | Toast.makeText(this, "已经是最大音量了", Toast.LENGTH_SHORT).show();
240 | return;
241 | }
242 | controlBiz.setVolume(currVolume);
243 | break;
244 | case R.id.btn_sub_vol:
245 | currVolume--;
246 | if (currVolume < 0) {
247 | currVolume = 0;
248 | Toast.makeText(this, "已经是最小音量了", Toast.LENGTH_SHORT).show();
249 | return;
250 | }
251 | controlBiz.setVolume(currVolume);
252 | break;
253 | default:
254 | break;
255 | }
256 | }
257 |
258 | protected void updatePlayingState(boolean isPlaying) {
259 | realtimeUpdate.setPlaying(isPlaying);
260 | if (isPlaying) {
261 | ibPlay.setVisibility(View.GONE);
262 | ibPause.setVisibility(View.VISIBLE);
263 | } else {
264 | ibPlay.setVisibility(View.VISIBLE);
265 | ibPause.setVisibility(View.GONE);
266 | }
267 | }
268 | }
269 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jjr/dlna/app/MyAppication.java:
--------------------------------------------------------------------------------
1 | package com.example.jjr.dlna.app;
2 |
3 | import android.app.Application;
4 |
5 | import com.dongao.dlna.DLNALibrary;
6 | import com.dongao.dlna.moduls.searchdevice.entity.DeviceDisplay;
7 | import com.dongao.dlna.upnp.UpnpServiceBiz;
8 |
9 | import org.fourthline.cling.support.model.item.Item;
10 |
11 | /**
12 | * @author jjr
13 | * @date 2018/6/19
14 | */
15 | public class MyAppication extends Application {
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | DLNALibrary.getInstance().init(this);
21 | }
22 |
23 | @Override
24 | public void onTerminate() {
25 | UpnpServiceBiz.newInstance().closeUpnpService(this);
26 | super.onTerminate();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_btn_next.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_btn_pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_btn_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_btn_pre.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_volume.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
27 |
28 |
36 |
37 |
38 |
39 |
44 |
45 |
51 |
52 |
58 |
59 |
66 |
67 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
94 |
95 |
105 |
106 |
115 |
116 |
125 |
126 |
139 |
140 |
141 |
142 |
147 |
148 |
155 |
156 |
164 |
165 |
173 |
174 |
182 |
183 |
184 |
185 |
186 |
187 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_tv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/ic_tv.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_pause_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_pause_n.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_pause_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_pause_p.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_n.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_n.PNG
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_next_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_next_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_next_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_next_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_p.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_p.PNG
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_prev_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_prev_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_play_prev_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_play_prev_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_stop.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_volume_mute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_volume_mute.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_volume_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxhdpi/icon_volume_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-DLNA
3 | 查找设备
4 |
5 | 查找局域网中的Upnp设备…
6 | 开启路由…
7 | 关闭路由…
8 | Error switching router:
9 | 正在查找设备详情,请稍后.
10 |
11 | Device Details
12 | 确定
13 |
14 | 请选择播放设备
15 |
16 | /
17 | 0:00:00
18 | +
19 | -
20 | 当前音量:
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/jjr/dlna/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.jjr.dlna;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.2'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jun 19 10:39:06 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/lib-dlna/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib-dlna/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | defaultConfig {
6 | minSdkVersion 15
7 | targetSdkVersion 25
8 | versionCode 1
9 | versionName "1.0.0"
10 |
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 |
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | }
23 |
24 | dependencies {
25 | api fileTree(include: ['*.jar'], dir: 'libs')
26 | implementation 'com.android.support:appcompat-v7:25.4.0'
27 | testImplementation 'junit:junit:4.12'
28 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/lib-dlna/libs/Cling-2.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/Cling-2.1.1.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/javax.servlet-3.0.0.v201112011016.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/javax.servlet-3.0.0.v201112011016.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-client-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-client-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-http-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-http-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-io-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-io-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-security-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-security-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-server-8.1.14.v20131031.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-server-8.1.14.v20131031.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-servlet-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-servlet-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/jetty-util-8.1.8.v20121106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/jetty-util-8.1.8.v20121106.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/seamless-http-1.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/seamless-http-1.1.0.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/seamless-util-1.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/seamless-util-1.1.0.jar
--------------------------------------------------------------------------------
/lib-dlna/libs/seamless-xml-1.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/libs/seamless-xml-1.1.0.jar
--------------------------------------------------------------------------------
/lib-dlna/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/lib-dlna/src/androidTest/java/com/dongao/dlna/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.dongao.dlna.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/DLNALibrary.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna;
2 |
3 | import android.app.Application;
4 |
5 | import com.dongao.dlna.moduls.searchdevice.entity.DeviceDisplay;
6 |
7 | import org.fourthline.cling.support.model.item.Item;
8 |
9 | /**
10 | * @author jjr
11 | * @date 2018/6/22
12 | */
13 | public final class DLNALibrary {
14 |
15 | private static DLNALibrary mInstance;
16 | private static Application mApplication;
17 | private DeviceDisplay device;
18 | private Item item;
19 |
20 | private DLNALibrary() {
21 |
22 | }
23 |
24 | public static synchronized DLNALibrary getInstance() {
25 | if (null == mInstance) {
26 | mInstance = new DLNALibrary();
27 | }
28 | return mInstance;
29 | }
30 |
31 | public void init(Application application) {
32 | mApplication = application;
33 | }
34 |
35 | public Application getApplicationContext() {
36 | return mApplication;
37 | }
38 |
39 | public void setDeviceDisplay(DeviceDisplay device) {
40 | this.device = device;
41 | }
42 |
43 | public DeviceDisplay getDeviceDisplay() {
44 | return device;
45 | }
46 |
47 |
48 | public void setItem(Item item) {
49 | this.item = item;
50 | }
51 |
52 | public Item getItem() {
53 | return item;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/adapter/GeneralAdapter.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.drawable.Drawable;
6 | import android.text.TextUtils;
7 | import android.util.SparseArray;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.BaseAdapter;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import java.util.ArrayList;
16 | import java.util.Collection;
17 | import java.util.Collections;
18 | import java.util.Comparator;
19 | import java.util.List;
20 |
21 | /**
22 | * 通用Adapter基类,其他要实现Adapter的只要继承此类,实现convert方法即可
23 | *
24 | * @author hubing
25 | * @version 1.0.0 2015-4-10
26 | */
27 | public abstract class GeneralAdapter extends BaseAdapter {
28 |
29 | //ListView中最大显示数据条数
30 | private int maxCount = 200;
31 | private List data;
32 | //ListView中Item布局id
33 | private int resource;
34 | private Context ctx;
35 |
36 | private final Object mLock = new Object();
37 |
38 | /**
39 | *
40 | * @param resource
41 | * item布局文件
42 | * @param data
43 | */
44 | public GeneralAdapter(Context ctx, int resource, List data) {
45 | this.ctx = ctx;
46 | this.resource = resource;
47 | setData(data);
48 | }
49 |
50 | /**
51 | * 设置Adapter中的数据
52 | *
53 | * @param data
54 | */
55 | public void setData(List data) {
56 | synchronized (mLock) {
57 | if (data == null) {
58 | data = new ArrayList();
59 | }
60 | }
61 | this.data = data;
62 | checkListSize();
63 | }
64 |
65 | public List getData() {
66 | return data;
67 | }
68 |
69 | /**
70 | * 向Adapter中List添加单个对象
71 | *
72 | * @author hubing
73 | * @param object
74 | */
75 | public void add(E object) {
76 | synchronized (mLock) {
77 | if (data != null) {
78 | data.add(object);
79 | }
80 | checkListSize();
81 | }
82 | }
83 |
84 | /**
85 | * 向Adapter中List末尾追加列表数据
86 | *
87 | * @param collection
88 | */
89 | public void addAll(Collection extends E> collection) {
90 | synchronized (mLock) {
91 | if (data != null) {
92 | data.addAll(data);
93 | checkListSize();
94 | }
95 | }
96 | }
97 |
98 | /**
99 | * Inserts the specified object at the specified index in the array.
100 | *
101 | * @param object The object to insert into the array.
102 | * @param index The index at which the object must be inserted.
103 | */
104 | public void insert(E object, int index) {
105 | synchronized (mLock) {
106 | if (data != null) {
107 | data.add(index, object);
108 | }
109 | }
110 | notifyDataSetChanged();
111 | }
112 |
113 | /**
114 | * Removes the specified object from the array.
115 | *
116 | * @param object The object to remove.
117 | */
118 | public void remove(E object) {
119 | synchronized (mLock) {
120 | if (data != null) {
121 | data.remove(object);
122 | }
123 | }
124 | notifyDataSetChanged();
125 | }
126 |
127 | /**
128 | * Remove all elements from the list.
129 | */
130 | public void clear() {
131 | synchronized (mLock) {
132 | if (data != null) {
133 | data.clear();
134 | }
135 | }
136 | notifyDataSetChanged();
137 | }
138 |
139 | /**
140 | * Sorts the content of this adapter using the specified comparator.
141 | *
142 | * @param comparator The comparator used to sort the objects contained
143 | * in this adapter.
144 | */
145 | public void sort(Comparator super E> comparator) {
146 | synchronized (mLock) {
147 | if (data != null) {
148 | Collections.sort(data, comparator);
149 | }
150 | }
151 | notifyDataSetChanged();
152 | }
153 |
154 | /**
155 | * 检测当前List中的数据是否超过最大值maxCount
156 | */
157 | private void checkListSize() {
158 | int totalCount = data.size();
159 | if (totalCount > maxCount) {
160 | data = data.subList(totalCount - maxCount, totalCount);
161 | }
162 | this.notifyDataSetChanged();
163 | }
164 |
165 | /**
166 | * 获取ListView中显示的item最大条数
167 | *
168 | * @return maxCount
169 | */
170 | public int getMaxCount() {
171 | return maxCount;
172 | }
173 |
174 | /**
175 | * 设置ListView中显示的item最大条数(此方法必需在setData方法之前调用才有效)
176 | *
177 | * @param maxCount
178 | */
179 | public void setMaxCount(int maxCount) {
180 | this.maxCount = maxCount;
181 | }
182 |
183 | /**
184 | * Returns the context associated with this array adapter. The context is used
185 | * to create views from the resource passed to the constructor.
186 | *
187 | * @return The Context associated with this adapter.
188 | */
189 | public Context getContext() {
190 | return ctx;
191 | }
192 |
193 | @Override
194 | public int getCount() {
195 | return this.data.size();
196 | }
197 |
198 | @Override
199 | public E getItem(int position) {
200 | return data.get(position);
201 | }
202 |
203 | /**
204 | * Returns the position of the specified item in the array.
205 | *
206 | * @param item The item to retrieve the position of.
207 | *
208 | * @return The position of the specified item.
209 | */
210 | public int getPosition(E item) {
211 | return data.indexOf(item);
212 | }
213 |
214 | @Override
215 | public long getItemId(int position) {
216 | return position;
217 | }
218 |
219 | @Override
220 | public View getView(int position, View convertView, ViewGroup parent) {
221 | ViewHolder holder = ViewHolder.get(ctx, resource, convertView);
222 | convert(holder, getItem(position), position);
223 | return holder.getConvertView();
224 | }
225 |
226 | /**
227 | * 实现此方法,完成item界面设置
228 | */
229 | public abstract void convert(ViewHolder holder, E item, int position);
230 |
231 | /**
232 | *
233 | * @author hubing
234 | * @version 1.0.0 2015-4-10
235 | */
236 | public static class ViewHolder {
237 |
238 | private View convertView;
239 | private SparseArray views;
240 |
241 | private ViewHolder(Context ctx, int resource) {
242 | convertView = LayoutInflater.from(ctx).inflate(resource, null);
243 | convertView.setTag(this);
244 | views = new SparseArray();
245 | }
246 |
247 | /**
248 | * 获取ViewHoler
249 | *
250 | * @param ctx
251 | * @param resource
252 | * @param convertView
253 | * @return
254 | */
255 | public static ViewHolder get(Context ctx, int resource, View convertView) {
256 | ViewHolder vh = null;
257 | if (convertView == null) {
258 | vh = new ViewHolder(ctx, resource);
259 | } else {
260 | vh = (ViewHolder) convertView.getTag();
261 | }
262 | return vh;
263 | }
264 |
265 | public View getConvertView() {
266 | return this.convertView;
267 | }
268 |
269 | /**
270 | * 从ViewHoler中获取已经保持的View
271 | *
272 | * @param widgetId
273 | * @return
274 | */
275 | public View getView(int widgetId) {
276 | View view = views.get(widgetId);
277 | if (view == null) {
278 | view = convertView.findViewById(widgetId);
279 | views.append(widgetId, view);
280 | }
281 | return view;
282 | }
283 |
284 | /**
285 | * 设置继承自TextView的控件文本
286 | *
287 | * @param widgetId
288 | * @param text
289 | */
290 | public void setText(int widgetId, String text) {
291 | TextView tv = (TextView) getView(widgetId);
292 | if (tv != null && !TextUtils.isEmpty(text)) {
293 | tv.setText(text);
294 | }
295 | }
296 |
297 | /**
298 | * 设置继承自TextView的控件文本
299 | *
300 | * @param widgetId
301 | * @param resid
302 | */
303 | public void setText(int widgetId, int resid) {
304 | TextView tv = (TextView) getView(widgetId);
305 | if (tv != null) {
306 | tv.setText(resid);
307 | }
308 | }
309 |
310 | /**
311 | * 设置背景颜色
312 | *
313 | * @param widgetId
314 | * @param color
315 | */
316 | public void setBackgroundColor(int widgetId, int color) {
317 | View view = getView(widgetId);
318 | if (view != null) {
319 | view.setBackgroundColor(color);
320 | }
321 | }
322 |
323 | /**
324 | * 设置背景颜色
325 | *
326 | * @param widgetId
327 | * @param resid
328 | */
329 | public void setBackgroundResource(int widgetId, int resid) {
330 | View view = getView(widgetId);
331 | if (view != null) {
332 | view.setBackgroundResource(resid);
333 | }
334 | }
335 |
336 | /**
337 | * ImageView设置图片
338 | *
339 | * @param widgetId
340 | * @param drawable
341 | */
342 | public void setImageDrawable(int widgetId, Drawable drawable) {
343 | ImageView iv = (ImageView) getView(widgetId);
344 | if (iv != null) {
345 | iv.setImageDrawable(drawable);
346 | }
347 | }
348 |
349 | /**
350 | * ImageView设置图片
351 | *
352 | * @param widgetId
353 | * @param resid
354 | */
355 | public void setImageResource(int widgetId, int resid) {
356 | ImageView iv = (ImageView) getView(widgetId);
357 | if (iv != null) {
358 | iv.setImageResource(resid);
359 | }
360 | }
361 |
362 | /**
363 | * ImageView设置图片
364 | *
365 | * @param widgetId
366 | * @param bm
367 | */
368 | public void setImageBitmap(int widgetId, Bitmap bm) {
369 | ImageView iv = (ImageView) getView(widgetId);
370 | if (iv != null) {
371 | iv.setImageBitmap(bm);
372 | }
373 | }
374 |
375 | }
376 |
377 | }
378 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/bll/MediaControlBiz.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.bll;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 | import android.util.Log;
6 |
7 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.GetMediaInfo;
8 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.GetPositionInfo;
9 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Next;
10 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Pause;
11 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Play;
12 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Previous;
13 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Seek;
14 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.SetAVTransportURI;
15 | import com.dongao.dlna.moduls.avtransport.callback.avtransport.Stop;
16 | import com.dongao.dlna.moduls.avtransport.callback.renderingcontrol.GetMute;
17 | import com.dongao.dlna.moduls.avtransport.callback.renderingcontrol.GetVolume;
18 | import com.dongao.dlna.moduls.avtransport.callback.renderingcontrol.SetMute;
19 | import com.dongao.dlna.moduls.avtransport.callback.renderingcontrol.SetVolume;
20 | import com.dongao.dlna.moduls.avtransport.constants.MediaControlWhat;
21 | import com.dongao.dlna.moduls.avtransport.entity.MediaInfo;
22 | import com.dongao.dlna.moduls.avtransport.entity.PositionInfo;
23 | import com.dongao.dlna.upnp.UpnpServiceBiz;
24 |
25 | import org.fourthline.cling.model.ModelUtil;
26 | import org.fourthline.cling.model.action.ActionInvocation;
27 | import org.fourthline.cling.model.message.UpnpResponse;
28 | import org.fourthline.cling.model.meta.Device;
29 | import org.fourthline.cling.model.meta.Service;
30 | import org.fourthline.cling.model.types.UDAServiceType;
31 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
32 | import org.fourthline.cling.support.contentdirectory.DIDLParser;
33 | import org.fourthline.cling.support.model.DIDLContent;
34 | import org.fourthline.cling.support.model.item.Item;
35 |
36 | /**
37 | * @author hubing
38 | * @version 1.0.0 2015-4-28
39 | */
40 |
41 | public class MediaControlBiz {
42 |
43 | public static final int SUCCESS = 0;
44 | public static final int FAILURE = 1;
45 |
46 | private static String TAG = MediaControlBiz.class.getSimpleName();
47 |
48 | private Service serviceAVT;
49 | private Service serviceRC;
50 | private UpnpServiceBiz upnpBiz;
51 | protected Handler handler;
52 | private UnsignedIntegerFourBytes instanceId;
53 |
54 | public MediaControlBiz(Device device, Handler handler, long mId) {
55 | serviceAVT = device.findService(new UDAServiceType("AVTransport", 1));
56 | serviceRC = device.findService(new UDAServiceType("RenderingControl", 1));
57 | upnpBiz = UpnpServiceBiz.newInstance();
58 | this.handler = handler;
59 | instanceId = new UnsignedIntegerFourBytes(mId);
60 | }
61 |
62 | /**
63 | * 设备要播放的网络url
64 | * @param url
65 | */
66 | public void setPlayUri(String url) {
67 | upnpBiz.execute(new SetAVTransportURI(instanceId, serviceAVT, url,
68 | null) {
69 |
70 | @Override
71 | public void failure(ActionInvocation invocation,
72 | UpnpResponse operation, String defaultMsg) {
73 | Log.d(TAG, "setPlayUri failure:" + defaultMsg);
74 | }
75 |
76 | @Override
77 | public void onSuccess(String defaultMsg) {
78 | Log.d(TAG, "SetAVTransportURI successed:" + defaultMsg);
79 | Message msg = Message.obtain(handler);
80 | msg.what = MediaControlWhat.SET_AVTRANSPORT_URI;
81 | msg.arg1 = SUCCESS;
82 | msg.sendToTarget();
83 | }
84 | });
85 | }
86 |
87 | /**
88 | * 设备要播放的媒体的uri
89 | * @param item
90 | */
91 | public void setPlayUri(Item item) {
92 | String uri = item.getFirstResource().getValue();
93 | DIDLContent didlContent = new DIDLContent();
94 | didlContent.addItem(item);
95 | DIDLParser parser = new DIDLParser();
96 | String metadata = "";
97 | try {
98 | metadata = parser.generate(didlContent);
99 | } catch (Exception e) {
100 | e.printStackTrace();
101 | }
102 | upnpBiz.execute(new SetAVTransportURI(instanceId, serviceAVT, uri,
103 | metadata) {
104 |
105 | @Override
106 | public void failure(ActionInvocation invocation,
107 | UpnpResponse operation, String defaultMsg) {
108 | Log.d(TAG, "setPlayUri failure:" + defaultMsg);
109 | }
110 |
111 | @Override
112 | public void onSuccess(String defaultMsg) {
113 | Log.d(TAG, "SetAVTransportURI successed:" + defaultMsg);
114 | Message msg = Message.obtain(handler);
115 | msg.what = MediaControlWhat.SET_AVTRANSPORT_URI;
116 | msg.arg1 = SUCCESS;
117 | msg.sendToTarget();
118 | }
119 | });
120 | }
121 |
122 | public interface GetPositionInfoListerner {
123 | void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg);
124 | void onSuccess(PositionInfo positionInfo);
125 | }
126 |
127 | protected GetPositionInfoListerner gpiListener;
128 |
129 | /**
130 | * 获取当前播放的媒体位置信息
131 | * @author hubing
132 | */
133 | public void getPositionInfo(GetPositionInfoListerner listener) {
134 | this.gpiListener = listener;
135 | upnpBiz.execute(new GetPositionInfo(instanceId, serviceAVT) {
136 |
137 | @Override
138 | public void failure(ActionInvocation invocation, UpnpResponse operation,
139 | String defaultMsg) {
140 | Log.d(TAG, "Get position info failure:" + defaultMsg);
141 | if (gpiListener != null) {
142 | gpiListener.failure(invocation, operation, defaultMsg);
143 | }
144 | }
145 |
146 | @Override
147 | public void onSuccess(PositionInfo positionInfo) {
148 | if (gpiListener != null) {
149 | gpiListener.onSuccess(positionInfo);
150 | }
151 | }
152 | });
153 | }
154 |
155 | /**
156 | * 获取当前播放的媒体信息
157 | */
158 | public void getMediaInfo() {
159 | upnpBiz.execute(new GetMediaInfo(instanceId, serviceAVT) {
160 |
161 | @Override
162 | public void failure(ActionInvocation invocation,
163 | UpnpResponse operation, String defaultMsg) {
164 | Log.d(TAG, "GetMediaInfo failure:" + defaultMsg);
165 | }
166 |
167 | @Override
168 | public void onSuccess(MediaInfo mediaInfo) {
169 |
170 | }
171 | });
172 | }
173 |
174 | /**
175 | * 播放
176 | * @author hubing
177 | */
178 | public void play() {
179 | upnpBiz.execute(new Play(instanceId, serviceAVT) {
180 | @Override
181 | public void failure(ActionInvocation invocation,
182 | UpnpResponse operation, String defaultMsg) {
183 | Log.d(TAG, "Play failure:" + defaultMsg);
184 | }
185 |
186 | @Override
187 | public void onSuccess(String defaultMsg) {
188 | Log.d(TAG, "Play successed:" + defaultMsg);
189 | Message msg = Message.obtain(handler);
190 | msg.what = MediaControlWhat.PLAY;
191 | msg.arg1 = SUCCESS;
192 | msg.sendToTarget();
193 | }
194 | });
195 | }
196 |
197 | /**
198 | * 暂停
199 | */
200 | public void pause() {
201 | upnpBiz.execute(new Pause(instanceId, serviceAVT) {
202 | @Override
203 | public void failure(ActionInvocation invocation,
204 | UpnpResponse operation, String defaultMsg) {
205 | Log.d(TAG, "Pause failure:" + defaultMsg);
206 | }
207 |
208 | @Override
209 | public void onSuccess(String defaultMsg) {
210 | Log.d(TAG, "Pause successed:" + defaultMsg);
211 | Message msg = Message.obtain(handler);
212 | msg.what = MediaControlWhat.PAUSE;
213 | msg.arg1 = SUCCESS;
214 | msg.sendToTarget();
215 | }
216 | });
217 | }
218 |
219 | /**
220 | * 下一首
221 | */
222 | public void next() {
223 | upnpBiz.execute(new Next(instanceId, serviceAVT) {
224 | @Override
225 | public void failure(ActionInvocation invocation,
226 | UpnpResponse operation, String defaultMsg) {
227 | Log.d(TAG, "Next failure:" + defaultMsg);
228 | }
229 |
230 | @Override
231 | public void onSuccess(String defaultMsg) {
232 | Log.d(TAG, "Next successed:" + defaultMsg);
233 | Message msg = Message.obtain(handler);
234 | msg.what = MediaControlWhat.NEXT;
235 | msg.arg1 = SUCCESS;
236 | msg.sendToTarget();
237 | }
238 | });
239 | }
240 |
241 | /**
242 | * 上一首
243 | */
244 | public void previous() {
245 | upnpBiz.execute(new Previous(instanceId, serviceAVT) {
246 | @Override
247 | public void failure(ActionInvocation invocation,
248 | UpnpResponse operation, String defaultMsg) {
249 | Log.d(TAG, "Previous failure:" + defaultMsg);
250 | }
251 |
252 | @Override
253 | public void onSuccess(String defaultMsg) {
254 | Log.d(TAG, "Previous successed:" + defaultMsg);
255 | Message msg = Message.obtain(handler);
256 | msg.what = MediaControlWhat.PREVIOUS;
257 | msg.arg1 = SUCCESS;
258 | msg.sendToTarget();
259 | }
260 | });
261 | }
262 |
263 | /**
264 | * 停止播放
265 | */
266 | public void stop() {
267 | upnpBiz.execute(new Stop(instanceId, serviceAVT) {
268 | @Override
269 | public void failure(ActionInvocation invocation,
270 | UpnpResponse operation, String defaultMsg) {
271 | Log.d(TAG, "Stop failure:" + defaultMsg);
272 | }
273 |
274 | @Override
275 | public void onSuccess(String defaultMsg) {
276 | Log.d(TAG, "Stop successed:" + defaultMsg);
277 | Message msg = Message.obtain(handler);
278 | msg.what = MediaControlWhat.STOP;
279 | msg.arg1 = SUCCESS;
280 | msg.sendToTarget();
281 | }
282 | });
283 | }
284 |
285 | /**
286 | * 设置跳转时间
287 | * @param totalTime 媒体总时长
288 | * @param percent 跳转的百分比
289 | */
290 | public void seek(String totalTime, int percent) {
291 | long duration = ModelUtil.fromTimeString(totalTime);
292 | long seekTime = percent * duration / 100;
293 | String seekTo = ModelUtil.toTimeString(seekTime);
294 | upnpBiz.execute(new Seek(instanceId, serviceAVT, seekTo) {
295 | @Override
296 | public void failure(ActionInvocation invocation,
297 | UpnpResponse operation, String defaultMsg) {
298 | Log.d(TAG, "Seek failure:" + defaultMsg);
299 | }
300 |
301 | @Override
302 | public void onSuccess(String defaultMsg) {
303 | Log.d(TAG, "Seek successed:" + defaultMsg);
304 | Message msg = Message.obtain(handler);
305 | msg.what = MediaControlWhat.SEEK;
306 | msg.arg1 = SUCCESS;
307 | msg.sendToTarget();
308 | }
309 | });
310 | }
311 |
312 | /**
313 | * 获取当前静音状态
314 | */
315 | public void getMute() {
316 | upnpBiz.execute(new GetMute(serviceRC, instanceId) {
317 |
318 | @Override
319 | public void failure(ActionInvocation invocation,
320 | UpnpResponse operation, String defaultMsg) {
321 | Log.d(TAG, "GetVolume failure:" + defaultMsg);
322 | }
323 |
324 | @Override
325 | public void onSuccess(boolean currentMute) {
326 | Log.d(TAG, "GetVolume successed:current mute = "
327 | + currentMute);
328 | Message msg = Message.obtain(handler);
329 | msg.what = MediaControlWhat.GET_MUTE;
330 | msg.arg1 = SUCCESS;
331 | msg.obj = currentMute;
332 | msg.sendToTarget();
333 | }
334 | });
335 | }
336 |
337 | /**
338 | * 设置是否开启静音模式
339 | * @param desiredMute true表示开启静音
340 | */
341 | public void setMute(boolean desiredMute) {
342 | upnpBiz.execute(new SetMute(serviceRC, instanceId, desiredMute) {
343 |
344 | @Override
345 | public void failure(ActionInvocation invocation,
346 | UpnpResponse operation, String defaultMsg) {
347 | Log.d(TAG, "GetVolume failure:" + defaultMsg);
348 | }
349 |
350 | @Override
351 | public void onSuccess(String defaultMsg) {
352 | Log.d(TAG, "SetMute successed:" + defaultMsg);
353 | Message msg = Message.obtain(handler);
354 | msg.what = MediaControlWhat.SET_MUTE;
355 | msg.arg1 = SUCCESS;
356 | msg.sendToTarget();
357 | }
358 | });
359 | }
360 |
361 | /**
362 | * 获取当前音量大小
363 | */
364 | public void getVolume() {
365 | upnpBiz.execute(new GetVolume(serviceRC, instanceId) {
366 |
367 | @Override
368 | public void failure(ActionInvocation invocation,
369 | UpnpResponse operation, String defaultMsg) {
370 | Log.d(TAG, "GetVolume failure:" + defaultMsg);
371 | }
372 |
373 | @Override
374 | public void onSuccess(int currentVolume) {
375 | Log.d(TAG, "GetVolume successed:current volume = "
376 | + currentVolume);
377 | Message msg = Message.obtain(handler);
378 | msg.what = MediaControlWhat.GET_VOLUME;
379 | msg.arg1 = SUCCESS;
380 | msg.arg2 = currentVolume;
381 | msg.sendToTarget();
382 | }
383 | });
384 | }
385 |
386 | /**
387 | * 设置音量大小,范围0-100
388 | * @param volume
389 | */
390 | public void setVolume(int volume) {
391 | upnpBiz.execute(new SetVolume(serviceRC, instanceId, volume) {
392 |
393 | @Override
394 | public void failure(ActionInvocation invocation,
395 | UpnpResponse operation, String defaultMsg) {
396 | Log.d(TAG, "SetVolume failure:" + defaultMsg);
397 | }
398 |
399 | @Override
400 | public void onSuccess(String defaultMsg) {
401 | Log.d(TAG, "SetVolume successed:" + defaultMsg);
402 | Message msg = Message.obtain(handler);
403 | msg.what = MediaControlWhat.SET_VOLUME;
404 | msg.arg1 = SUCCESS;
405 | msg.sendToTarget();
406 | }
407 | });
408 | }
409 |
410 | }
411 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/bll/MediaEventBiz.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.bll;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 | import android.util.Log;
6 |
7 | import com.dongao.dlna.moduls.avtransport.constants.MediaEventWhat;
8 | import com.dongao.dlna.moduls.avtransport.entity.AVTransportInfo;
9 | import com.dongao.dlna.moduls.avtransport.entity.RenderingControlInfo;
10 | import com.dongao.dlna.moduls.avtransport.event.AVTransportEvent;
11 | import com.dongao.dlna.moduls.avtransport.event.RenderingControlEvent;
12 | import com.dongao.dlna.upnp.UpnpServiceBiz;
13 |
14 | import org.fourthline.cling.model.gena.CancelReason;
15 | import org.fourthline.cling.model.gena.GENASubscription;
16 | import org.fourthline.cling.model.message.UpnpResponse;
17 | import org.fourthline.cling.model.meta.Device;
18 | import org.fourthline.cling.model.meta.Service;
19 | import org.fourthline.cling.model.types.UDAServiceType;
20 |
21 | /**
22 | * @author hubing
23 | * @version 1.0.0 2015-5-5
24 | */
25 |
26 | public class MediaEventBiz {
27 |
28 | private static String TAG = MediaControlBiz.class.getSimpleName();
29 |
30 | private Device device;
31 | private UpnpServiceBiz upnpBiz;
32 | protected Handler handler;
33 |
34 | private RenderingControlEvent serviceRCEvent;
35 | private AVTransportEvent transportEvent;
36 |
37 | public MediaEventBiz(Device device, Handler handler) {
38 | this.device = device;
39 | this.handler = handler;
40 | upnpBiz = UpnpServiceBiz.newInstance();
41 | }
42 |
43 | public void addRenderingEvent() {
44 | Service serviceRC = device.findService(new UDAServiceType("RenderingControl", 1));
45 | serviceRCEvent = new RenderingControlEvent(serviceRC) {
46 |
47 | @Override
48 | protected void failed(GENASubscription subscription,
49 | UpnpResponse responseStatus, Exception exception, String defaultMsg) {
50 | Log.d(TAG, "Rendering failed:" + defaultMsg);
51 | }
52 |
53 | @Override
54 | protected void eventsMissed(GENASubscription subscription,
55 | int numberOfMissedEvents) {
56 | Log.d(TAG, "Rendering eventsMissed:" + numberOfMissedEvents);
57 | }
58 |
59 | @Override
60 | protected void established(GENASubscription subscription) {
61 | Log.d(TAG, "Rendering established:" + subscription.toString());
62 | }
63 |
64 | @Override
65 | protected void ended(GENASubscription subscription, CancelReason reason,
66 | UpnpResponse responseStatus) {
67 | Log.d(TAG, "Rendering ended");
68 | }
69 |
70 | @Override
71 | public void received(RenderingControlInfo controlInfo) {
72 | Log.d(TAG, "Rendering received:" + controlInfo.toString());
73 | Message msg = Message.obtain(handler);
74 | msg.what = MediaEventWhat.RENDERING_CONTROL;
75 | msg.obj = controlInfo;
76 | msg.sendToTarget();
77 | }
78 | };
79 | upnpBiz.execute(serviceRCEvent);
80 | }
81 |
82 | public void removeRenderingEvent() {
83 | if (serviceRCEvent != null) {
84 | serviceRCEvent.end();
85 | Log.d(TAG, "Remove rendering event");
86 | }
87 | }
88 |
89 | public void addAVTransportEvent() {
90 | Service serviceAVT = device.findService(new UDAServiceType("AVTransport", 1));
91 | transportEvent = new AVTransportEvent(serviceAVT) {
92 |
93 | @Override
94 | protected void failed(GENASubscription subscription,
95 | UpnpResponse responseStatus, Exception exception, String defaultMsg) {
96 | Log.d(TAG, "AVTransport failed:" + defaultMsg);
97 | }
98 |
99 | @Override
100 | protected void eventsMissed(GENASubscription subscription,
101 | int numberOfMissedEvents) {
102 | Log.d(TAG, "AVTransport eventsMissed:" + numberOfMissedEvents);
103 | }
104 |
105 | @Override
106 | protected void established(GENASubscription subscription) {
107 | Log.d(TAG, "AVTransport established:" + subscription.toString());
108 | }
109 |
110 | @Override
111 | protected void ended(GENASubscription subscription, CancelReason reason,
112 | UpnpResponse responseStatus) {
113 | Log.d(TAG, "AVTransport ended");
114 | }
115 |
116 | @Override
117 | public void received(AVTransportInfo avTransportInfo) {
118 | Log.d(TAG, "AVTransport received:" + avTransportInfo.toString());
119 | Message msg = Message.obtain(handler);
120 | msg.what = MediaEventWhat.AV_TRANSPORT;
121 | msg.obj = avTransportInfo;
122 | msg.sendToTarget();
123 | }
124 | };
125 | upnpBiz.execute(transportEvent);
126 | }
127 |
128 | public void removeAVTransportEvent() {
129 | if (transportEvent != null) {
130 | transportEvent.end();
131 | Log.d(TAG, "Remove AVTransport event");
132 | }
133 | }
134 |
135 | }
136 |
137 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/bll/RealtimeUpdatePositionInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.bll;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 | import android.widget.SeekBar;
6 | import android.widget.TextView;
7 |
8 | import com.dongao.dlna.moduls.avtransport.entity.PositionInfo;
9 |
10 | import org.fourthline.cling.model.action.ActionInvocation;
11 | import org.fourthline.cling.model.message.UpnpResponse;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public class RealtimeUpdatePositionInfo extends AsyncTask {
19 |
20 | private static String TAG = RealtimeUpdatePositionInfo.class.getSimpleName();
21 |
22 | private boolean isPlaying; // 是否正在播放
23 |
24 | private SeekBar sbPlayback;
25 | private TextView tvCurTime;
26 | private TextView tvTotalTime;
27 | private MediaControlBiz controlBiz;
28 |
29 | public RealtimeUpdatePositionInfo(MediaControlBiz controlBiz, SeekBar sbPlayback, TextView tvCurTime, TextView tvTotalTime) {
30 | this.sbPlayback = sbPlayback;
31 | this.tvCurTime = tvCurTime;
32 | this.tvTotalTime = tvTotalTime;
33 | this.controlBiz = controlBiz;
34 |
35 | sbPlayback.setMax(100);
36 | isPlaying = true;
37 | }
38 |
39 | @Override
40 | protected PositionInfo doInBackground(Void... params) {
41 | PositionInfo info = null;
42 | while (!isCancelled()) {
43 | while (isPlaying) {
44 | try {
45 | Thread.sleep(1000);
46 | controlBiz.getPositionInfo(new MediaControlBiz.GetPositionInfoListerner() {
47 |
48 | @Override
49 | public void onSuccess(PositionInfo positionInfo) {
50 | publishProgress(positionInfo);
51 | }
52 |
53 | @Override
54 | public void failure(ActionInvocation invocation, UpnpResponse operation,
55 | String defaultMsg) {
56 | Log.d(TAG, "Get position info failure:" + defaultMsg);
57 | }
58 | });
59 | } catch (InterruptedException e) {
60 | Log.d(TAG, "Get position info failure:" + e.getMessage());
61 | }
62 | }
63 | }
64 | return info;
65 | }
66 |
67 | @Override
68 | protected void onProgressUpdate(PositionInfo... values) {
69 | PositionInfo info = values[0];
70 | sbPlayback.setProgress(info.getElapsedPercent());
71 | tvCurTime.setText(info.getRelTime());
72 | tvTotalTime.setText(info.getTrackDuration());
73 | }
74 |
75 | public boolean isPlaying() {
76 | return isPlaying;
77 | }
78 |
79 | /**
80 | * 设置是否播放
81 | * @param isPlaying
82 | */
83 | public void setPlaying(boolean isPlaying) {
84 | this.isPlaying = isPlaying;
85 | }
86 |
87 | @Override
88 | protected void onCancelled() {
89 | super.onCancelled();
90 | sbPlayback = null;
91 | tvCurTime = null;
92 | tvTotalTime = null;
93 | controlBiz = null;
94 | }
95 |
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/GetCurrentTransportActions.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 | import org.fourthline.cling.support.model.TransportAction;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public abstract class GetCurrentTransportActions extends UpnpActionCallback {
19 |
20 | private static String TAG = GetCurrentTransportActions.class.getSimpleName();
21 |
22 | public GetCurrentTransportActions(UnsignedIntegerFourBytes instanceId,
23 | Service service) {
24 | super(new ActionInvocation(
25 | service.getAction("GetCurrentTransportActions")));
26 | try {
27 | setInput("InstanceID", instanceId);
28 | } catch (InvalidValueException e) {
29 | e.printStackTrace();
30 | }
31 | }
32 |
33 | @Override
34 | public void received(ActionInvocation invocation, Map result) {
35 | String actionsString = (String) result.get("Actions");
36 | onSuccess(TransportAction.valueOfCommaSeparatedList(actionsString));
37 | }
38 |
39 | public abstract void onSuccess(TransportAction[] actions);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/GetDeviceCapabilities.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 | import org.fourthline.cling.support.model.DeviceCapabilities;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public abstract class GetDeviceCapabilities extends UpnpActionCallback {
19 |
20 | private static String TAG = GetDeviceCapabilities.class.getSimpleName();
21 |
22 | public GetDeviceCapabilities(UnsignedIntegerFourBytes instanceId,
23 | Service service) {
24 | super(new ActionInvocation(service.getAction("GetDeviceCapabilities")));
25 | try {
26 | setInput("InstanceID", instanceId);
27 | } catch (InvalidValueException e) {
28 | e.printStackTrace();
29 | }
30 | }
31 |
32 | @Override
33 | public void received(ActionInvocation invocation, Map result) {
34 | DeviceCapabilities caps = new DeviceCapabilities(
35 | invocation.getOutputMap());
36 | onSuccess(caps);
37 | }
38 |
39 | public abstract void onSuccess(DeviceCapabilities caps);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/GetMediaInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.moduls.avtransport.entity.MediaInfo;
4 | import com.dongao.dlna.upnp.UpnpActionCallback;
5 |
6 | import org.fourthline.cling.model.action.ActionInvocation;
7 | import org.fourthline.cling.model.meta.Service;
8 | import org.fourthline.cling.model.types.InvalidValueException;
9 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public abstract class GetMediaInfo extends UpnpActionCallback {
19 |
20 | private static String TAG = GetMediaInfo.class.getSimpleName();
21 |
22 | public GetMediaInfo(UnsignedIntegerFourBytes instanceId, Service service) {
23 | super(new ActionInvocation(service.getAction("GetMediaInfo")));
24 | try {
25 | setInput("InstanceID", instanceId);
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | MediaInfo mediaInfo = new MediaInfo(result);
34 | onSuccess(mediaInfo);
35 | }
36 |
37 | public abstract void onSuccess(MediaInfo mediaInfo);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/GetPositionInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.moduls.avtransport.entity.PositionInfo;
4 | import com.dongao.dlna.upnp.UpnpActionCallback;
5 |
6 | import org.fourthline.cling.model.action.ActionInvocation;
7 | import org.fourthline.cling.model.meta.Service;
8 | import org.fourthline.cling.model.types.InvalidValueException;
9 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public abstract class GetPositionInfo extends UpnpActionCallback {
19 |
20 | private static String TAG = GetPositionInfo.class.getSimpleName();
21 |
22 | public GetPositionInfo(UnsignedIntegerFourBytes instanceId,
23 | Service service) {
24 | super(new ActionInvocation(service.getAction("GetPositionInfo")));
25 | try {
26 | setInput("InstanceID", instanceId);
27 | } catch (InvalidValueException e) {
28 | e.printStackTrace();
29 | }
30 | }
31 |
32 | @Override
33 | public void received(ActionInvocation invocation, Map result) {
34 | PositionInfo positionInfo = new PositionInfo(result);
35 | onSuccess(positionInfo);
36 | }
37 |
38 | public abstract void onSuccess(PositionInfo positionInfo);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/GetTransportInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 | import org.fourthline.cling.support.model.TransportInfo;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-28
16 | */
17 |
18 | public abstract class GetTransportInfo extends UpnpActionCallback {
19 |
20 | private static String TAG = GetTransportInfo.class.getSimpleName();
21 |
22 | public GetTransportInfo(UnsignedIntegerFourBytes instanceId, Service service) {
23 | super(new ActionInvocation(service.getAction("GetTransportInfo")));
24 | try {
25 | setInput("InstanceID", instanceId);
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | TransportInfo transportInfo = new TransportInfo(
34 | invocation.getOutputMap());
35 | onSuccess(transportInfo);
36 | }
37 |
38 | public abstract void onSuccess(TransportInfo transportInfo);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Next.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Next extends UpnpActionCallback {
18 |
19 | private static String TAG = Next.class.getSimpleName();
20 |
21 | public Next(UnsignedIntegerFourBytes instanceId, Service service) {
22 | super(new ActionInvocation(service.getAction("Next")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | } catch (InvalidValueException e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | @Override
31 | public void received(ActionInvocation invocation, Map result) {
32 | onSuccess("Next successful");
33 | }
34 |
35 | public abstract void onSuccess(String msg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Pause.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Pause extends UpnpActionCallback {
18 |
19 | private static String TAG = Pause.class.getSimpleName();
20 |
21 | public Pause(UnsignedIntegerFourBytes instanceId, Service service) {
22 | super(new ActionInvocation(service.getAction("Pause")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | } catch (InvalidValueException e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | @Override
31 | public void received(ActionInvocation invocation, Map result) {
32 | onSuccess("Pause play successful");
33 | }
34 |
35 | public abstract void onSuccess(String msg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Play.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Play extends UpnpActionCallback {
18 |
19 | private static String TAG = Play.class.getSimpleName();
20 |
21 | public Play(UnsignedIntegerFourBytes instanceId, Service service) {
22 | super(new ActionInvocation(service.getAction("Play")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | setInput("Speed", "1");
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | onSuccess("Play successful");
34 | }
35 |
36 | public abstract void onSuccess(String msg);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Previous.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Previous extends UpnpActionCallback {
18 |
19 | private static String TAG = Previous.class.getSimpleName();
20 |
21 | public Previous(UnsignedIntegerFourBytes instanceId, Service service) {
22 | super(new ActionInvocation(service.getAction("Previous")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | } catch (InvalidValueException e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | @Override
31 | public void received(ActionInvocation invocation, Map result) {
32 | onSuccess("Previous successful");
33 | }
34 |
35 | public abstract void onSuccess(String msg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Seek.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Seek extends UpnpActionCallback {
18 |
19 | private static String TAG = Seek.class.getSimpleName();
20 |
21 | public Seek(UnsignedIntegerFourBytes instanceId, Service service,
22 | String seekTo) {
23 | super(new ActionInvocation(service.getAction("Seek")));
24 | try {
25 | setInput("InstanceID", instanceId);
26 | /**
27 | * ABS_COUNT
28 | * TRACK_NR
29 | * REL_TIME
30 | */
31 | setInput("Unit", "REL_TIME");
32 | setInput("Target", seekTo);
33 | } catch (InvalidValueException e) {
34 | e.printStackTrace();
35 | }
36 | }
37 |
38 | @Override
39 | public void received(ActionInvocation invocation, Map result) {
40 | onSuccess("Seek successful");
41 | }
42 |
43 | public abstract void onSuccess(String msg);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/SetAVTransportURI.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-23
15 | */
16 |
17 | public abstract class SetAVTransportURI extends UpnpActionCallback {
18 |
19 | private static String TAG = SetAVTransportURI.class.getSimpleName();
20 |
21 | public SetAVTransportURI(UnsignedIntegerFourBytes instanceId,
22 | Service service, String uri, String metadata) {
23 | super(new ActionInvocation(service.getAction("SetAVTransportURI")));
24 | try {
25 | setInput("InstanceID", instanceId);
26 | setInput("CurrentURI", uri);
27 | setInput("CurrentURIMetaData", metadata);
28 | } catch (InvalidValueException e) {
29 | e.printStackTrace();
30 | }
31 | }
32 |
33 | @Override
34 | public void received(ActionInvocation invocation, Map result) {
35 | onSuccess("Set AVTransport URI successful");
36 | }
37 |
38 | public abstract void onSuccess(String msg);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/avtransport/Stop.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.avtransport;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-28
15 | */
16 |
17 | public abstract class Stop extends UpnpActionCallback {
18 |
19 | private static String TAG = Stop.class.getSimpleName();
20 |
21 | public Stop(UnsignedIntegerFourBytes instanceId, Service service) {
22 | super(new ActionInvocation(service.getAction("Stop")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | } catch (InvalidValueException e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | @Override
31 | public void received(ActionInvocation invocation, Map result) {
32 | onSuccess("Stop play successful");
33 | }
34 |
35 | public abstract void onSuccess(String msg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/GetMute.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-29
15 | */
16 |
17 | public abstract class GetMute extends UpnpActionCallback {
18 |
19 | private static String TAG = GetMute.class.getSimpleName();
20 |
21 | public GetMute(Service service, UnsignedIntegerFourBytes instanceId) {
22 | super(new ActionInvocation(service.getAction("GetMute")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | setInput("Channel", "Master");
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | onSuccess((Boolean) result.get("CurrentMute"));
34 | }
35 |
36 | public abstract void onSuccess(boolean currentMute);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/GetVolume.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-29
15 | */
16 |
17 | public abstract class GetVolume extends UpnpActionCallback {
18 |
19 | private static String TAG = GetVolume.class.getSimpleName();
20 |
21 | public GetVolume(Service service, UnsignedIntegerFourBytes instanceId) {
22 | super(new ActionInvocation(service.getAction("GetVolume")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | setInput("Channel", "Master");
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | onSuccess(Integer.parseInt(result.get("CurrentVolume").toString()));
34 | }
35 |
36 | public abstract void onSuccess(int currentVolume);
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/ListPresets.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-29
15 | */
16 |
17 | public abstract class ListPresets extends UpnpActionCallback {
18 |
19 | private static String TAG = ListPresets.class.getSimpleName();
20 |
21 | public ListPresets(Service service, UnsignedIntegerFourBytes instanceId) {
22 | super(new ActionInvocation(service.getAction("ListPresets")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | } catch (InvalidValueException e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | @Override
31 | public void received(ActionInvocation invocation, Map result) {
32 | onSuccess((String) result.get("CurrentPresetNameList"));
33 | }
34 |
35 | public abstract void onSuccess(String msg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/SelectPreset.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import com.dongao.dlna.upnp.UpnpActionCallback;
4 |
5 | import org.fourthline.cling.model.action.ActionInvocation;
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * @author hubing
14 | * @version 1.0.0 2015-4-29
15 | */
16 |
17 | public abstract class SelectPreset extends UpnpActionCallback {
18 |
19 | private static String TAG = SelectPreset.class.getSimpleName();
20 |
21 | public SelectPreset(Service service, UnsignedIntegerFourBytes instanceId, String presetName) {
22 | super(new ActionInvocation(service.getAction("SelectPreset")));
23 | try {
24 | setInput("InstanceID", instanceId);
25 | setInput("PresetName", presetName);
26 | } catch (InvalidValueException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 | @Override
32 | public void received(ActionInvocation invocation, Map result) {
33 | onSuccess("SelectPreset successed");
34 | }
35 |
36 | public abstract void onSuccess(String msg);
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/SetMute.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import android.util.Log;
4 |
5 | import com.dongao.dlna.upnp.UpnpActionCallback;
6 |
7 | import org.fourthline.cling.model.action.ActionInvocation;
8 | import org.fourthline.cling.model.meta.Service;
9 | import org.fourthline.cling.model.types.InvalidValueException;
10 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
11 |
12 | import java.util.Map;
13 |
14 | /**
15 | * @author hubing
16 | * @version 1.0.0 2015-4-29
17 | */
18 |
19 | public abstract class SetMute extends UpnpActionCallback {
20 |
21 | private static String TAG = SetMute.class.getSimpleName();
22 |
23 | public SetMute(Service service, UnsignedIntegerFourBytes instanceId,
24 | boolean desiredMute) {
25 | super(new ActionInvocation(service.getAction("SetMute")));
26 | try {
27 | setInput("InstanceID", instanceId);
28 | setInput("Channel", "Master");
29 | setInput("DesiredMute", desiredMute);
30 | } catch (InvalidValueException e) {
31 | e.printStackTrace();
32 | }
33 | }
34 |
35 | @Override
36 | public void received(ActionInvocation invocation, Map result) {
37 | onSuccess("SetMute successed");
38 | }
39 |
40 | public abstract void onSuccess(String msg);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/callback/renderingcontrol/SetVolume.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.callback.renderingcontrol;
2 |
3 | import android.util.Log;
4 |
5 | import com.dongao.dlna.upnp.UpnpActionCallback;
6 |
7 | import org.fourthline.cling.model.action.ActionInvocation;
8 | import org.fourthline.cling.model.meta.Service;
9 | import org.fourthline.cling.model.types.InvalidValueException;
10 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
11 | import org.fourthline.cling.model.types.UnsignedIntegerTwoBytes;
12 |
13 | import java.util.Map;
14 |
15 | /**
16 | * @author hubing
17 | * @version 1.0.0 2015-4-29
18 | */
19 |
20 | public abstract class SetVolume extends UpnpActionCallback {
21 |
22 | private static String TAG = SetVolume.class.getSimpleName();
23 |
24 | /**
25 | *
26 | * @param service
27 | * @param instanceId
28 | * @param volume Allowed value range: 0-100,step: 1
29 | */
30 | public SetVolume(Service service, UnsignedIntegerFourBytes instanceId,
31 | long volume) {
32 | super(new ActionInvocation(service.getAction("SetVolume")));
33 | try {
34 | setInput("InstanceID", instanceId);
35 | setInput("Channel", "Master");
36 | setInput("DesiredVolume", new UnsignedIntegerTwoBytes(volume));
37 | } catch (InvalidValueException e) {
38 | e.printStackTrace();
39 | }
40 | }
41 |
42 | @Override
43 | public void received(ActionInvocation invocation, Map result) {
44 | onSuccess("SetVolume successed");
45 | }
46 |
47 | public abstract void onSuccess(String msg);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/constants/MediaControlWhat.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.constants;
2 |
3 | /**
4 | * @author hubing
5 | * @version 1.0.0 2015-4-28
6 | */
7 |
8 | public class MediaControlWhat {
9 |
10 | // 获取当前静音状态
11 | public static final int GET_MUTE = 10;
12 | // 打开/关闭静音模式
13 | public static final int SET_MUTE = 11;
14 | // 获取当前音量大小
15 | public static final int GET_VOLUME = 12;
16 | // 设置音量大小
17 | public static final int SET_VOLUME = 13;
18 |
19 | // 停止
20 | public static final int STOP = 14;
21 | // 播放
22 | public static final int PLAY = 15;
23 | // 暂停
24 | public static final int PAUSE = 16;
25 | // 跳转到指定位置
26 | public static final int SEEK = 17;
27 | // 下一首
28 | public static final int NEXT = 18;
29 | // 上一首
30 | public static final int PREVIOUS = 19;
31 | // 设置播放URI
32 | public static final int SET_AVTRANSPORT_URI = 20;
33 | // 获取媒体信息
34 | public static final int GET_MEDIAINFO = 21;
35 | // 获取播放位置信息
36 | public static final int GET_POSITIONINFO = 22;
37 | // 获取传输信息
38 | public static final int GET_TRANSPORT_INFO = 23;
39 | // 获取当前传输action
40 | public static final int GET_CURRENT_TRANSPORT_ACTION = 24;
41 | // 获取设备支持的功能
42 | public static final int GET_DEVICE_CAPABILITIES = 25;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/constants/MediaEventWhat.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.constants;
2 |
3 | /**
4 | * @author hubing
5 | * @version 1.0.0 2015-5-5
6 | */
7 |
8 | public class MediaEventWhat {
9 |
10 | // 媒体渲染控制
11 | public static final int RENDERING_CONTROL = 100;
12 | // AV传输
13 | public static final int AV_TRANSPORT = 101;
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/constants/TransportState.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.constants;
2 |
3 | /**
4 | * @author hubing
5 | * @version 1.0.0 2015-5-6
6 | */
7 |
8 | public class TransportState {
9 |
10 | public static final String STOPPED = "STOPPED";
11 | public static final String PAUSED_PLAYBACK = "PAUSED_PLAYBACK";
12 | public static final String PLAYING = "PLAYING";
13 | public static final String TRANSITIONING = "TRANSITIONING";
14 | public static final String NO_MEDIA_PRESENT = "NO_MEDIA_PRESENT";
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/constants/TransportStatus.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.constants;
2 |
3 | /**
4 | * @author hubing
5 | * @version 1.0.0 2015-5-6
6 | */
7 |
8 | public class TransportStatus {
9 |
10 | public static final String OK = "OK";
11 | public static final String ERROR_OCCURRED = "ERROR_OCCURRED";
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/entity/AVTransportInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.entity;
2 |
3 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
4 |
5 | import java.util.HashMap;
6 |
7 | /**
8 | * @author hubing
9 | * @version 1.0.0 2015-5-6
10 | */
11 |
12 | public class AVTransportInfo {
13 |
14 | // 保存值的更改状态
15 | private HashMap valueIsChange = new HashMap();
16 |
17 | public static final String TRANSPORT_STATE = "TransportState";
18 | public static final String TRANSPORT_STATUS = "TransportStatus";
19 | public static final String NUMBER_Of_TRACKS = "NumberOfTracks";
20 | public static final String CURRENT_TRACK = "CurrentTrack";
21 | public static final String CURRENT_TRACK_DURATION = "CurrentTrackDuration";
22 | public static final String CURRENT_MEDIA_DURATION = "CurrentMediaDuration";
23 | public static final String CURRENT_TRACK_URI = "CurrentTrackURI";
24 | public static final String AV_TRANSPORT_URI = "AVTransportURI";
25 | public static final String CURRENT_TRACK_METADATA = "CurrentTrackMetaData";
26 | public static final String CURRENT_TRANSPORT_ACTIONS = "CurrentTransportActions";
27 |
28 | // 传输状态(播放、暂停等)
29 | private String transportState;
30 | // 传输过程状态
31 | private String transportStatus;
32 | private UnsignedIntegerFourBytes numberOfTracks;
33 | private UnsignedIntegerFourBytes currentTrack;
34 | private String currentTrackDuration;
35 | private String currentMediaDuration;
36 | private String currentTrackURI;
37 | private String AVTransportURI;
38 | private String currentTrackMetaData;
39 | private String currentTransportActions;
40 |
41 | public AVTransportInfo() {
42 | valueIsChange.put(TRANSPORT_STATE, false);
43 | valueIsChange.put(TRANSPORT_STATUS, false);
44 | valueIsChange.put(NUMBER_Of_TRACKS, false);
45 | valueIsChange.put(CURRENT_TRACK, false);
46 | valueIsChange.put(CURRENT_TRACK_DURATION, false);
47 | valueIsChange.put(CURRENT_MEDIA_DURATION, false);
48 | valueIsChange.put(CURRENT_TRACK_URI, false);
49 | valueIsChange.put(AV_TRANSPORT_URI, false);
50 | valueIsChange.put(CURRENT_TRACK_METADATA, false);
51 | valueIsChange.put(CURRENT_TRANSPORT_ACTIONS, false);
52 | }
53 |
54 | public AVTransportInfo(HashMap valueIsChange,
55 | String transportState, String transportStatus,
56 | UnsignedIntegerFourBytes numberOfTracks,
57 | UnsignedIntegerFourBytes currentTrack, String currentTrackDuration,
58 | String currentMediaDuration, String currentTrackURI,
59 | String aVTransportURI, String currentTrackMetaData,
60 | String currentTransportActions) {
61 | this.valueIsChange = valueIsChange;
62 | this.transportState = transportState;
63 | this.transportStatus = transportStatus;
64 | this.numberOfTracks = numberOfTracks;
65 | this.currentTrack = currentTrack;
66 | this.currentTrackDuration = currentTrackDuration;
67 | this.currentMediaDuration = currentMediaDuration;
68 | this.currentTrackURI = currentTrackURI;
69 | AVTransportURI = aVTransportURI;
70 | this.currentTrackMetaData = currentTrackMetaData;
71 | this.currentTransportActions = currentTransportActions;
72 | valueIsChange.put(TRANSPORT_STATE, true);
73 | valueIsChange.put(TRANSPORT_STATUS, true);
74 | valueIsChange.put(NUMBER_Of_TRACKS, true);
75 | valueIsChange.put(CURRENT_TRACK, true);
76 | valueIsChange.put(CURRENT_TRACK_DURATION, true);
77 | valueIsChange.put(CURRENT_MEDIA_DURATION, true);
78 | valueIsChange.put(CURRENT_TRACK_URI, true);
79 | valueIsChange.put(AV_TRANSPORT_URI, true);
80 | valueIsChange.put(CURRENT_TRACK_METADATA, true);
81 | valueIsChange.put(CURRENT_TRANSPORT_ACTIONS, true);
82 | }
83 |
84 | public HashMap getValueIsChange() {
85 | return valueIsChange;
86 | }
87 |
88 | public String getTransportState() {
89 | return transportState;
90 | }
91 |
92 | public void setTransportState(String transportState) {
93 | this.transportState = transportState;
94 | valueIsChange.put(TRANSPORT_STATE, true);
95 | }
96 |
97 | public String getTransportStatus() {
98 | return transportStatus;
99 | }
100 |
101 | public void setTransportStatus(String transportStatus) {
102 | this.transportStatus = transportStatus;
103 | valueIsChange.put(TRANSPORT_STATUS, true);
104 | }
105 |
106 | public UnsignedIntegerFourBytes getNumberOfTracks() {
107 | return numberOfTracks;
108 | }
109 |
110 | public void setNumberOfTracks(UnsignedIntegerFourBytes numberOfTracks) {
111 | this.numberOfTracks = numberOfTracks;
112 | valueIsChange.put(NUMBER_Of_TRACKS, true);
113 | }
114 |
115 | public UnsignedIntegerFourBytes getCurrentTrack() {
116 | return currentTrack;
117 | }
118 |
119 | public void setCurrentTrack(UnsignedIntegerFourBytes currentTrack) {
120 | this.currentTrack = currentTrack;
121 | valueIsChange.put(CURRENT_TRACK, true);
122 | }
123 |
124 | public String getCurrentTrackDuration() {
125 | return currentTrackDuration;
126 | }
127 |
128 | public void setCurrentTrackDuration(String currentTrackDuration) {
129 | this.currentTrackDuration = currentTrackDuration;
130 | valueIsChange.put(CURRENT_TRACK_DURATION, true);
131 | }
132 |
133 | public String getCurrentMediaDuration() {
134 | return currentMediaDuration;
135 | }
136 |
137 | public void setCurrentMediaDuration(String currentMediaDuration) {
138 | this.currentMediaDuration = currentMediaDuration;
139 | valueIsChange.put(CURRENT_MEDIA_DURATION, true);
140 | }
141 |
142 | public String getCurrentTrackURI() {
143 | return currentTrackURI;
144 | }
145 |
146 | public void setCurrentTrackURI(String currentTrackURI) {
147 | this.currentTrackURI = currentTrackURI;
148 | valueIsChange.put(CURRENT_TRACK_URI, true);
149 | }
150 |
151 | public String getAVTransportURI() {
152 | return AVTransportURI;
153 | }
154 |
155 | public void setAVTransportURI(String aVTransportURI) {
156 | AVTransportURI = aVTransportURI;
157 | valueIsChange.put(AV_TRANSPORT_URI, true);
158 | }
159 |
160 | public String getCurrentTrackMetaData() {
161 | return currentTrackMetaData;
162 | }
163 |
164 | public void setCurrentTrackMetaData(String currentTrackMetaData) {
165 | this.currentTrackMetaData = currentTrackMetaData;
166 | valueIsChange.put(CURRENT_TRACK_METADATA, true);
167 | }
168 |
169 | public String getCurrentTransportActions() {
170 | return currentTransportActions;
171 | }
172 |
173 | public void setCurrentTransportActions(String currentTransportActions) {
174 | this.currentTransportActions = currentTransportActions;
175 | valueIsChange.put(CURRENT_TRANSPORT_ACTIONS, true);
176 | }
177 |
178 | @Override
179 | public String toString() {
180 | return valueIsChange.toString();
181 | }
182 |
183 | }
184 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/entity/MediaInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.entity;
2 |
3 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
4 | import org.fourthline.cling.support.model.RecordMediumWriteStatus;
5 | import org.fourthline.cling.support.model.StorageMedium;
6 |
7 | import java.util.Map;
8 |
9 | /**
10 | * @author hubing
11 | * @version 1.0.0 2015-4-28
12 | */
13 |
14 | public class MediaInfo {
15 |
16 | private String currentURI = "";
17 | private String currentURIMetaData = "";
18 | private String nextURI = "NOT_IMPLEMENTED";
19 | private String nextURIMetaData = "NOT_IMPLEMENTED";
20 |
21 | private UnsignedIntegerFourBytes numberOfTracks = new UnsignedIntegerFourBytes(
22 | 0);
23 | private String mediaDuration = "00:00:00";
24 | private StorageMedium playMedium = StorageMedium.NONE;
25 | private StorageMedium recordMedium = StorageMedium.NOT_IMPLEMENTED;
26 | private RecordMediumWriteStatus writeStatus = RecordMediumWriteStatus.NOT_IMPLEMENTED;
27 |
28 | public MediaInfo() {
29 | }
30 |
31 | public MediaInfo(Map args) {
32 | this((String) args.get("CurrentURI"), (String) args
33 | .get("CurrentURIMetaData"), (String) args.get("NextURI"),
34 | (String) args.get("NextURIMetaData"),
35 |
36 | (UnsignedIntegerFourBytes) args.get("NrTracks"), (String) args
37 | .get("MediaDuration"), StorageMedium
38 | .valueOrVendorSpecificOf((String) args
39 | .get("PlayMedium")), StorageMedium
40 | .valueOrVendorSpecificOf((String) args
41 | .get("RecordMedium")), RecordMediumWriteStatus
42 | .valueOrUnknownOf((String) args.get("WriteStatus")));
43 | }
44 |
45 | public MediaInfo(String currentURI, String currentURIMetaData,
46 | String nextURI, String nextURIMetaData,
47 | UnsignedIntegerFourBytes numberOfTracks, String mediaDuration,
48 | StorageMedium playMedium, StorageMedium recordMedium,
49 | RecordMediumWriteStatus writeStatus) {
50 | this.currentURI = currentURI;
51 | this.currentURIMetaData = currentURIMetaData;
52 | this.nextURI = nextURI;
53 | this.nextURIMetaData = nextURIMetaData;
54 | this.numberOfTracks = numberOfTracks;
55 | this.mediaDuration = mediaDuration;
56 | this.playMedium = playMedium;
57 | this.recordMedium = recordMedium;
58 | this.writeStatus = writeStatus;
59 | }
60 |
61 | public String getCurrentURI() {
62 | return currentURI;
63 | }
64 |
65 | public String getCurrentURIMetaData() {
66 | return currentURIMetaData;
67 | }
68 |
69 | public String getNextURI() {
70 | return nextURI;
71 | }
72 |
73 | public String getNextURIMetaData() {
74 | return nextURIMetaData;
75 | }
76 |
77 | public UnsignedIntegerFourBytes getNumberOfTracks() {
78 | return numberOfTracks;
79 | }
80 |
81 | public String getMediaDuration() {
82 | return mediaDuration;
83 | }
84 |
85 | public StorageMedium getPlayMedium() {
86 | return playMedium;
87 | }
88 |
89 | public StorageMedium getRecordMedium() {
90 | return recordMedium;
91 | }
92 |
93 | public RecordMediumWriteStatus getWriteStatus() {
94 | return writeStatus;
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/entity/PositionInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.entity;
2 |
3 | import org.fourthline.cling.model.ModelUtil;
4 | import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * @author hubing
10 | * @version 1.0.0 2015-4-28
11 | */
12 |
13 | public class PositionInfo {
14 |
15 | private UnsignedIntegerFourBytes track = new UnsignedIntegerFourBytes(0);
16 | private String trackDuration = "00:00:00";
17 | private String trackMetaData = "NOT_IMPLEMENTED";
18 | private String trackURI = "";
19 | private String relTime = "00:00:00";
20 | private String absTime = "00:00:00"; // TODO: MORE VALUES IN DOMAIN!
21 | private int relCount = Integer.MAX_VALUE; // Indicates that we don't support this
22 | private int absCount = Integer.MAX_VALUE;
23 |
24 | public PositionInfo() {
25 | }
26 |
27 | public PositionInfo(Map args) {
28 | this.track = (UnsignedIntegerFourBytes) args.get("Track");
29 | this.trackDuration = (String) args.get("TrackDuration");
30 | this.trackMetaData = (String) args.get("TrackMetaData");
31 | this.trackURI = (String) args.get("TrackURI");
32 | this.relTime = (String) args.get("RelTime");
33 | this.absTime = (String) args.get("AbsTime");
34 | this.relCount = (Integer) args.get("RelCount");
35 | this.absCount = (Integer) args.get("AbsCount");
36 | }
37 |
38 | public PositionInfo(long track, String trackDuration, String trackMetaData,
39 | String trackURI, String relTime, String absTime, int relCount,
40 | int absCount) {
41 | this.track = new UnsignedIntegerFourBytes(track);
42 | this.trackDuration = trackDuration;
43 | this.trackMetaData = trackMetaData;
44 | this.trackURI = trackURI;
45 | this.relTime = relTime;
46 | this.absTime = absTime;
47 | this.relCount = relCount;
48 | this.absCount = absCount;
49 | }
50 |
51 | public UnsignedIntegerFourBytes getTrack() {
52 | return track;
53 | }
54 |
55 | public String getTrackDuration() {
56 | return trackDuration;
57 | }
58 |
59 | public String getTrackMetaData() {
60 | return trackMetaData;
61 | }
62 |
63 | public String getTrackURI() {
64 | return trackURI;
65 | }
66 |
67 | public String getRelTime() {
68 | return relTime;
69 | }
70 |
71 | public String getAbsTime() {
72 | return absTime;
73 | }
74 |
75 | public int getRelCount() {
76 | return relCount;
77 | }
78 |
79 | public int getAbsCount() {
80 | return absCount;
81 | }
82 |
83 | public void setTrackDuration(String trackDuration) {
84 | this.trackDuration = trackDuration;
85 | }
86 |
87 | public void setRelTime(String relTime) {
88 | this.relTime = relTime;
89 | }
90 |
91 | public long getTrackDurationSeconds() {
92 | return getTrackDuration() == null ? 0 : ModelUtil
93 | .fromTimeString(getTrackDuration());
94 | }
95 |
96 | public long getTrackElapsedSeconds() {
97 | return getRelTime() == null || getRelTime().equals("NOT_IMPLEMENTED") ? 0
98 | : ModelUtil.fromTimeString(getRelTime());
99 | }
100 |
101 | public long getTrackRemainingSeconds() {
102 | return getTrackDurationSeconds() - getTrackElapsedSeconds();
103 | }
104 |
105 | public int getElapsedPercent() {
106 | long elapsed = getTrackElapsedSeconds();
107 | long total = getTrackDurationSeconds();
108 | if (elapsed == 0 || total == 0)
109 | return 0;
110 | return new Double(elapsed / ((double) total / 100)).intValue();
111 | }
112 |
113 | @Override
114 | public String toString() {
115 | return "(PositionInfo) Track: " + getTrack() + " RelTime: "
116 | + getRelTime() + " Duration: " + getTrackDuration()
117 | + " Percent: " + getElapsedPercent();
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/entity/RenderingControlInfo.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.entity;
2 |
3 | import java.util.HashMap;
4 |
5 | /**
6 | * @author hubing
7 | * @version 1.0.0 2015-5-5
8 | */
9 |
10 | public class RenderingControlInfo {
11 |
12 | // 保存值的更改状态
13 | private HashMap valueIsChange = new HashMap();
14 |
15 | public static final String MUTE = "Mute";
16 | public static final String VOLUME = "Volume";
17 | public static final String PRESET_NAME_LIST = "PresetNameList";
18 |
19 | // 静音
20 | private boolean mute;
21 | // 音量大小
22 | private int volume;
23 | // 预设列表名
24 | private String presetNameList;
25 |
26 | public RenderingControlInfo() {
27 | valueIsChange.put(MUTE, false);
28 | valueIsChange.put(VOLUME, false);
29 | valueIsChange.put(PRESET_NAME_LIST, false);
30 | }
31 |
32 | public RenderingControlInfo(boolean mute, int volume, String presetNameList) {
33 | this.mute = mute;
34 | this.volume = volume;
35 | this.presetNameList = presetNameList;
36 | valueIsChange.put(MUTE, true);
37 | valueIsChange.put(VOLUME, true);
38 | valueIsChange.put(PRESET_NAME_LIST, true);
39 | }
40 |
41 | public HashMap getValueIsChange() {
42 | return valueIsChange;
43 | }
44 |
45 | public boolean isMute() {
46 | return mute;
47 | }
48 |
49 | public void setMute(boolean mute) {
50 | this.mute = mute;
51 | valueIsChange.put(MUTE, true);
52 | }
53 |
54 | public int getVolume() {
55 | return volume;
56 | }
57 |
58 | public void setVolume(int volume) {
59 | this.volume = volume;
60 | valueIsChange.put(VOLUME, true);
61 | }
62 |
63 | public String getPresetNameList() {
64 | return presetNameList;
65 | }
66 |
67 | public void setPresetNameList(String presetNameList) {
68 | this.presetNameList = presetNameList;
69 | valueIsChange.put(PRESET_NAME_LIST, true);
70 | }
71 |
72 | @Override
73 | public String toString() {
74 | return valueIsChange.toString() + mute + "," + volume + "," + presetNameList;
75 | }
76 |
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/event/AVTransportEvent.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.event;
2 |
3 | import com.dongao.dlna.moduls.avtransport.entity.AVTransportInfo;
4 | import com.dongao.dlna.upnp.UpnpSubscriptionCallback;
5 | import com.dongao.dlna.utils.ObjectParse;
6 |
7 | import org.fourthline.cling.model.meta.Service;
8 | import org.fourthline.cling.support.avtransport.lastchange.AVTransportLastChangeParser;
9 | import org.fourthline.cling.support.lastchange.EventedValue;
10 | import org.fourthline.cling.support.lastchange.LastChangeParser;
11 |
12 | import java.util.HashMap;
13 | import java.util.List;
14 | import java.util.Map;
15 |
16 | /**
17 | * @author hubing
18 | * @version 1.0.0 2015-5-6
19 | */
20 |
21 | public abstract class AVTransportEvent extends UpnpSubscriptionCallback {
22 |
23 | public AVTransportEvent(Service service) {
24 | super(service);
25 | }
26 |
27 | public AVTransportEvent(Service service, int requestedDurationSeconds) {
28 | super(service, requestedDurationSeconds);
29 | }
30 |
31 | @Override
32 | public LastChangeParser getLastChangeParser() {
33 | return new AVTransportLastChangeParser();
34 | }
35 |
36 | @Override
37 | public void onReceive(List values) {
38 | Map currStates = new HashMap();
39 | for (EventedValue ev : values) {
40 | currStates.put(ev.getName(), ev.getValue());
41 | }
42 | AVTransportInfo avtInfo = ObjectParse.parseMapToObject(currStates, AVTransportInfo.class);
43 | if (avtInfo == null) {
44 | avtInfo = new AVTransportInfo();
45 | }
46 | received(avtInfo);
47 | }
48 |
49 | public abstract void received(AVTransportInfo avTransportInfo);
50 |
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/avtransport/event/RenderingControlEvent.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.avtransport.event;
2 |
3 | import com.dongao.dlna.moduls.avtransport.entity.RenderingControlInfo;
4 | import com.dongao.dlna.upnp.UpnpSubscriptionCallback;
5 |
6 | import org.fourthline.cling.model.meta.Service;
7 | import org.fourthline.cling.support.lastchange.EventedValue;
8 | import org.fourthline.cling.support.lastchange.LastChangeParser;
9 | import org.fourthline.cling.support.model.Channel;
10 | import org.fourthline.cling.support.renderingcontrol.lastchange.ChannelMute;
11 | import org.fourthline.cling.support.renderingcontrol.lastchange.ChannelVolume;
12 | import org.fourthline.cling.support.renderingcontrol.lastchange.RenderingControlLastChangeParser;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * @author hubing
18 | * @version 1.0.0 2015-5-5
19 | */
20 |
21 | public abstract class RenderingControlEvent extends UpnpSubscriptionCallback {
22 |
23 | public RenderingControlEvent(Service service) {
24 | super(service);
25 | }
26 |
27 | public RenderingControlEvent(Service service, int requestedDurationSeconds) {
28 | super(service, requestedDurationSeconds);
29 | }
30 |
31 | @Override
32 | public void onReceive(List values) {
33 | RenderingControlInfo controlInfo = new RenderingControlInfo();
34 | for (EventedValue entry : values) {
35 | if (RenderingControlInfo.MUTE.equals(entry.getName())) {
36 | Object v = entry.getValue();
37 | if (v instanceof ChannelMute) {
38 | ChannelMute cm = (ChannelMute) v;
39 | if (Channel.Master.equals(cm.getChannel())) {
40 | controlInfo.setMute(cm.getMute());
41 | }
42 | }
43 | }
44 | if (RenderingControlInfo.VOLUME.equals(entry.getName())) {
45 | Object v = entry.getValue();
46 | if (v instanceof ChannelVolume) {
47 | ChannelVolume cv = (ChannelVolume) v;
48 | if (Channel.Master.equals(cv.getChannel())) {
49 | controlInfo.setVolume(cv.getVolume());
50 | }
51 | }
52 | }
53 | if (RenderingControlInfo.PRESET_NAME_LIST.equals(entry.getName())) {
54 | Object v = entry.getValue();
55 | controlInfo.setPresetNameList(v.toString());
56 | }
57 | }
58 | received(controlInfo);
59 | }
60 |
61 | @Override
62 | public LastChangeParser getLastChangeParser() {
63 | return new RenderingControlLastChangeParser();
64 | }
65 |
66 | public abstract void received(RenderingControlInfo controlInfo);
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/searchdevice/entity/DeviceDisplay.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.searchdevice.entity;
2 |
3 | import org.fourthline.cling.model.meta.Device;
4 | import org.fourthline.cling.model.meta.Service;
5 |
6 | /**
7 | * @author hubing
8 | * @version 1.0.0 2015-4-15
9 | */
10 |
11 | public class DeviceDisplay {
12 |
13 | private Device device;
14 |
15 | public DeviceDisplay(Device device) {
16 | this.device = device;
17 | }
18 |
19 | public Device getDevice() {
20 | return this.device;
21 | }
22 |
23 | @Override
24 | public boolean equals(Object o) {
25 | if (this == o) {
26 | return true;
27 | }
28 | if (o == null || getClass() != o.getClass()) {
29 | return false;
30 | }
31 | DeviceDisplay that = (DeviceDisplay) o;
32 | return device.equals(that.device);
33 | }
34 |
35 | @Override
36 | public int hashCode() {
37 | return device.hashCode();
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | String name = device.getDetails() != null && device.getDetails().getFriendlyName() != null
43 | ? device.getDetails().getFriendlyName() : device.getDisplayString();
44 | return device.isFullyHydrated() ? name : name + " *";
45 | }
46 |
47 | public String getDetailsMsg() {
48 | StringBuilder sb = new StringBuilder();
49 | if (device.isFullyHydrated()) {
50 | sb.append(device.getDisplayString());
51 | sb.append("\n\n");
52 | for (Service srv : device.getServices()) {
53 | sb.append(srv.getServiceType()).append("\n");
54 | }
55 | } else {
56 | sb.append("正在查找设备详情,请稍后.");
57 | }
58 | return sb.toString();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/moduls/searchdevice/listener/DeviceRegistryListener.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.moduls.searchdevice.listener;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import com.dongao.dlna.moduls.searchdevice.entity.DeviceDisplay;
7 | import com.dongao.dlna.upnp.UpnpRegistryListener;
8 | import com.dongao.dlna.upnp.constants.HandlerWhat;
9 |
10 | import org.fourthline.cling.model.meta.Device;
11 | import org.fourthline.cling.registry.Registry;
12 |
13 | /**
14 | * @author hubing
15 | * @version 1.0.0 2015-4-16
16 | */
17 |
18 | public class DeviceRegistryListener extends UpnpRegistryListener {
19 |
20 | private Handler handler;
21 |
22 | public DeviceRegistryListener(Handler handler) {
23 | this.handler = handler;
24 | }
25 |
26 | /**
27 | * 添加设备
28 | * @param device
29 | */
30 | @Override
31 | public void deviceAdded(Device device) {
32 | if (handler == null) {
33 | return;
34 | }
35 | DeviceDisplay d = new DeviceDisplay(device);
36 | Message msg = Message.obtain(handler);
37 | msg.what = HandlerWhat.ADD;
38 | msg.obj = d;
39 | msg.sendToTarget();
40 | }
41 |
42 | /**
43 | * 删除设备
44 | * @param device
45 | */
46 | @Override
47 | public void deviceRemoved(Device device) {
48 | if (handler == null) {
49 | return;
50 | }
51 | Message msg = Message.obtain(handler);
52 | msg.what = HandlerWhat.REMOVE;
53 | msg.obj = new DeviceDisplay(device);
54 | msg.sendToTarget();
55 | }
56 |
57 | @Override
58 | public void beforeShutdown(Registry registry) {
59 | }
60 |
61 | @Override
62 | public void afterShutdown() {
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/UpnpActionCallback.java:
--------------------------------------------------------------------------------
1 |
2 | package com.dongao.dlna.upnp;
3 |
4 | import org.fourthline.cling.controlpoint.ActionCallback;
5 | import org.fourthline.cling.model.action.ActionArgumentValue;
6 | import org.fourthline.cling.model.action.ActionInvocation;
7 | import org.fourthline.cling.model.types.InvalidValueException;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | /**
13 | * 控制设备的动作
14 | *
15 | * @author hubing
16 | * @version 1.0.0 2015-4-28
17 | */
18 |
19 | public abstract class UpnpActionCallback extends ActionCallback {
20 |
21 | public UpnpActionCallback(ActionInvocation actionInvocation) {
22 | super(actionInvocation);
23 | }
24 |
25 | public void setInput(String argumentName, Object value) throws InvalidValueException {
26 | getActionInvocation().setInput(argumentName, value);
27 | }
28 |
29 | public void setInput(ActionArgumentValue value) {
30 | getActionInvocation().setInput(value);
31 | }
32 |
33 | public void setInput(ActionArgumentValue[] input) {
34 | getActionInvocation().setInput(input);
35 | }
36 |
37 | @Override
38 | public void success(ActionInvocation invocation) {
39 | ActionArgumentValue[] aavs = invocation.getOutput();
40 | Map result = new HashMap();
41 | for (ActionArgumentValue aav : aavs) {
42 | result.put(aav.getArgument().getName(), aav.getValue());
43 | }
44 | received(invocation, result);
45 | }
46 |
47 | public abstract void received(ActionInvocation invocation, Map result);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/UpnpRegistryListener.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.upnp;
2 |
3 | import android.util.Log;
4 |
5 | import org.fourthline.cling.model.meta.Device;
6 | import org.fourthline.cling.model.meta.LocalDevice;
7 | import org.fourthline.cling.model.meta.RemoteDevice;
8 | import org.fourthline.cling.registry.DefaultRegistryListener;
9 | import org.fourthline.cling.registry.Registry;
10 |
11 | /**
12 | * @author hubing
13 | * @version 1.0.0 2015-4-29
14 | */
15 |
16 | public abstract class UpnpRegistryListener extends DefaultRegistryListener {
17 |
18 | @Override
19 | public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device) {
20 | deviceAdded(device);
21 | }
22 |
23 | @Override
24 | public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice device, Exception ex) {
25 | Log.d("", "Discovery failed of '"
26 | + device.getDisplayString()
27 | + "': "
28 | + (ex != null ? ex.toString()
29 | : "Couldn't retrieve device/service descriptors"));
30 | deviceRemoved(device);
31 | }
32 |
33 | @Override
34 | public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
35 | deviceAdded(device);
36 | }
37 |
38 | @Override
39 | public void remoteDeviceUpdated(Registry registry, RemoteDevice device) {
40 | deviceAdded(device);
41 | }
42 |
43 | @Override
44 | public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
45 | deviceRemoved(device);
46 | }
47 |
48 | @Override
49 | public void localDeviceAdded(Registry registry, LocalDevice device) {
50 | deviceAdded(device);
51 | }
52 |
53 | @Override
54 | public void localDeviceRemoved(Registry registry, LocalDevice device) {
55 | deviceRemoved(device);
56 | }
57 |
58 | /**
59 | * 添加设备
60 | *
61 | * @param device
62 | */
63 | public abstract void deviceAdded(Device device);
64 |
65 | /**
66 | * 删除设备
67 | *
68 | * @param device
69 | */
70 | public abstract void deviceRemoved(Device device);
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/UpnpServiceBiz.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.upnp;
2 |
3 | import android.app.Application;
4 | import android.app.Service;
5 | import android.content.ComponentName;
6 | import android.content.Intent;
7 | import android.content.ServiceConnection;
8 | import android.os.IBinder;
9 |
10 | import com.dongao.dlna.DLNALibrary;
11 | import com.dongao.dlna.upnp.service.UpnpDeviceService;
12 |
13 | import org.fourthline.cling.android.AndroidUpnpService;
14 | import org.fourthline.cling.controlpoint.SubscriptionCallback;
15 | import org.fourthline.cling.model.DiscoveryOptions;
16 | import org.fourthline.cling.model.message.header.UpnpHeader;
17 | import org.fourthline.cling.model.meta.Device;
18 | import org.fourthline.cling.model.meta.LocalDevice;
19 | import org.fourthline.cling.model.types.DeviceType;
20 | import org.fourthline.cling.model.types.ServiceType;
21 | import org.fourthline.cling.model.types.UDN;
22 | import org.fourthline.cling.transport.Router;
23 |
24 | import java.util.Collection;
25 | import java.util.Map.Entry;
26 | import java.util.concurrent.ConcurrentHashMap;
27 | import java.util.concurrent.Future;
28 |
29 | /**
30 | * @author hubing
31 | * @version 1.0.0 2015-4-27
32 | */
33 |
34 | public class UpnpServiceBiz {
35 |
36 | protected static String TAG = UpnpServiceBiz.class.getSimpleName();
37 |
38 | protected AndroidUpnpService upnpService;
39 | private static UpnpServiceBiz localUpnpService;
40 |
41 | private UpnpRegistryListener listener;
42 |
43 | private ConcurrentHashMap localDevices;
44 |
45 | private UpnpServiceBiz(Application mApp) {
46 | Intent service = new Intent(mApp, UpnpDeviceService.class);
47 | mApp.bindService(service, conn, Service.BIND_AUTO_CREATE);
48 | localDevices = new ConcurrentHashMap();
49 | }
50 |
51 | public static UpnpServiceBiz newInstance() {
52 | if (localUpnpService == null) {
53 | localUpnpService = new UpnpServiceBiz(DLNALibrary.getInstance().getApplicationContext());
54 | }
55 | return localUpnpService;
56 | }
57 |
58 | /**
59 | * 关闭upnp服务
60 | *
61 | * @param mApp
62 | */
63 | public void closeUpnpService(Application mApp) {
64 | if (upnpService != null) {
65 | upnpService.getRegistry().removeAllLocalDevices();
66 | mApp.unbindService(conn);
67 | }
68 | }
69 |
70 | public void addListener(UpnpRegistryListener listener) {
71 | if (upnpService != null) {
72 | upnpService.getRegistry().addListener(listener);
73 | } else {
74 | this.listener = listener;
75 | }
76 | }
77 |
78 | public void removeListener(UpnpRegistryListener listener) {
79 | upnpService.getRegistry().removeListener(listener);
80 | }
81 |
82 | public void removeAllRemoteDevices() {
83 | upnpService.getRegistry().removeAllRemoteDevices();
84 | }
85 |
86 | /**
87 | * 添加本地设备
88 | *
89 | * @param localDevice
90 | */
91 | public void addDevice(LocalDevice localDevice) {
92 | if (upnpService != null && localDevice.getIdentity() != null) {
93 | upnpService.getRegistry().addDevice(localDevice);
94 | }
95 | addDevice(localDevice.getIdentity().getUdn(), localDevice);
96 | }
97 |
98 | /**
99 | * 添加本地设备
100 | *
101 | * @param localDevice
102 | * @param options
103 | */
104 | public void addDevice(LocalDevice localDevice, DiscoveryOptions options) {
105 | if (upnpService != null && localDevice.getIdentity() != null) {
106 | upnpService.getRegistry().addDevice(localDevice, options);
107 | }
108 | addDevice(localDevice.getIdentity().getUdn(), localDevice);
109 | }
110 |
111 | /**
112 | * 添加本地设备到设备列表
113 | *
114 | * @param device
115 | */
116 | private void addDevice(UDN udn, LocalDevice device) {
117 | localDevices.put(udn, device);
118 | }
119 |
120 | public boolean removeDevice(LocalDevice localDevice) {
121 | return upnpService.getRegistry().removeDevice(localDevice);
122 | }
123 |
124 | public Collection getDevices() {
125 | return upnpService.getRegistry().getDevices();
126 | }
127 |
128 | public Collection getDevices(DeviceType deviceType) {
129 | return upnpService.getRegistry().getDevices(deviceType);
130 | }
131 |
132 | public Collection getDevices(ServiceType serviceType) {
133 | return upnpService.getRegistry().getDevices(serviceType);
134 | }
135 |
136 | public Router getRouter() {
137 | return upnpService.get().getRouter();
138 | }
139 |
140 | public void search() {
141 | for (Entry entry : localDevices.entrySet()) {
142 | addDevice(entry.getValue());
143 | }
144 | // 添加已知设备
145 | for (Device device : upnpService.getRegistry().getDevices()) {
146 | listener.deviceAdded(device);
147 | }
148 | upnpService.getControlPoint().search();
149 | }
150 |
151 | public void search(UpnpHeader searchType) {
152 | upnpService.getControlPoint().search(searchType);
153 | }
154 |
155 | public void search(int mxSeconds) {
156 | upnpService.getControlPoint().search(mxSeconds);
157 | }
158 |
159 | public void search(UpnpHeader searchType, int mxSeconds) {
160 | upnpService.getControlPoint().search(searchType, mxSeconds);
161 | }
162 |
163 | public Future execute(UpnpActionCallback callback) {
164 | return upnpService.getControlPoint().execute(callback);
165 | }
166 |
167 | public void execute(SubscriptionCallback callback) {
168 | upnpService.getControlPoint().execute(callback);
169 | }
170 |
171 | private ServiceConnection conn = new ServiceConnection() {
172 |
173 | @Override
174 | public void onServiceDisconnected(ComponentName name) {
175 | upnpService = null;
176 | }
177 |
178 | @Override
179 | public void onServiceConnected(ComponentName name, IBinder service) {
180 | upnpService = (AndroidUpnpService) service;
181 | if (listener != null) {
182 | upnpService.getRegistry().addListener(listener);
183 |
184 | // 搜索设备
185 | search();
186 | }
187 | }
188 | };
189 |
190 | }
191 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/UpnpSubscriptionCallback.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.upnp;
2 |
3 | import android.util.Log;
4 |
5 | import org.fourthline.cling.controlpoint.SubscriptionCallback;
6 | import org.fourthline.cling.model.gena.GENASubscription;
7 | import org.fourthline.cling.model.meta.Service;
8 | import org.fourthline.cling.model.state.StateVariableValue;
9 | import org.fourthline.cling.support.lastchange.Event;
10 | import org.fourthline.cling.support.lastchange.EventedValue;
11 | import org.fourthline.cling.support.lastchange.InstanceID;
12 | import org.fourthline.cling.support.lastchange.LastChangeParser;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * @author hubing
19 | * @version 1.0.0 2015-5-4
20 | */
21 |
22 | public abstract class UpnpSubscriptionCallback extends SubscriptionCallback {
23 |
24 | private static String TAG = UpnpSubscriptionCallback.class.getSimpleName();
25 |
26 | public UpnpSubscriptionCallback(Service service) {
27 | super(service);
28 | }
29 |
30 | public UpnpSubscriptionCallback(Service service, int requestedDurationSeconds) {
31 | super(service, requestedDurationSeconds);
32 | }
33 |
34 | @SuppressWarnings("rawtypes")
35 | @Override
36 | protected void eventReceived(GENASubscription subscription) {
37 | StateVariableValue svv = (StateVariableValue) subscription.getCurrentValues().get("LastChange");
38 | Log.d(TAG, "eventReceived:" + svv.getValue().toString());
39 | LastChangeParser parser = getLastChangeParser();
40 | try {
41 | Event event = parser.parse(svv.getValue().toString());
42 | List iIDs = event.getInstanceIDs();
43 | List values = new ArrayList();
44 | for (InstanceID iID : iIDs) {
45 | values.addAll(iID.getValues());
46 | }
47 | onReceive(values);
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | }
51 | }
52 |
53 | public abstract LastChangeParser getLastChangeParser();
54 |
55 | public abstract void onReceive(List values);
56 |
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/constants/HandlerWhat.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.upnp.constants;
2 |
3 | /**
4 | * @author hubing
5 | * @version 1.0.0 2015-4-16
6 | */
7 |
8 | public class HandlerWhat {
9 | public static final int ADD = 0;
10 | public static final int REMOVE = 1;
11 | public static final int INSERT = 2;
12 | public static final int CLEAR_ALL = 3;
13 | }
14 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/upnp/service/UpnpDeviceService.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.upnp.service;
2 |
3 | import org.fourthline.cling.UpnpServiceConfiguration;
4 | import org.fourthline.cling.android.AndroidUpnpServiceConfiguration;
5 | import org.fourthline.cling.android.AndroidUpnpServiceImpl;
6 |
7 | /**
8 | * @author hubing
9 | * @version 1.0.0 2015-4-15
10 | */
11 |
12 | public class UpnpDeviceService extends AndroidUpnpServiceImpl {
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | }
18 |
19 | @Override
20 | protected UpnpServiceConfiguration createConfiguration() {
21 | return new AndroidUpnpServiceConfiguration() {
22 | @Override
23 | public int getRegistryMaintenanceIntervalMillis() {
24 | // 维护时间
25 | return 7000;
26 | }
27 |
28 | // @Override
29 | // public ServiceType[] getExclusiveServiceTypes() {
30 | // // 过滤要搜索的服务类型
31 | // return new ServiceType[] { new UDAServiceType("RenderingControl", 1) };
32 | // }
33 | };
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/utils/ObjectParse.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.utils;
2 |
3 | import org.fourthline.cling.model.types.BooleanDatatype;
4 |
5 | import java.lang.reflect.Constructor;
6 | import java.lang.reflect.Field;
7 | import java.lang.reflect.InvocationTargetException;
8 | import java.lang.reflect.Method;
9 | import java.util.Locale;
10 | import java.util.Map;
11 | import java.util.Map.Entry;
12 | import java.util.Set;
13 |
14 | /**
15 | * @author hubing
16 | * @version 1.0.0 2015-5-7
17 | */
18 |
19 | public class ObjectParse {
20 |
21 | protected class FieldType {
22 |
23 | public static final String BYTE = "byte";
24 | public static final String SHORT = "short";
25 | public static final String INT = "int";
26 | public static final String LONG = "long";
27 | public static final String FLOAT = "float";
28 | public static final String DOUBLE = "double";
29 | public static final String BOOLEAN = "boolean";
30 | public static final String CHAR = "char";
31 |
32 | }
33 |
34 | protected static final String SET = "set";
35 |
36 | private static String TAG = ObjectParse.class.getSimpleName();
37 |
38 |
39 | /**
40 | * 将map解析成object
41 | * @param data
42 | * @param clazz
43 | * @return
44 | */
45 | public static T parseMapToObject(Map data, Class clazz) {
46 | T t = null;
47 | try {
48 | Constructor constructor = clazz.getDeclaredConstructor();
49 | t = constructor.newInstance();
50 | if (data == null || data.isEmpty()) {
51 | return t;
52 | }
53 | Set> set = data.entrySet();
54 | for (Entry entry : set) {
55 | String attrName = entry.getKey();
56 | try {
57 | Field field = clazz.getDeclaredField(firstToLowerCase(attrName));
58 | Class> fieldType = field.getType();
59 | Method method = clazz.getDeclaredMethod(SET + attrName, fieldType);
60 | method.invoke(t, parseToRealValue(fieldType, entry.getValue()));
61 | } catch (NoSuchFieldException e) {
62 | break;
63 | }
64 | }
65 | } catch (Exception e) {
66 | e.printStackTrace();
67 | }
68 | return t;
69 | }
70 |
71 | /**
72 | * 将字符串首字母改成小写
73 | *
74 | * @param str
75 | * @return
76 | */
77 | public static String firstToLowerCase(String str) {
78 | if (str == null || str.length() == 0) {
79 | return str;
80 | }
81 | if (str.length() == 1) {
82 | return str.toLowerCase(Locale.CHINA);
83 | }
84 | StringBuilder sb = new StringBuilder();
85 | String mStr = str.substring(0, 1).toLowerCase(Locale.CHINA);
86 | sb.append(mStr);
87 | sb.append(str.substring(1, str.length()));
88 | return sb.toString();
89 | }
90 |
91 | private static Object parseToRealValue(Class> classType, Object value)
92 | throws InstantiationException, IllegalAccessException,
93 | IllegalArgumentException, InvocationTargetException,
94 | NoSuchMethodException {
95 | String type = classType.toString();
96 | if (FieldType.BYTE.equals(type)) {
97 | return Byte.parseByte(value.toString());
98 | } else if (FieldType.SHORT.equals(type)) {
99 | return Short.parseShort(value.toString());
100 | } else if (FieldType.INT.equals(type)) {
101 | return Integer.parseInt(value.toString());
102 | } else if (FieldType.LONG.equals(type)) {
103 | return Long.parseLong(value.toString());
104 | } else if (FieldType.FLOAT.equals(type)) {
105 | return Float.parseFloat(value.toString());
106 | } else if (FieldType.DOUBLE.equals(type)) {
107 | return Double.parseDouble(value.toString());
108 | } else if (FieldType.BOOLEAN.equals(type)) {
109 | return new BooleanDatatype().valueOf(value.toString());
110 | } else if (FieldType.CHAR.equals(type)) {
111 | return (Character) value;
112 | } else {
113 | Constructor> constructor = classType.getDeclaredConstructor(String.class);
114 | return constructor.newInstance(value.toString());
115 | }
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/java/com/dongao/dlna/view/SelectDeviceDialog.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna.view;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.os.Handler;
9 | import android.os.Message;
10 | import android.support.annotation.NonNull;
11 | import android.support.v4.app.DialogFragment;
12 | import android.support.v4.app.FragmentActivity;
13 | import android.view.Gravity;
14 | import android.view.View;
15 | import android.view.Window;
16 | import android.view.WindowManager;
17 | import android.widget.AdapterView;
18 | import android.widget.ImageView;
19 | import android.widget.ListView;
20 | import android.widget.ProgressBar;
21 | import android.widget.TextView;
22 | import android.widget.Toast;
23 |
24 | import com.dongao.dlna.DLNALibrary;
25 | import com.dongao.dlna.R;
26 | import com.dongao.dlna.adapter.GeneralAdapter;
27 | import com.dongao.dlna.moduls.searchdevice.entity.DeviceDisplay;
28 | import com.dongao.dlna.moduls.searchdevice.listener.DeviceRegistryListener;
29 | import com.dongao.dlna.upnp.UpnpServiceBiz;
30 | import com.dongao.dlna.upnp.constants.HandlerWhat;
31 |
32 | /**
33 | * @author jjr
34 | * @date 2018/7/1
35 | */
36 | public class SelectDeviceDialog extends DialogFragment implements View.OnClickListener, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
37 |
38 | private TextView find_tv;
39 | private ProgressBar find_pb;
40 | private TextView help_tv;
41 | private ImageView close_iv;
42 | private ListView list_lv;
43 | private TextView wifi_tv;
44 | private GeneralAdapter adapter;
45 | private Handler handler = new Handler() {
46 | @Override
47 | public void handleMessage(Message msg) {
48 | DeviceDisplay dd = (DeviceDisplay) msg.obj;
49 | switch (msg.what) {
50 | case HandlerWhat.ADD:
51 | int p = adapter.getPosition(dd);
52 | if (adapter.getPosition(dd) >= 0) {
53 | // Device already in the list, re-set new value at same position
54 | adapter.remove(dd);
55 | adapter.insert(dd, p);
56 | } else {
57 | adapter.add(dd);
58 | }
59 | break;
60 | case HandlerWhat.REMOVE:
61 | adapter.remove(dd);
62 | break;
63 | }
64 | }
65 | };
66 | private UpnpServiceBiz mUpnpServiceBiz;
67 | private DeviceRegistryListener mListener;
68 |
69 | @NonNull
70 | @Override
71 | public Dialog onCreateDialog(Bundle savedInstanceState) {
72 | //使用不带Theme的构造器, 获得的dialog边框距离屏幕仍有几毫米的缝隙。
73 | Dialog dialog = new Dialog(getActivity(), R.style.BottomDialog);
74 |
75 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
76 | dialog.setContentView(R.layout.dlna_select_device_dialog);
77 | dialog.setCanceledOnTouchOutside(true);
78 |
79 | //设置宽度为屏宽, 靠近屏幕底部。
80 | Window window = dialog.getWindow();
81 | WindowManager.LayoutParams lp = window.getAttributes();
82 | lp.gravity = Gravity.BOTTOM;
83 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
84 | window.setAttributes(lp);
85 |
86 | init(dialog);
87 |
88 | return dialog;
89 | }
90 |
91 | private void init(Dialog dialog) {
92 | find_tv = (TextView) dialog.findViewById(R.id.dlna_select_device_find_tv);
93 | find_pb = (ProgressBar) dialog.findViewById(R.id.dlna_select_device_find_pb);
94 | help_tv = (TextView) dialog.findViewById(R.id.dlna_select_device_help_tv);
95 | close_iv = (ImageView) dialog.findViewById(R.id.dlna_select_device_close_iv);
96 | list_lv = (ListView) dialog.findViewById(R.id.dlna_select_device_list_lv);
97 | wifi_tv = (TextView) dialog.findViewById(R.id.dlna_select_device_wifi_tv);
98 | help_tv.setOnClickListener(this);
99 | close_iv.setOnClickListener(this);
100 | adapter = new GeneralAdapter(getActivity(), android.R.layout.simple_list_item_1, null) {
101 |
102 | @Override
103 | public void convert(GeneralAdapter.ViewHolder holder, DeviceDisplay item, int position) {
104 | String text = item.toString();
105 | holder.setText(android.R.id.text1, text);
106 | }
107 | };
108 | list_lv.setAdapter(adapter);
109 | list_lv.setOnItemClickListener(this);
110 | list_lv.setOnItemLongClickListener(this);
111 |
112 | mUpnpServiceBiz = UpnpServiceBiz.newInstance();
113 | mListener = new DeviceRegistryListener(handler);
114 | mUpnpServiceBiz.addListener(mListener);
115 | }
116 |
117 | @Override
118 | public void onClick(View v) {
119 | int i = v.getId();
120 | if (i == R.id.dlna_select_device_help_tv) {
121 | Toast.makeText(getActivity(), "打开帮助页面", Toast.LENGTH_LONG).show();
122 | } else if (i == R.id.dlna_select_device_close_iv){
123 | dismiss();
124 | }
125 | }
126 |
127 | @Override
128 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
129 | DeviceDisplay dd = adapter.getItem(position);
130 | DLNALibrary.getInstance().setDeviceDisplay(dd);
131 | dismiss();
132 | }
133 |
134 | @Override
135 | public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
136 | DeviceDisplay deviceDisplay = adapter.getItem(position);
137 | return showDeviceDetails(deviceDisplay);
138 | }
139 |
140 | /**
141 | * 显示设备详细信息
142 | *
143 | * @param deviceDisplay
144 | * @return
145 | * @author hubing
146 | */
147 | protected boolean showDeviceDetails(DeviceDisplay deviceDisplay) {
148 | AlertDialog dialog = new AlertDialog.Builder(getActivity()).create();
149 | dialog.setTitle("设备详情");
150 | dialog.setMessage(deviceDisplay.getDetailsMsg());
151 | dialog.setButton(AlertDialog.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() {
152 | @Override
153 | public void onClick(DialogInterface dialog, int which) {
154 | }
155 | });
156 | dialog.show();
157 | TextView textView = (TextView) dialog.findViewById(android.R.id.message);
158 | textView.setTextSize(12);
159 | return dialog.isShowing();
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/res/layout/dlna_select_device_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
20 |
21 |
26 |
27 |
31 |
32 |
44 |
45 |
50 |
51 |
52 |
53 |
58 |
59 |
60 |
67 |
68 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/res/mipmap-xxhdpi/btn_nav_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jijiangrui/AndroidDLNA/2809ede17eede9376399d38a42897b9240ac9866/lib-dlna/src/main/res/mipmap-xxhdpi/btn_nav_close.png
--------------------------------------------------------------------------------
/lib-dlna/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidDLNA
3 |
4 |
--------------------------------------------------------------------------------
/lib-dlna/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/lib-dlna/src/test/java/com/dongao/dlna/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.dongao.dlna;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lib-dlna'
2 |
--------------------------------------------------------------------------------