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 { /// /// Button 按键 /// public class Video : View { /// /// 当前视图 /// /// The android button. // 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"); // } // // } // }