Esempio n. 1
0
		internal LocalPlayer(PlayerController controller, Uri content, Uri subtitlesUri, SurfaceView videoView)
		{
			mController = controller;

			// Create and initialize Android MediaPlayer instance.
			mPlayer = new MediaPlayer();
			mPlayer.OnCompletionListener = this;

			mSurfaceHolder = videoView.Holder;
			mSurfaceHolder.addCallback(this);

			bool isSurfaceValid = mSurfaceHolder.Surface.Valid;

			if (isSurfaceValid)
			{
				mPlayer.Display = mSurfaceHolder;
			}

			try
			{
				mPlayer.setDataSource(controller.mContext, content);

				mPlayer.prepare();
				if (subtitlesUri != null)
				{
					mPlayer.addTimedTextSource(subtitlesUri.Path, MediaPlayer.MEDIA_MIMETYPE_TEXT_SUBRIP);
					mPlayer.OnTimedTextListener = this;
				}
				controller.Duration = mPlayer.Duration / 1000;
			}
			catch (IOException ignored)
			{
				Log.e("VideoPlayer", ignored.Message);
			}
		}
		internal RemotePlayer(PlayerController controller, Uri contentUri, Uri subtitlesUri, string mimeType, string deviceId, int deviceType)
		{
			mController = controller;
			mContentUri = contentUri;
			mSubtitlesUri = subtitlesUri;
			mMimeType = mimeType;
			mDeviceId = deviceId;
			mDeviceType = deviceType;

			// Connects to AllShare Service. Processing continues when
			// service instance is received in onCreated callback method.
			// Connect to AllShare Service. Processing continues when
			// service instance is received in onCreated callback method.
			SmcDeviceFinder df = new SmcDeviceFinder(controller.mContext);
			df.StatusListener = this;
			df.start();
		}