当前位置: 首页>>代码示例>>C#>>正文


C# MediaPlayer.Start方法代码示例

本文整理汇总了C#中Android.Media.MediaPlayer.Start方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Start方法的具体用法?C# MediaPlayer.Start怎么用?C# MediaPlayer.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Media.MediaPlayer的用法示例。


在下文中一共展示了MediaPlayer.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.Hide();
            SetContentView(Resource.Layout.Main);
            cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
            player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
            toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                StartActivity(typeof(Login));
            };


            toggleMusic.Click += (o, s) =>

            {
                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);

                }
                else
                {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };


        }
开发者ID:knervous,项目名称:MemoryBox,代码行数:35,代码来源:MainActivity.cs

示例2: OnCreateView

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.HomeScreen, container, false);
            infoButton = view.FindViewById<Button>(Resource.Id.infoButton);
            player = MediaPlayer.Create(view.Context, Resource.Raw.avril_14th);
            toggleMusic = view.FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            cover = view.FindViewById<RelativeLayout>(Resource.Id.titleScreen);

            Xamarin.Insights.Initialize(XamarinInsights.ApiKey, view.Context);
            CurrentPlatform.Init();

            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                facebookLogin.Invoke(this, new LoginEventArgs());
            };

            toggleMusic.Click += (o, s) => {

                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
                }
                else {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };

            return view;
        }
开发者ID:knervous,项目名称:MemBox1,代码行数:34,代码来源:HomeScreenFragment.cs

示例3: OnProgressChanged

        public override void OnProgressChanged(WebView view, int newProgress)
        {
            base.OnProgressChanged(view, newProgress);

            _context.SetProgress(newProgress * 100);

            if (newProgress == 100)
            {
                _context.Title = view.Title;

                bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);

                if (soundEnabled)
                {
                    _mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
                    _mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
                    _mediaPlayer.Start();
                }

                // add this page to the history
                using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
                {
                    var values = new ContentValues();
                    values.Put("Title", view.Title);
                    values.Put("Url", view.Url);
                    values.Put("Timestamp", DateTime.Now.Ticks);

                    db.Insert("history", null, values);
                }
            }
            else
            {
                _context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
            }
        }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:35,代码来源:CustomWebChromeClient.cs

示例4: OnElementChanged

        protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
        {
            base.OnElementChanged(e);
            if (Element == null)
                return;

            player = new MediaPlayer();
            timer = new Timer(1000);
            timer.Elapsed += timer_Elapsed;

            player.Prepared += (sender, args) =>
              {
                  try
                  {
                      player.SeekTo(0);
                      player.Start();
                      timer.Start();
                  }
                  catch
                  {
                  }
              };

            if (string.IsNullOrWhiteSpace(Player.Url))
                return;

            InitPlayer();

        }
开发者ID:Adam--,项目名称:Hanselman.Forms,代码行数:29,代码来源:AudioPlayerRenderer.cs

示例5: PlayWavFile

        public bool PlayWavFile(string fileName)
        {
            _mediaPlayer = MediaPlayer.Create(global::Android.App.Application.Context, Resource.Raw.ding_persevy);
            _mediaPlayer.Start();

            return true;
        }
开发者ID:JohanDeLijser,项目名称:SimpleAudioForms,代码行数:7,代码来源:AudioService.cs

示例6: PlaySoundAsync

        public Task PlaySoundAsync(string filename)
        {
            // Create media player
            var player = new MediaPlayer();

            // Create task completion source to support async/await
            var tcs = new TaskCompletionSource<bool> ();

            // Open the resource
            var fd = Xamarin.Forms.Forms.Context.Assets.OpenFd (filename);

            // Hook up some events
            player.Prepared += (s, e) => {
                player.Start();
            };

            player.Completion += (sender, e) => {
                tcs.SetResult(true);
            };

            // Initialize
            player.SetDataSource (fd.FileDescriptor);
            player.Prepare ();

            return tcs.Task;
        }
开发者ID:chrfalch,项目名称:SoundPlayer,代码行数:26,代码来源:AndroidSoundProvider.cs

示例7: PlaySound

 /// <summary>
 /// Method that plays the sound on Android.
 /// </summary>
 public void PlaySound(SoundboardItem item)
 {
     player = new MediaPlayer ();
     var fd = Xamarin.Forms.Forms.Context.Assets.OpenFd (item.FileName + ".mp3");
     player.SetDataSource (fd.FileDescriptor);
     player.Prepare ();
     player.Start ();
 }
开发者ID:sander1095,项目名称:DnD_Soundboard_Edres,代码行数:11,代码来源:Soundplayer_Android.cs

