├── list
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── btn_title_back.png
│ │ │ │ ├── btn_title_black_back.png
│ │ │ │ └── btn_title_back_pressed.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── btn_title_back_bg.xml
│ │ │ │ ├── btn_shape.xml
│ │ │ │ ├── text_selector.xml
│ │ │ │ └── selector_text.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── table_media_info.xml
│ │ │ │ ├── table_media_info_section.xml
│ │ │ │ ├── table_media_info_row1.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── table_media_info_row2.xml
│ │ │ │ ├── content_main.xml
│ │ │ │ └── playactivity_main.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── strings_pref.xml
│ │ │ └── color
│ │ │ │ └── selector.xml
│ │ ├── java
│ │ │ └── voole
│ │ │ │ └── example
│ │ │ │ └── com
│ │ │ │ └── myapplication
│ │ │ │ ├── data
│ │ │ │ └── liveData.java
│ │ │ │ ├── media
│ │ │ │ ├── IMediaController.java
│ │ │ │ ├── IRenderView.java
│ │ │ │ ├── MediaPlayerCompat.java
│ │ │ │ ├── Settings.java
│ │ │ │ ├── TableLayoutBinder.java
│ │ │ │ ├── AndroidMediaController.java
│ │ │ │ ├── InfoHudViewHolder.java
│ │ │ │ ├── SurfaceRenderView.java
│ │ │ │ ├── MeasureHelper.java
│ │ │ │ ├── TextureRenderView.java
│ │ │ │ └── IjkVideoView.java
│ │ │ │ ├── services
│ │ │ │ └── MediaPlayerService.java
│ │ │ │ ├── adapter
│ │ │ │ └── newAdapter.java
│ │ │ │ ├── network
│ │ │ │ └── HttpHelp.java
│ │ │ │ └── activity
│ │ │ │ ├── PlayerActivity.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── voole
│ │ │ └── example
│ │ │ └── com
│ │ │ └── myapplication
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── voole
│ │ └── example
│ │ └── com
│ │ └── myapplication
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
└── README.md
/list/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Player
2 | 直播项目的demo,仅供参考,不得用于商业用途
3 | 本demo是基于ijkplayer播放框架下实现的。
4 |
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-hdpi/btn_title_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-hdpi/btn_title_back.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-hdpi/btn_title_black_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-hdpi/btn_title_black_back.png
--------------------------------------------------------------------------------
/list/src/main/res/mipmap-hdpi/btn_title_back_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangzexin/Player_Demo/HEAD/list/src/main/res/mipmap-hdpi/btn_title_back_pressed.png
--------------------------------------------------------------------------------
/list/src/main/res/drawable/btn_title_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/list/src/main/res/drawable/btn_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/list/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/list/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/list/src/test/java/voole/example/com/myapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/list/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/list/src/androidTest/java/voole/example/com/myapplication/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/list/src/main/res/layout/table_media_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/list/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #009688
7 | #00796b
8 | #eeff41
9 | #F4FF81
10 |
11 |
12 |
13 | #77000000
14 |
15 |
--------------------------------------------------------------------------------
/list/src/main/res/color/selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/list/src/main/res/layout/table_media_info_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/list/src/main/res/drawable/text_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/list/src/main/res/drawable/selector_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/list/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangzexin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/list/src/main/res/layout/table_media_info_row1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/list/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/list/src/main/res/layout/table_media_info_row2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/data/liveData.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.data;
2 |
3 | /**
4 | * Created by zhangzexin on 16/2/18.
5 | */
6 | public class liveData {
7 | String id;//房间ID
8 | String name;//房间名
9 | String flv;//flv
10 | String imgerURl;//图片地址
11 |
12 | public String getId() {
13 | return id;
14 | }
15 |
16 | public String getName() {
17 | return name;
18 | }
19 |
20 | public String getFlv() {
21 | return flv;
22 | }
23 |
24 | public String getImgerURl() {
25 | return imgerURl;
26 | }
27 |
28 | public void setId(String id) {
29 | this.id = id;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public void setFlv(String flv) {
37 | this.flv = flv;
38 | }
39 |
40 | public void setImgerURl(String imgerURl) {
41 | this.imgerURl = imgerURl;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/list/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 |
6 | 16dp
7 | 16dp
8 |
9 | 16dp
10 | 8dp
11 | 4dp
12 |
13 | 4dp
14 |
15 | 72dp
16 | 72dp
17 | 240dp
18 | 120dp
19 |
20 | 180dp
21 | 48dp
22 |
23 | 72dp
24 | 16dp
25 |
26 | 32dp
27 | 4dp
28 |
29 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/IMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import android.view.View;
20 | import android.widget.MediaController;
21 |
22 | public interface IMediaController {
23 | void hide();
24 |
25 | boolean isShowing();
26 |
27 | void setAnchorView(View view);
28 |
29 | void setEnabled(boolean enabled);
30 |
31 | void setMediaPlayer(MediaController.MediaPlayerControl player);
32 |
33 | void show(int timeout);
34 |
35 | void show();
36 |
37 | //----------
38 | // Extends
39 | //----------
40 | void showOnce(View view);
41 | }
42 |
--------------------------------------------------------------------------------
/list/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
19 |
20 |
30 |
31 |
--------------------------------------------------------------------------------
/list/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '23.0.2'
6 |
7 | defaultConfig {
8 | applicationId "voole.example.com.myapplication"
9 | minSdkVersion 9
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 | compile 'com.android.support:design:23.1.1'
27 | compile 'com.facebook.fresco:fresco:0.9.0'
28 | //required, enough for most devices.
29 | compile 'tv.danmaku.ijk.media:ijkplayer-java:0.4.5.1'
30 | compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.4.5.1'
31 | // Other ABIs: optional
32 | compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.4.5.1'
33 | compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.4.5.1'
34 | compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.4.4.1'
35 | compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
36 | compile 'com.melnykov:floatingactionbutton:1.3.0'
37 | compile 'com.nineoldandroids:library:2.4.0'
38 | }
39 | allprojects {
40 | gradle.projectsEvaluated {
41 | tasks.withType(JavaCompile) {
42 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/list/src/main/res/layout/playactivity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
36 |
37 |
--------------------------------------------------------------------------------
/list/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/services/MediaPlayerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.services;
18 |
19 | import android.app.Service;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.IBinder;
23 | import android.support.annotation.Nullable;
24 |
25 | import tv.danmaku.ijk.media.player.IMediaPlayer;
26 |
27 | public class MediaPlayerService extends Service {
28 | private static IMediaPlayer sMediaPlayer;
29 |
30 | public static Intent newIntent(Context context) {
31 | Intent intent = new Intent(context, MediaPlayerService.class);
32 | return intent;
33 | }
34 |
35 | public static void intentToStart(Context context) {
36 | context.startService(newIntent(context));
37 | }
38 |
39 | public static void intentToStop(Context context) {
40 | context.stopService(newIntent(context));
41 | }
42 |
43 | @Nullable
44 | @Override
45 | public IBinder onBind(Intent intent) {
46 | return null;
47 | }
48 |
49 | public static void setMediaPlayer(IMediaPlayer mp) {
50 | if (sMediaPlayer != null && sMediaPlayer != mp) {
51 | if (sMediaPlayer.isPlaying())
52 | sMediaPlayer.stop();
53 | sMediaPlayer.release();
54 | sMediaPlayer = null;
55 | }
56 | sMediaPlayer = mp;
57 | }
58 |
59 | public static IMediaPlayer getMediaPlayer() {
60 | return sMediaPlayer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/list/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
29 |
30 |
36 |
41 |
42 |
50 |
53 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/IRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import android.graphics.SurfaceTexture;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 | import android.view.View;
25 |
26 | import tv.danmaku.ijk.media.player.IMediaPlayer;
27 |
28 | public interface IRenderView {
29 | static final int AR_ASPECT_FIT_PARENT = 0; // without clip
30 | static final int AR_ASPECT_FILL_PARENT = 1; // may clip
31 | static final int AR_ASPECT_WRAP_CONTENT = 2;
32 | static final int AR_MATCH_PARENT = 3;
33 | static final int AR_16_9_FIT_PARENT = 4;
34 | static final int AR_4_3_FIT_PARENT = 5;
35 |
36 | View getView();
37 |
38 | boolean shouldWaitForResize();
39 |
40 | void setVideoSize(int videoWidth, int videoHeight);
41 |
42 | void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
43 |
44 | void setVideoRotation(int degree);
45 |
46 | void setAspectRatio(int aspectRatio);
47 |
48 | void addRenderCallback(@NonNull IRenderCallback callback);
49 |
50 | void removeRenderCallback(@NonNull IRenderCallback callback);
51 |
52 | interface ISurfaceHolder {
53 | void bindToMediaPlayer(IMediaPlayer mp);
54 |
55 | @NonNull
56 | IRenderView getRenderView();
57 |
58 | @Nullable
59 | SurfaceHolder getSurfaceHolder();
60 |
61 | @Nullable
62 | Surface openSurface();
63 |
64 | @Nullable
65 | SurfaceTexture getSurfaceTexture();
66 | }
67 |
68 | public interface IRenderCallback {
69 | /**
70 | * @param holder
71 | * @param width could be 0
72 | * @param height could be 0
73 | */
74 | void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
75 |
76 | /**
77 | * @param holder
78 | * @param format could be 0
79 | * @param width
80 | * @param height
81 | */
82 | void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
83 |
84 | void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/adapter/newAdapter.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.BaseAdapter;
11 | import android.widget.RelativeLayout;
12 | import android.widget.TextView;
13 |
14 | import com.facebook.drawee.view.SimpleDraweeView;
15 |
16 | import java.util.ArrayList;
17 |
18 | import voole.example.com.myapplication.R;
19 | import voole.example.com.myapplication.activity.PlayerActivity;
20 | import voole.example.com.myapplication.data.liveData;
21 |
22 | /**
23 | * Created by zhangzexin on 16/1/29.
24 | */
25 | public class newAdapter extends BaseAdapter {
26 | String url = "http://pl3.live.panda.tv/live_panda/";
27 | Context context;
28 | ArrayList data;
29 | public newAdapter(Context context,ArrayList data) {
30 | super();
31 | this.data = data;
32 | this.context = context;
33 | }
34 |
35 | @Override
36 | public int getCount() {
37 | return data.size();
38 | }
39 |
40 | @Override
41 | public liveData getItem(int position) {
42 | return data.get(position);
43 | }
44 |
45 | @Override
46 | public long getItemId(int position) {
47 | return position;
48 | }
49 |
50 | @Override
51 | public View getView(final int position, View convertView, ViewGroup parent) {
52 | final liveData item = getItem(position);
53 | ViewHolder holder;
54 | if(convertView == null) {
55 | holder = new ViewHolder();
56 | holder.layout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.content_main,null);
57 | holder.imagerview = (SimpleDraweeView) holder.layout.findViewById(R.id.my_image_view);
58 | holder.textView = (TextView) holder.layout.findViewById(R.id.text);
59 | convertView = holder.layout;
60 | convertView.setTag(holder);
61 | }else{
62 | holder = (ViewHolder) convertView.getTag();
63 | }
64 | holder.textView.setText(item.getName());
65 | Uri uri = Uri.parse(item.getImgerURl());
66 | holder.imagerview.setImageURI(uri);
67 | convertView.setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View view) {
70 | // Intent intent = new Intent(context,PlayerActivity.class);
71 | String flv = item.getFlv();
72 | // intent.putExtra("url",url+flv+".flv?sign=sign&time=ts");
73 | PlayerActivity.intentTo(context,url+flv+".flv?sign=sign&time=ts");
74 | // context.startActivity(intent);
75 | Log.d("Adapter","点几了第"+position);
76 | }
77 | });
78 | return holder.layout;
79 | }
80 | static class ViewHolder{
81 | public SimpleDraweeView imagerview;
82 | public RelativeLayout layout;
83 | public TextView textView;
84 | }
85 |
86 |
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/MediaPlayerCompat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import tv.danmaku.ijk.media.player.IMediaPlayer;
20 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
21 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
22 | import tv.danmaku.ijk.media.player.TextureMediaPlayer;
23 |
24 | public class MediaPlayerCompat {
25 | public static String getName(IMediaPlayer mp) {
26 | if (mp == null) {
27 | return "null";
28 | } else if (mp instanceof TextureMediaPlayer) {
29 | StringBuilder sb = new StringBuilder("TextureMediaPlayer <");
30 | IMediaPlayer internalMediaPlayer = ((TextureMediaPlayer) mp).getInternalMediaPlayer();
31 | if (internalMediaPlayer == null) {
32 | sb.append("null>");
33 | } else {
34 | sb.append(internalMediaPlayer.getClass().getSimpleName());
35 | sb.append(">");
36 | }
37 | return sb.toString();
38 | } else {
39 | return mp.getClass().getSimpleName();
40 | }
41 | }
42 |
43 | public static IjkMediaPlayer getIjkMediaPlayer(IMediaPlayer mp) {
44 | IjkMediaPlayer ijkMediaPlayer = null;
45 | if (mp == null) {
46 | return null;
47 | } if (mp instanceof IjkMediaPlayer) {
48 | ijkMediaPlayer = (IjkMediaPlayer) mp;
49 | } else if (mp instanceof MediaPlayerProxy && ((MediaPlayerProxy) mp).getInternalMediaPlayer() instanceof IjkMediaPlayer) {
50 | ijkMediaPlayer = (IjkMediaPlayer) ((MediaPlayerProxy) mp).getInternalMediaPlayer();
51 | }
52 | return ijkMediaPlayer;
53 | }
54 |
55 | public static void selectTrack(IMediaPlayer mp, int stream) {
56 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
57 | if (ijkMediaPlayer == null)
58 | return;
59 | ijkMediaPlayer.selectTrack(stream);
60 | }
61 |
62 | public static void deselectTrack(IMediaPlayer mp, int stream) {
63 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
64 | if (ijkMediaPlayer == null)
65 | return;
66 | ijkMediaPlayer.deselectTrack(stream);
67 | }
68 |
69 | public static int getSelectedTrack(IMediaPlayer mp, int trackType) {
70 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
71 | if (ijkMediaPlayer == null)
72 | return -1;
73 | return ijkMediaPlayer.getSelectedTrack(trackType);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/network/HttpHelp.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.network;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.InputStreamReader;
8 | import java.io.OutputStream;
9 | import java.net.HttpURLConnection;
10 | import java.net.MalformedURLException;
11 | import java.net.URL;
12 | import java.net.URLConnection;
13 | import java.net.URLEncoder;
14 | import java.util.Map;
15 |
16 |
17 | public class HttpHelp {
18 |
19 | public String Get(String url) throws IOException {
20 | URL mUrl = new URL(url);
21 | HttpURLConnection connection = (HttpURLConnection) mUrl
22 | .openConnection();
23 | connection.setConnectTimeout(5000);
24 | connection.setReadTimeout(5000);
25 | connection.setRequestMethod("GET");
26 | connection.connect();
27 | int responseCode = connection.getResponseCode();
28 | if (responseCode<=299&&200 <=responseCode) {
29 | InputStream inputStream = connection.getInputStream();
30 | BufferedReader br = new BufferedReader(new InputStreamReader(
31 | inputStream));
32 | String response = "";
33 | String readLine = null;
34 | while ((readLine = br.readLine()) != null) {
35 | // response = br.readLine();
36 | response = response + readLine;
37 | }
38 | inputStream.close();
39 | br.close();
40 | connection.disconnect();
41 | return response;
42 | } else {
43 | throw new IOException("Unexpected code "
44 | + connection.getResponseCode());
45 | }
46 | }
47 | public String Post(String url,Map data,String ecode) throws IOException {
48 | byte[] mData = getRequestData(data,ecode).toString().getBytes();
49 | URL mUrl = new URL(url);
50 | HttpURLConnection connection = (HttpURLConnection)mUrl.openConnection();
51 | connection.setConnectTimeout(3000);
52 | connection.setReadTimeout(5000);
53 | connection.setDoInput(true);
54 | connection.setDoOutput(true);
55 | connection.setRequestMethod("POST");
56 | connection.setUseCaches(true);
57 | // connection.setRequestProperty("Content-Type","application/text/html;charset=utf-8");
58 | // connection.setRequestProperty("Content-Length",String.valueOf(mData.length));
59 | OutputStream outputStream = connection.getOutputStream();
60 | outputStream.write(mData);
61 | int responseCode = connection.getResponseCode();
62 | if(responseCode == connection.HTTP_OK){
63 | InputStream inputStream = connection.getInputStream();
64 | return dealResponseResult(inputStream);
65 | }
66 |
67 | return "-1";
68 | }
69 | public static StringBuffer getRequestData(Map data, String encode) {
70 | StringBuffer stringBuffer = new StringBuffer(); //存储封装好的请求体信息
71 | try {
72 | for(Map.Entry entry : data.entrySet()) {
73 | stringBuffer.append(entry.getKey())
74 | .append("=")
75 | .append(URLEncoder.encode(entry.getValue(), encode))
76 | .append("&");
77 | }
78 | stringBuffer.deleteCharAt(stringBuffer.length() - 1); //删除最后的一个"&"
79 | } catch (Exception e) {
80 | e.printStackTrace();
81 | }
82 | return stringBuffer;
83 | }
84 | public static String dealResponseResult(InputStream inputStream) {
85 | String resultData = null; //存储处理结果
86 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
87 | byte[] data = new byte[1024];
88 | int len = 0;
89 | try {
90 | while((len = inputStream.read(data)) != -1) {
91 | byteArrayOutputStream.write(data, 0, len);
92 | }
93 | } catch (IOException e) {
94 | e.printStackTrace();
95 | }
96 | resultData = new String(byteArrayOutputStream.toByteArray());
97 | return resultData;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/activity/PlayerActivity.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.v7.app.ActionBar;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.ImageButton;
13 |
14 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
15 | import voole.example.com.myapplication.R;
16 | import voole.example.com.myapplication.media.AndroidMediaController;
17 | import voole.example.com.myapplication.media.IjkVideoView;
18 |
19 | /**
20 | * Created by Administrator on 2016/2/22 0022.
21 | */
22 | public class PlayerActivity extends AppCompatActivity {
23 |
24 | private IjkVideoView mVideoView;
25 | private boolean mBackPressed;
26 | private AndroidMediaController mMediaController;
27 |
28 | public static Intent newIntent(Context context,String url){
29 | Intent intent = new Intent(context, PlayerActivity.class);
30 | intent.putExtra("url",url);
31 | return intent;
32 | }
33 |
34 | public static void intentTo(Context context, String Url){
35 | context.startActivity(newIntent(context,Url));
36 | }
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | String TAG = "PlayerActivty";
41 |
42 |
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.playactivity_main);
45 | Intent intent = getIntent();
46 | String url = intent.getStringExtra("url");
47 |
48 | //initButton
49 | ImageButton button = (ImageButton) findViewById(R.id.button);
50 | button.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | onBackPressed();
54 | }
55 | });
56 |
57 | //// android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
58 | // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
59 | // setSupportActionBar(toolbar);
60 | // ActionBar actionBar = getSupportActionBar();
61 | //
62 | // AndroidMediaController androidMediaController = new AndroidMediaController(this, false);
63 | // androidMediaController.setSupportActionBar(actionBar);
64 | // ActionBar actionBar = getSupportActionBar();
65 | mMediaController = new AndroidMediaController(this, false);
66 | mMediaController.setSupportBackPressed(button);
67 | // mMediaController.setSupportActionBar(actionBar);
68 |
69 |
70 | // init player
71 | IjkMediaPlayer.loadLibrariesOnce(null);
72 | IjkMediaPlayer.native_profileBegin("libijkplayer.so");
73 |
74 | mVideoView = (IjkVideoView) findViewById(R.id.video_view);
75 | mVideoView.setMediaController(mMediaController);
76 | // mVideoView.setHudView(mHudView);
77 | if (url != null)
78 | mVideoView.setVideoPath(url);
79 | else {
80 | Log.e(TAG, "Null Data Source\n");
81 | finish();
82 | return;
83 | }
84 | mVideoView.start();
85 |
86 | }
87 |
88 | @Override
89 | public void onBackPressed() {
90 | mBackPressed = true;
91 | super.onBackPressed();
92 | }
93 |
94 | @Override
95 | protected void onStop() {
96 | super.onStop();
97 | if (mBackPressed) {
98 | mVideoView.stopPlayback();
99 | mVideoView.release(true);
100 | mVideoView.stopBackgroundPlay();
101 | }
102 | IjkMediaPlayer.native_profileEnd();
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 | import android.preference.PreferenceManager;
22 |
23 | import voole.example.com.myapplication.R;
24 |
25 | public class Settings {
26 | private Context mAppContext;
27 | private SharedPreferences mSharedPreferences;
28 |
29 | public static final int PV_PLAYER__Auto = 0;
30 | public static final int PV_PLAYER__AndroidMediaPlayer = 1;
31 | public static final int PV_PLAYER__IjkMediaPlayer = 2;
32 | public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
33 |
34 | public Settings(Context context) {
35 | mAppContext = context.getApplicationContext();
36 | mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
37 | }
38 |
39 | public boolean getEnableBackgroundPlay() {
40 | String key = mAppContext.getString(R.string.pref_key_enable_background_play);
41 | return mSharedPreferences.getBoolean(key, false);
42 | }
43 |
44 | public int getPlayer() {
45 | String key = mAppContext.getString(R.string.pref_key_player);
46 | String value = mSharedPreferences.getString(key, "");
47 | try {
48 | return Integer.valueOf(value).intValue();
49 | } catch (NumberFormatException e) {
50 | return 0;
51 | }
52 | }
53 |
54 | public boolean getUsingMediaCodec() {
55 | String key = mAppContext.getString(R.string.pref_key_using_media_codec);
56 | return mSharedPreferences.getBoolean(key, false);
57 | }
58 |
59 | public boolean getUsingMediaCodecAutoRotate() {
60 | String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
61 | return mSharedPreferences.getBoolean(key, false);
62 | }
63 |
64 | public boolean getUsingOpenSLES() {
65 | String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
66 | return mSharedPreferences.getBoolean(key, false);
67 | }
68 |
69 | public String getPixelFormat() {
70 | String key = mAppContext.getString(R.string.pref_key_pixel_format);
71 | return mSharedPreferences.getString(key, "");
72 | }
73 |
74 | public boolean getEnableNoView() {
75 | String key = mAppContext.getString(R.string.pref_key_enable_no_view);
76 | return mSharedPreferences.getBoolean(key, false);
77 | }
78 |
79 | public boolean getEnableSurfaceView() {
80 | String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
81 | return mSharedPreferences.getBoolean(key, false);
82 | }
83 |
84 | public boolean getEnableTextureView() {
85 | String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
86 | return mSharedPreferences.getBoolean(key, false);
87 | }
88 |
89 | public boolean getEnableDetachedSurfaceTextureView() {
90 | String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
91 | return mSharedPreferences.getBoolean(key, false);
92 | }
93 |
94 | public String getLastDirectory() {
95 | String key = mAppContext.getString(R.string.pref_key_last_directory);
96 | return mSharedPreferences.getString(key, "/");
97 | }
98 |
99 | public void setLastDirectory(String path) {
100 | String key = mAppContext.getString(R.string.pref_key_last_directory);
101 | mSharedPreferences.edit().putString(key, path).commit();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/list/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | My Application
3 | Settings
4 |
5 |
6 | Sliding up effect with GridView
7 | N/A
8 | Close
9 | Exit
10 | Sample
11 | Recent
12 | Settings
13 | Tracks
14 | Player
15 | Render
16 | Scale
17 | Info
18 | vdec
19 | fps
20 | v-cache
21 | a-cache
22 |
23 | Media Information
24 | Player
25 | Media
26 | Profile level
27 | Pixel format
28 | Resolution
29 | Length
30 | Stream #%d
31 | Type
32 | Language
33 | Codec
34 | Frame rate
35 | Bit rate
36 | Sample rate
37 | Channels
38 | *
39 | *
40 |
41 | Video
42 | Audio
43 | Subtitle
44 | Timed text
45 | Meta data
46 | Unknown
47 |
48 | Invalid progressive playback
49 | Unknown
50 | OK
51 |
52 | Aspect / Fit parent
53 | Aspect / Fill parent
54 | Aspect / Wrap content
55 | Free / Fill parent
56 | 16:9 / Fit parent
57 | 4:3 / Fit parent
58 |
59 | Render: None
60 | Render: SurfaceView
61 | Render: TextureView
62 |
63 | Player: None
64 | Player: AndroidMediaPlayer
65 | Player: IjkMediaPlayer
66 | Player: IjkExoMediaPlayer
67 |
68 |
69 | Previous track
70 |
71 | Next track
72 |
73 | Pause
74 |
75 | Play
76 |
77 | Stop
78 |
79 | Rewind
80 |
81 |
--------------------------------------------------------------------------------
/list/src/main/res/values/strings_pref.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | General
5 |
6 | pref.enable_background_play
7 | Enable background play
8 | need Android 4.0+
9 |
10 | pref.using_android_player
11 | Using system player
12 |
13 |
14 | pref.player
15 | Choose Player
16 |
17 | - Auto Select
18 | - AndroidMediaPlayer
19 | - IjkMediaPlayer
20 | - IjkExoMediaPlayer
21 |
22 |
23 | - 0
24 | - 1
25 | - 2
26 | - 3
27 |
28 |
29 | - Auto Select
30 | - AndroidMediaPlayer
31 | - IjkMediaPlayer
32 | - IjkExoMediaPlayer
33 |
34 |
35 |
36 | Video: ijkplayer
37 |
38 | pref.using_media_codec
39 | Using MediaCodec
40 |
41 |
42 | pref.using_media_codec_auto_rotate
43 | Using MediaCodec auto rotate
44 |
45 |
46 | pref.pixel_format
47 | Pixel Format
48 |
49 | - Auto Select
50 | - RGB 565
51 | - RGB 888
52 | - RGBX 8888
53 | - YV12
54 | - OpenGL ES2
55 |
56 |
57 |
58 | - fcc-rv16
59 | - fcc-rv24
60 | - fcc-rv32
61 | - fcc-yv12
62 | - fcc-_es2
63 |
64 |
65 | - Auto Select
66 | - RGB 565
67 | - RGB 888
68 | - RGBX 8888
69 | - YV12
70 | - OpenGL ES2
71 |
72 |
73 |
74 | Audio: ijkplayer
75 |
76 | pref.using_opensl_es
77 | Using OpenSL ES
78 |
79 |
80 |
81 | RenderView
82 |
83 | pref.enable_no_view
84 | Enable NoView
85 |
86 |
87 | pref.enable_surface_view
88 | Enable SurfaceView
89 |
90 |
91 | pref.enable_texture_view
92 | Enable TextureView
93 |
94 |
95 | pref.enable_detached_surface_texture
96 | Enable detached SurfaceTexture
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/TableLayoutBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import android.content.Context;
20 | import android.support.v7.app.AlertDialog;
21 | import android.view.LayoutInflater;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.TableLayout;
25 | import android.widget.TextView;
26 |
27 | import voole.example.com.myapplication.R;
28 |
29 | public class TableLayoutBinder {
30 | private Context mContext;
31 | public ViewGroup mTableView;
32 | public TableLayout mTableLayout;
33 |
34 | public TableLayoutBinder(Context context) {
35 | this(context, R.layout.table_media_info);
36 | }
37 |
38 | public TableLayoutBinder(Context context, int layoutResourceId) {
39 | mContext = context;
40 | mTableView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutResourceId, null);
41 | mTableLayout = (TableLayout) mTableView.findViewById(R.id.table);
42 | }
43 |
44 | public TableLayoutBinder(Context context, TableLayout tableLayout) {
45 | mContext = context;
46 | mTableView = tableLayout;
47 | mTableLayout = tableLayout;
48 | }
49 |
50 | public View appendRow1(String name, String value) {
51 | return appendRow(R.layout.table_media_info_row1, name, value);
52 | }
53 |
54 | public View appendRow1(int nameId, String value) {
55 | return appendRow1(mContext.getString(nameId), value);
56 | }
57 |
58 | public View appendRow2(String name, String value) {
59 | return appendRow(R.layout.table_media_info_row2, name, value);
60 | }
61 |
62 | public View appendRow2(int nameId, String value) {
63 | return appendRow2(mContext.getString(nameId), value);
64 | }
65 |
66 | public View appendSection(String name) {
67 | return appendRow(R.layout.table_media_info_section, name, null);
68 | }
69 |
70 | public View appendSection(int nameId) {
71 | return appendSection(mContext.getString(nameId));
72 | }
73 |
74 | public View appendRow(int layoutId, String name, String value) {
75 | ViewGroup rowView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutId, mTableLayout, false);
76 | setNameValueText(rowView, name, value);
77 |
78 | mTableLayout.addView(rowView);
79 | return rowView;
80 | }
81 |
82 | public ViewHolder obtainViewHolder(View rowView) {
83 | ViewHolder viewHolder = (ViewHolder) rowView.getTag();
84 | if (viewHolder == null) {
85 | viewHolder = new ViewHolder();
86 | viewHolder.mNameTextView = (TextView) rowView.findViewById(R.id.name);
87 | viewHolder.mValueTextView = (TextView) rowView.findViewById(R.id.value);
88 | rowView.setTag(viewHolder);
89 | }
90 | return viewHolder;
91 | }
92 |
93 | public void setNameValueText(View rowView, String name, String value) {
94 | ViewHolder viewHolder = obtainViewHolder(rowView);
95 | viewHolder.setName(name);
96 | viewHolder.setValue(value);
97 | }
98 |
99 | public void setValueText(View rowView, String value) {
100 | ViewHolder viewHolder = obtainViewHolder(rowView);
101 | viewHolder.setValue(value);
102 | }
103 |
104 | public ViewGroup buildLayout() {
105 | return mTableView;
106 | }
107 |
108 | public AlertDialog.Builder buildAlertDialogBuilder() {
109 | AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(mContext);
110 | dlgBuilder.setView(buildLayout());
111 | return dlgBuilder;
112 | }
113 |
114 | private static class ViewHolder {
115 | public TextView mNameTextView;
116 | public TextView mValueTextView;
117 |
118 | public void setName(String name) {
119 | if (mNameTextView != null) {
120 | mNameTextView.setText(name);
121 | }
122 | }
123 |
124 | public void setValue(String value) {
125 | if (mValueTextView != null) {
126 | mValueTextView.setText(value);
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/AndroidMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package voole.example.com.myapplication.media;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.support.v7.app.ActionBar;
23 | import android.util.AttributeSet;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.ImageButton;
27 | import android.widget.MediaController;
28 | import android.widget.SeekBar;
29 |
30 | import java.lang.reflect.Field;
31 | import java.util.ArrayList;
32 |
33 | public class AndroidMediaController extends MediaController implements IMediaController {
34 | private ActionBar mActionBar;
35 | private ImageButton mButton;
36 | private Context mContext;
37 | private Field mRoot;
38 |
39 | public AndroidMediaController(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | this.mContext =context;
42 | initView(context);
43 | }
44 |
45 | public AndroidMediaController(Context context, boolean useFastForward) {
46 | super(context, useFastForward);
47 | this.mContext =context;
48 | initView(context);
49 | }
50 |
51 | public AndroidMediaController(Context context) {
52 | super(context);
53 | this.mContext =context;
54 | initView(context);
55 | }
56 |
57 | private void initView(Context context) {
58 | }
59 |
60 | @Override
61 | public void setAnchorView(View view) {
62 | super.setAnchorView(view);
63 | try {
64 | mRoot = MediaController.class.getDeclaredField("mRoot");
65 | mRoot.setAccessible(true);
66 | ViewGroup mRootVg = (ViewGroup) mRoot.get(this);
67 | ViewGroup vg = findSeekBarParent(mRootVg);
68 | vg.setVisibility(INVISIBLE);
69 | } catch (NoSuchFieldException e) {
70 | e.printStackTrace();
71 | } catch (IllegalAccessException e) {
72 | e.printStackTrace();
73 | }
74 |
75 | }
76 | private ViewGroup findSeekBarParent(ViewGroup vg) {
77 | ViewGroup viewGroup = null;
78 | for (int i = 0; i < vg.getChildCount(); i++) {
79 | View view = vg.getChildAt(i);
80 | if (view instanceof SeekBar) {
81 | viewGroup = (ViewGroup) view.getParent();
82 | break;
83 | } else if (view instanceof ViewGroup) {
84 | viewGroup = findSeekBarParent((ViewGroup) view);
85 | } else {
86 | continue;
87 | }
88 | }
89 | return viewGroup;
90 | }
91 |
92 |
93 |
94 |
95 | public void setSupportActionBar(@Nullable ActionBar actionBar) {
96 | mActionBar = actionBar;
97 | if (isShowing()) {
98 | actionBar.show();
99 | } else {
100 | actionBar.hide();
101 | }
102 | }
103 | public void setSupportBackPressed(@Nullable ImageButton imageButton){
104 | mButton = imageButton;
105 | if(isShowing()){
106 | imageButton.setVisibility(VISIBLE);
107 | }else{
108 | imageButton.setVisibility(INVISIBLE);
109 | }
110 | }
111 |
112 | @Override
113 | public void show() {
114 | super.show();
115 | if (mActionBar != null)
116 | mActionBar.show();
117 | if (mButton != null)
118 | mButton.setVisibility(VISIBLE);
119 | }
120 |
121 | @Override
122 | public void hide() {
123 | super.hide();
124 | if (mActionBar != null)
125 | mActionBar.hide();
126 | if (mButton != null)
127 | mButton.setVisibility(INVISIBLE);
128 | for (View view : mShowOnceArray)
129 | view.setVisibility(View.GONE);
130 | mShowOnceArray.clear();;
131 | }
132 |
133 | //----------
134 | // Extends
135 | //----------
136 | private ArrayList mShowOnceArray = new ArrayList();
137 |
138 | public void showOnce(@NonNull View view) {
139 | mShowOnceArray.add(view);
140 | view.setVisibility(View.VISIBLE);
141 | show();
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/media/InfoHudViewHolder.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.media;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.view.View;
7 | import android.widget.TableLayout;
8 |
9 | import java.util.HashMap;
10 | import java.util.Locale;
11 |
12 | import tv.danmaku.ijk.media.player.IMediaPlayer;
13 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
14 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
15 | import voole.example.com.myapplication.R;
16 |
17 | public class InfoHudViewHolder {
18 | private TableLayoutBinder mTableLayoutBinder;
19 | private HashMap mRowMap = new HashMap();
20 | private IMediaPlayer mMediaPlayer;
21 |
22 | public InfoHudViewHolder(Context context, TableLayout tableLayout) {
23 | mTableLayoutBinder = new TableLayoutBinder(context, tableLayout);
24 | }
25 |
26 | private void appendSection(int nameId) {
27 | mTableLayoutBinder.appendSection(nameId);
28 | }
29 |
30 | private void appendRow(int nameId) {
31 | View rowView = mTableLayoutBinder.appendRow2(nameId, null);
32 | mRowMap.put(nameId, rowView);
33 | }
34 |
35 | private void setRowValue(int id, String value) {
36 | View rowView = mRowMap.get(id);
37 | if (rowView == null) {
38 | rowView = mTableLayoutBinder.appendRow2(id, value);
39 | mRowMap.put(id, rowView);
40 | } else {
41 | mTableLayoutBinder.setValueText(rowView, value);
42 | }
43 | }
44 |
45 | public void setMediaPlayer(IMediaPlayer mp) {
46 | mMediaPlayer = mp;
47 | if (mMediaPlayer != null) {
48 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
49 | } else {
50 | mHandler.removeMessages(MSG_UPDATE_HUD);
51 | }
52 | }
53 |
54 | private static String formatedDurationMilli(long duration) {
55 | if (duration >= 1000) {
56 | return String.format(Locale.US, "%.2f sec", ((float)duration) / 1000);
57 | } else {
58 | return String.format(Locale.US, "%d msec", duration);
59 | }
60 | }
61 |
62 | private static String formatedSize(long bytes) {
63 | if (bytes >= 100 * 1000) {
64 | return String.format(Locale.US, "%.2f MB", ((float)bytes) / 1000 / 1000);
65 | } else if (bytes >= 100) {
66 | return String.format(Locale.US, "%.1f KB", ((float)bytes) / 1000);
67 | } else {
68 | return String.format(Locale.US, "%d B", bytes);
69 | }
70 | }
71 |
72 | private static final int MSG_UPDATE_HUD = 1;
73 | private Handler mHandler = new Handler() {
74 | @Override
75 | public void handleMessage(Message msg) {
76 | switch (msg.what) {
77 | case MSG_UPDATE_HUD: {
78 | InfoHudViewHolder holder = InfoHudViewHolder.this;
79 | IjkMediaPlayer mp = null;
80 | if (mMediaPlayer == null)
81 | break;
82 | if (mMediaPlayer instanceof IjkMediaPlayer) {
83 | mp = (IjkMediaPlayer) mMediaPlayer;
84 | } else if (mMediaPlayer instanceof MediaPlayerProxy) {
85 | MediaPlayerProxy proxy = (MediaPlayerProxy) mMediaPlayer;
86 | IMediaPlayer internal = proxy.getInternalMediaPlayer();
87 | if (internal != null && internal instanceof IjkMediaPlayer)
88 | mp = (IjkMediaPlayer) internal;
89 | }
90 | if (mp == null)
91 | break;
92 |
93 | int vdec = mp.getVideoDecoder();
94 | switch (vdec) {
95 | case IjkMediaPlayer.FFP_PROPV_DECODER_AVCODEC:
96 | setRowValue(R.string.vdec, "avcodec");
97 | break;
98 | case IjkMediaPlayer.FFP_PROPV_DECODER_MEDIACODEC:
99 | setRowValue(R.string.vdec, "MediaCodec");
100 | break;
101 | default:
102 | setRowValue(R.string.vdec, "");
103 | break;
104 | }
105 |
106 | float fpsOutput = mp.getVideoOutputFramesPerSecond();
107 | float fpsDecode = mp.getVideoDecodeFramesPerSecond();
108 | setRowValue(R.string.fps, String.format(Locale.US, "%.2f / %.2f", fpsDecode, fpsOutput));
109 |
110 | long videoCachedDuration = mp.getVideoCachedDuration();
111 | long audioCachedDuration = mp.getAudioCachedDuration();
112 | long videoCachedBytes = mp.getVideoCachedBytes();
113 | long audioCachedBytes = mp.getAudioCachedBytes();
114 |
115 | setRowValue(R.string.v_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(videoCachedDuration), formatedSize(videoCachedBytes)));
116 | setRowValue(R.string.a_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(audioCachedDuration), formatedSize(audioCachedBytes)));
117 |
118 | mHandler.removeMessages(MSG_UPDATE_HUD);
119 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
120 | }
121 | }
122 | }
123 | };
124 | }
125 |
--------------------------------------------------------------------------------
/list/src/main/java/voole/example/com/myapplication/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package voole.example.com.myapplication.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.os.Message;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.AbsListView;
12 | import android.widget.AdapterView;
13 | import android.widget.GridView;
14 | import android.widget.Toast;
15 |
16 | import com.facebook.drawee.backends.pipeline.Fresco;
17 |
18 | import org.json.JSONArray;
19 | import org.json.JSONException;
20 | import org.json.JSONObject;
21 |
22 | import java.io.IOException;
23 | import java.util.ArrayList;
24 | import java.util.HashMap;
25 | import java.util.LinkedHashMap;
26 | import java.util.List;
27 | import java.util.Map;
28 |
29 | import voole.example.com.myapplication.network.HttpHelp;
30 | import voole.example.com.myapplication.R;
31 | import voole.example.com.myapplication.data.liveData;
32 | import voole.example.com.myapplication.adapter.newAdapter;
33 |
34 |
35 | public class MainActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
36 | String url = "http://pl3.live.panda.tv/live_panda/";
37 | int pageno = 1;
38 | ArrayList arrayList = new ArrayList();
39 | Handler handler = new Handler(){
40 | @Override
41 | public void handleMessage(Message msg) {
42 | switch (msg.what){
43 | case 0:
44 | Toast.makeText(MainActivity.this,(String)msg.obj,Toast.LENGTH_LONG).show();
45 | break;
46 | case 1:
47 | ArrayList arrayList = (ArrayList) msg.obj;
48 | adapter = new newAdapter(MainActivity.this, arrayList);
49 | view.setAdapter(adapter);
50 | view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
51 | @Override
52 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
53 | liveData item = adapter.getItem(position);
54 | Intent intent = new Intent(MainActivity.this,PlayerActivity.class);
55 | String flv = item.getFlv();
56 | intent.putExtra("url",url+flv+".flv?sign=sign&time=ts");
57 | MainActivity.this.startActivity(intent);
58 | }
59 | });
60 | break;
61 | case 2:
62 | adapter.notifyDataSetChanged();
63 | break;
64 | }
65 | super.handleMessage(msg);
66 | }
67 | };
68 |
69 |
70 | List