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);
			}
		}
示例#2
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);
            }
        }
示例#3
0
        //
        // Play
        //

        public static void Play(Song song)
        {
            if (ActiveSongChanged != null)
            {
                throw new PlatformNotSupportedException("ActiveSongChanged");
            }

            if (song.isAsset)
            {
                var asset = GameRunner.Singleton.Activity.getAssets().openFd(song.path);
                player.setDataSource(asset.getFileDescriptor(),
                                     asset.getStartOffset(), asset.getLength());
            }
            else
            {
                player.setDataSource(song.path);
            }

            Queue.Clear();
            Queue.Add(song);
            Queue.ActiveSongIndex = 0;

            PrepareAndStart();
        }
        internal LocalPlayer(PlayerController controller, Uri content)
        {
            this.mController = controller;

            // Create and initialize Android MediaPlayer instance.
            mPlayer = new MediaPlayer();
            try
            {
                mPlayer.setDataSource(controller.mContext, content);
                mPlayer.prepare();
                controller.Duration = mPlayer.Duration / 1000;
            }
            catch (IOException)
            {
                // Ignored for application brevity
            }
        }
		internal LocalPlayer(PlayerController controller, Uri content)
		{
			this.mController = controller;

			// Create and initialize Android MediaPlayer instance.
			mPlayer = new MediaPlayer();
			try
			{
				mPlayer.setDataSource(controller.mContext, content);
				mPlayer.prepare();
				controller.Duration = mPlayer.Duration / 1000;
			}
			catch (IOException)
			{
				// Ignored for application brevity
			}

		}