示例8: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			// Create your application here
			SetContentView(Resource.Layout.Menu);

			mpButtonTap = MediaPlayer.Create (this, Resource.Raw.buttontap);

			mimgSlogan = FindViewById<ImageView> (Resource.Id.limgMenuSlogan);
			mimgSlogan.SetImageResource (Resource.Drawable.slogan);
			mimgCoin = FindViewById<ImageView> (Resource.Id.limgCoinIcon);
			mimgCoin.SetImageResource (Resource.Drawable.coin_small);

			mbtnPlay = FindViewById<Button> (Resource.Id.lbtnPlay);
			mbtnPhrases = FindViewById<Button> (Resource.Id.lbtnPhrases);
			mbtnDictionary = FindViewById<Button> (Resource.Id.lbtnDictionary);
			mbtnAchievements = FindViewById<Button> (Resource.Id.lbtnAchievements);
			mtxtTip = FindViewById<TextView> (Resource.Id.ltxtTip);
			mtxtCoin = FindViewById<TextView> (Resource.Id.ltxtCoin);

			Database.createDatabase ("Tip");
			Database.createDatabase("Coins");
			Database.createDatabase ("Dictionary");
			Database.createDatabase ("Phrases");

			mtxtCoin.Text = Convert.ToString(Database.getCoins ());
			mtxtTip.Text = Database.getRandomTip();  

			mbtnPlay.Click += (object sender, EventArgs e) => {
				mpButtonTap.Start ();
				StartActivity(typeof(actGame));
			};
			mbtnPhrases.Click += (object sender, EventArgs e) => {
				mpButtonTap.Start ();
				StartActivity(typeof(actPhrases));
			};
			mbtnDictionary.Click += (object sender, EventArgs e) => {
				mpButtonTap.Start ();
				StartActivity(typeof(actDictionary));
			};
			mbtnAchievements.Click += (object sender, EventArgs e) => {
				mpButtonTap.Start ();
			};
		}
开发者ID:jejeboom,项目名称:Cebuanizer,代码行数:45,代码来源:actMenu.cs

示例9: Play

 public override void Play(string filename)
 {
     AssetFileDescriptor afd = Assets.OpenFd(filename);
     player = new MediaPlayer();
     player.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length);
     player.Completion += DidFinishPlaying;
     player.Prepare();
     player.Start();
 }
开发者ID:papagenoo,项目名称:BabylonMono,代码行数:9,代码来源:SoundPlayerIml.cs

示例10: Play

        public bool Play()
        {
            _player = MediaPlayer.Create(global::Android.App.Application.Context, Resource.Raw._01yes);
            _player.Start();
            _player.Completion += delegate
            {
                _player.Release();
            };

            return true;
        }
开发者ID:bronsonmcn,项目名称:AoESoundBoard,代码行数:11,代码来源:PlayAudio_Android.cs

示例11: Play

 public void Play(string p_FilePath)
 {
     using (MediaPlayer player = new MediaPlayer()) {
         if (p_FilePath.IndexOf ("Content") > -1) {
             Android.Content.Res.AssetFileDescriptor af = Android.App.Application.Context.Assets.OpenFd (p_FilePath);
             player.SetDataSource (af.FileDescriptor, af.StartOffset, af.Length);
         } else {
             player.SetDataSource (Path.Combine(DataPath,p_FilePath));
         }
         player.Prepare ();
         player.Start ();
     }
 }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:13,代码来源:MediaPlay.cs

示例12: StartPlayer

        public void StartPlayer(String  filePath)
        {
            if (player == null) {
                player = new MediaPlayer();
            } else {
                player.Reset();

                player = MediaPlayer.Create(this, Resource.Raw.buffy);
            //				player.SetDataSource(filePath);
                //player.Prepare();
                player.Start();
            }
        }
开发者ID:chaucola,项目名称:Nostalgie90Quizz,代码行数:13,代码来源:QuizzMusicalEasy.cs

示例13: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.Main);

            _player = MediaPlayer.Create(this, Resource.Raw.test);

            var playButton = FindViewById<Button> (Resource.Id.playButton);

            playButton.Click += delegate {
                _player.Start();
            };
        }
开发者ID:yofanana,项目名称:recipes,代码行数:14,代码来源:Activity1.cs

示例14: play

		void play(string fullPath)
		{
			ISurfaceHolder holder = videoView.Holder;
			holder.SetType (SurfaceType.PushBuffers);
			holder.AddCallback( this );
			player = new  MediaPlayer ();
			Android.Content.Res.AssetFileDescriptor afd = this.Assets.OpenFd(fullPath);
			if  (afd != null )
			{
				player.SetDataSource (afd.FileDescriptor, afd.StartOffset, afd.Length);
				player.Prepare ();
				player.Start ();
			}
		}
开发者ID:softsan,项目名称:List-view-demo-android,代码行数:14,代码来源:DetailView.cs

示例15: Play

        public void Play(Context c)
        {
            if (mPlayer != null && !mPlayer.IsPlaying) {
                mPlayer.Start();
                return;
            }
            Stop();

            mPlayer = MediaPlayer.Create(c, Resource.Raw.one_small_step);

            mPlayer.Completion += (object sender, EventArgs e) => {
                Stop();
            };
            mPlayer.Start();
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:15,代码来源:AudioPlayer.cs


注:本文中的Android.Media.MediaPlayer.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。