wxr
2020-06-15 b8e94316e41eba72d927d5ca7d931b26139ee8ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Util;
using Android.Graphics;
 
//using IO.Vov.Vitamio;
//using OnBufferingUpdateListener = IO.Vov.Vitamio.MediaPlayer.IOnBufferingUpdateListener;
//using OnCompletionListener = IO.Vov.Vitamio.MediaPlayer.IOnCompletionListener;
//using OnPreparedListener = IO.Vov.Vitamio.MediaPlayer.IOnPreparedListener;
namespace Shared
{
    /// <summary>
    /// Button 按键
    /// </summary>
    public class Video : View
    {
        
        /// <summary>
        ///  当前视图
        /// </summary>
        /// <value>The android button.</value>
//        private AndroidSurfaceView surfaceView
//        {
//            get
//            {
//            return this.androidView as  AndroidSurfaceView;
//            }
//            set
//            {
//                this.androidView = value;
//            }
//        }
            
    
        public Video()
        {
//            this.surfaceView = new  AndroidSurfaceView (Application.Activity);
        }
 
        public void Start()
        {
//            this.surfaceView.Start ();    
        }
 
        public string URL
        {
//            get
//            {
//                return this.surfaceView.URL;
//            }
            set
            {
                //this.surfaceView.URL = value;
            }
        }
 
        public void Stop()
        {
            
        }
 
    }
 
//    internal class AndroidSurfaceView:SurfaceView,OnBufferingUpdateListener, OnPreparedListener, MediaPlayer.IOnVideoSizeChangedListener, ISurfaceHolderCallback
//    {
//        private const string TAG = "MediaPlayerDemo";
//        private int mVideoWidth;
//        private int mVideoHeight;
//        private MediaPlayer mMediaPlayer;
//        private ISurfaceHolder holder;
//
//        private const string MEDIA = "media";
//        private const int LOCAL_AUDIO = 1;
//        private const int STREAM_AUDIO = 2;
//        private const int RESOURCES_AUDIO = 3;
//        private const int LOCAL_VIDEO = 4;
//        private const int STREAM_VIDEO = 5;
//        private bool mIsVideoSizeKnown = false;
//        private bool mIsVideoReadyToBePlayed = false;
//
//        public string URL="";
//        
//        public AndroidSurfaceView (Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes):base(context,attrs,defStyleAttr,defStyleRes)
//        {
//            
//        }
//            
//        public AndroidSurfaceView (Context context, IAttributeSet attrs, int defStyleAttr):base(context,attrs,defStyleAttr){}
//
//        public AndroidSurfaceView (Context context, IAttributeSet attrs):base(context,attrs){}
//
//        public AndroidSurfaceView (Context context):base(context){
//            if (!LibsChecker.CheckVitamioLibs (Application.Activity)) {
//            }
//
//            holder = this.Holder;
//            holder.AddCallback(this);
//            holder.SetFormat(Format.Rgba8888);
//        }
//
//        protected AndroidSurfaceView (IntPtr javaReference, JniHandleOwnership transfer):base(javaReference,transfer){}
//
//        private void initPlayer()
//        {
//            try {
//                DoCleanUp ();
//
//                mMediaPlayer = new MediaPlayer (Application.Activity);
//                mMediaPlayer.SetDataSource (URL);
//                mMediaPlayer.SetDisplay (holder);
//                mMediaPlayer.PrepareAsync ();
//                mMediaPlayer.SetOnBufferingUpdateListener (this);
////                mMediaPlayer.SetOnCompletionListener (this);
//                mMediaPlayer.SetOnPreparedListener (this);
//                mMediaPlayer.SetOnVideoSizeChangedListener (this);
//
//            } catch (Exception e) {
//                Log.Error (TAG, "error: " + e.Message, e);
//            }
//        }
//
//        public virtual void OnBufferingUpdate(MediaPlayer arg0, int percent)
//        {
//            //Log.Info(TAG, "onBufferingUpdate percent:" + percent);
//
//        }
//            
//        public virtual void OnVideoSizeChanged(MediaPlayer mp, int width, int height)
//        {
//            Log.Verbose(TAG, "onVideoSizeChanged called");
//            if (width == 0 || height == 0)
//            {
//                Log.Error(TAG, "invalid video width(" + width + ") or height(" + height + ")");
//                return;
//            }
//            mIsVideoSizeKnown = true;
//            mVideoWidth = width;
//            mVideoHeight = height;
//        }
//
//        public virtual void OnPrepared(MediaPlayer mediaplayer)
//        {
//            Log.Debug(TAG, "onPrepared called");
//            mIsVideoReadyToBePlayed = true;
//        }
//
//        public virtual void SurfaceChanged(ISurfaceHolder surfaceholder, int i, int j, int k)
//        {
//            Log.Debug(TAG, "surfaceChanged called");
//        }
//
//        public virtual void SurfaceDestroyed(ISurfaceHolder surfaceholder)
//        {
//            Log.Debug(TAG, "surfaceDestroyed called");
//        }
//
//        public virtual void SurfaceCreated(ISurfaceHolder holder)
//        {
//            Log.Debug(TAG, "surfaceCreated called");
//            initPlayer();
//        }
//
//        public void Close()
//        {
//            ReleaseMediaPlayer();
//            DoCleanUp();
//        }
//
//        private void ReleaseMediaPlayer()
//        {
//            if (mMediaPlayer != null)
//            {
//                mMediaPlayer.Release();
//                mMediaPlayer = null;
//            }
//        }
//
//        private void DoCleanUp()
//        {
//            mVideoWidth = 0;
//            mVideoHeight = 0;
//            mIsVideoReadyToBePlayed = false;
//            mIsVideoSizeKnown = false;
//        }
//
//        public void Start()
//        {
//        if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) {
//            Log.Info (TAG, "startVideoPlayback");
//            holder.SetFixedSize (mVideoWidth, mVideoHeight);
//            if (!b) {
//                b = true;
//                mMediaPlayer.Start ();
//            }
//        }
//    }
//
//        private bool b;
//
//        public void SurfaceChanged (ISurfaceHolder holder, Format format, int width, int height)
//        {
//            Log.Debug(TAG, "surfaceChanged called");
//        }
//
//    }
//
}