Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.video);
            url = base.Intent.GetStringExtra("url");
            int x = base.Intent.GetIntExtra("xSize", 300);
            int y = base.Intent.GetIntExtra("ySize", 500);
            string urlHost = "http://replays.robertsstream.com/racereplays/replaysmobile.php?";
            //urlHost = "rtsp://66.209.93.10:554/2012/_definst_/300/mp4:" + url + "_300.mp4?";

            string pk = "oq56rfju4vnjkm789grt";

            DateTime d1 = new DateTime(1970, 1, 1);
            DateTime d2 = DateTime.UtcNow;
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);

            double sd = ts.TotalMilliseconds;

            string UTC = sd.ToString().Substring(0, 10);
            string MD5String = UTC + pk + url;
            MD5String = GetMD5Hash(MD5String);

            urlHost += "race=" + url;
            urlHost += "&cust=OQHRA";
            urlHost += "&t=" + UTC;
            urlHost += "&h=" + MD5String;

            url = resolveRedirect(urlHost);
            if (url == "cant")
                return;

            if (mp != null)
            {
                mp.Reset();
                mp.Release();
            }
            mp = new Android.Media.MediaPlayer();
            mp.SetOnErrorListener(this);
            var surface = FindViewById<SurfaceView>(Resource.Id.surfaceView);
            var holder = surface.Holder;
#if DEBUG
            Console.WriteLine("surface.Holder = {0}", surface.Holder);
#endif
            holder.AddCallback(this);
            holder.SetType(Android.Views.SurfaceType.PushBuffers);
            holder.SetFixedSize(x - 50, y - 75);
#if DEBUG
            Console.WriteLine("videoplayer - url = {0}, x - 50 = {1}, y - 75 = {2}, mp.Info = {3}", url, x - 50, y - 75, mp);
#endif
            Button btnClose = FindViewById<Button>(Resource.Id.btnClose);
            btnClose.Click += (object s, EventArgs e) => { this.Finish(); };
        }
Example #2
0
        void CreateMediaPlayerIfNeeded()
        {
            if (mediaPlayer != null)
            {
                mediaPlayer.Reset();
                return;
            }

            mediaPlayer = new Android.Media.MediaPlayer();
            mediaPlayer.SetWakeMode(Context.ApplicationContext, WakeLockFlags.Partial);
            mediaPlayer.SetOnPreparedListener(this);
            mediaPlayer.SetOnCompletionListener(this);
            mediaPlayer.SetOnErrorListener(this);
            mediaPlayer.SetOnSeekCompleteListener(this);
        }
Example #3
0
        private void InitializePlayer()
        {
            _player = new AndroidMediaPlayer();
            var surfaceView = RenderSurface as SurfaceView;

            if (_hasValidHolder)
            {
                _player.SetDisplay(surfaceView.Holder);
                _player.SetScreenOnWhilePlaying(true);
            }
            else
            {
                surfaceView.Holder.AddCallback(this);
            }

            _player.SetOnErrorListener(this);
            _player.SetOnPreparedListener(this);
            _player.SetOnSeekCompleteListener(this);
            _player.SetOnBufferingUpdateListener(this);

            PlaybackSession.PlaybackStateChanged -= OnStatusChanged;
            PlaybackSession.PlaybackStateChanged += OnStatusChanged;
        }
Example #4
0
		void CreateMediaPlayerIfNeeded ()
		{
			LogHelper.Debug (Tag, "createMediaPlayerIfNeeded. needed? ", (mediaPlayer==null));
			if (mediaPlayer == null) {
				mediaPlayer = new MediaPlayer ();

				mediaPlayer.SetWakeMode (service.ApplicationContext,
					Android.OS.WakeLockFlags.Partial);

				mediaPlayer.SetOnPreparedListener (this);
				mediaPlayer.SetOnCompletionListener (this);
				mediaPlayer.SetOnErrorListener (this);
				mediaPlayer.SetOnSeekCompleteListener (this);
			} else {
				mediaPlayer.Reset ();
			}
		}
        public void InitMusicPlayer()
        {
            _appSettingsHelper = new AppSettingsHelper();
            _player = new MediaPlayer();
            _wifiLock = ((WifiManager)GetSystemService(WifiService)).CreateWifiLock(WifiMode.Full, "playerLock");

            _player.SetWakeMode(ApplicationContext, WakeLockFlags.Partial);
            _player.SetAudioStreamType(Stream.Music);
            _player.SetOnPreparedListener(this);
            _player.SetOnCompletionListener(this);
            _player.SetOnErrorListener(this);

            _audioManager = (AudioManager) GetSystemService(AudioService);

            _mediaButtonReceiverComponent = new ComponentName(ApplicationContext,
                Class.FromType(typeof (HeadsetButtonsReceiver)));
            _audioManager.RegisterMediaButtonEventReceiver(_mediaButtonReceiverComponent);
        }
        /// <summary>
        /// Intializes the player.
        /// </summary>
        private void InitializePlayer ()
        {
            mediaPlayer = new MediaPlayer ();

            //Tell our player to sream music
            mediaPlayer.SetAudioStreamType (Stream.Music);

            //Wake mode will be partial to keep the CPU still running under lock screen
            mediaPlayer.SetWakeMode (ApplicationContext, WakeLockFlags.Partial);

            mediaPlayer.SetOnBufferingUpdateListener (this);
            mediaPlayer.SetOnCompletionListener (this);
            mediaPlayer.SetOnErrorListener (this);
            mediaPlayer.SetOnPreparedListener (this);
        }