예제 #1
0
        private void SetupCarPlay()
        {
            _playableContentManager = MPPlayableContentManager.Shared;

            PlayableContentDelegate playableContentDelegate = new PlayableContentDelegate();

            _playableContentManager.Delegate = playableContentDelegate;

            PlayableContentDataSource playableContentDataSource = new PlayableContentDataSource();

            _playableContentManager.DataSource = playableContentDataSource;
        }
예제 #2
0
        public override void InitiatePlaybackOfContentItem(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
        {
            try
            {
                DispatchQueue.MainQueue.DispatchAsync(async() =>
                {
                    UIApplication.SharedApplication.EndReceivingRemoteControlEvents();
                    UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();

                    var itemToPlay           = GlobalConstants.PlayLists[indexPath.Row];
                    var NowPlayingInfoCenter = MPNowPlayingInfoCenter.DefaultCenter;

                    MPNowPlayingInfo playingInfo = new MPNowPlayingInfo();
                    playingInfo.Title            = GlobalConstants.PlayLists[indexPath.Row].Name;
                    playingInfo.Artist           = GlobalConstants.PlayLists[indexPath.Row].Editor;
                    playingInfo.PlaybackDuration = GlobalConstants.PlayLists[indexPath.Row].Duration;
                    playingInfo.MediaType        = MPNowPlayingInfoMediaType.Audio;

                    NowPlayingInfoCenter.NowPlaying = playingInfo;

                    var commandCenter = MPRemoteCommandCenter.Shared;
                    commandCenter.PlayCommand.Enabled  = true;
                    commandCenter.PauseCommand.Enabled = true;
                    commandCenter.PauseCommand.AddTarget(PauseButton);

                    var songId          = "11111";
                    string[] identifier = new string[1];
                    identifier[0]       = songId;

                    contentManager = MPPlayableContentManager.Shared;
                    contentManager.NowPlayingIdentifiers = identifier;

                    await CrossMediaManager.Current.Play(GlobalConstants.PlayLists[indexPath.Row].Url);

                    completionHandler(null);

                    UIApplication.SharedApplication.EndReceivingRemoteControlEvents();

                    UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
예제 #3
0
        private void SetupCarPlay()
        {
            CPTemplateApplicationScene = new CPTemplateApplicationScene();
            CarPlayApplicationDelegate carPlayApplicationDelegate = new CarPlayApplicationDelegate();

            carPlayApplicationDelegate.Connected = Connected;
            CPTemplateApplicationScene.Delegate  = carPlayApplicationDelegate;

            _playableContentManager = MPPlayableContentManager.Shared;

            PlayableContentDelegate playableContentDelegate = new PlayableContentDelegate();

            _playableContentManager.Delegate = playableContentDelegate;

            PlayableContentDataSource playableContentDataSource = new PlayableContentDataSource();

            _playableContentManager.DataSource = playableContentDataSource;
        }
        public void Shared()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 1, throwIfOtherPlatform: false);

            MPPlayableContentManager shared = MPPlayableContentManager.Shared;

            Assert.Null(shared.DataSource, "DataSource");
            Assert.Null(shared.Delegate, "Delegate");

            try {
                using (var ds = new DataSource())
                    using (var dg = new Delegate()) {
                        shared.DataSource = ds;
                        shared.Delegate   = dg;
                    }
            }
            finally {
                shared.DataSource = null;
                shared.Delegate   = null;
            }
        }
        private async Task ItemSelectedAsync(MPPlayableContentManager contentManager, NSIndexPath indexPath)
        {
            // Play
            var station = PlayableContentDataSource.Stations[indexPath.Section];
            await CrossMediaManager.Current.Play(station.Url);

            // Set playing identifier
            MPContentItem item = contentManager.DataSource.ContentItem(indexPath);

            contentManager.NowPlayingIdentifiers = new[] { item.Identifier };

            // Update on simulator
            if (DeviceInfo.DeviceType == DeviceType.Virtual)
            {
                InvokeOnMainThread(() =>
                {
                    UIApplication.SharedApplication.EndReceivingRemoteControlEvents();
                    UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
                });
            }
        }
        public void InitCarPlay()
        {
            try
            {
                CPTemplateApplicationScene = new CPTemplateApplicationScene();
                CPTemplateSceneDelegate templateSceneDelegate = new CPTemplateSceneDelegate();
                templateSceneDelegate.Connected     = Connected;
                CPTemplateApplicationScene.Delegate = templateSceneDelegate;

                _playableContentManager = MPPlayableContentManager.Shared;

                PlayableContentDelegate playableContentDelegate = new PlayableContentDelegate();
                _playableContentManager.Delegate = playableContentDelegate;

                PlayableContentDataSource playableContentDataSource = new PlayableContentDataSource();
                _playableContentManager.DataSource = playableContentDataSource;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
        public void Shared()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(7, 1))
            {
                Assert.Inconclusive("Requires 7.1+");
            }

            MPPlayableContentManager shared = MPPlayableContentManager.Shared;

            Assert.Null(shared.DataSource, "DataSource");
            Assert.Null(shared.Delegate, "Delegate");

            try {
                using (var ds = new DataSource())
                    using (var dg = new Delegate()) {
                        shared.DataSource = ds;
                        shared.Delegate   = dg;
                    }
            }
            finally {
                shared.DataSource = null;
                shared.Delegate   = null;
            }
        }
 public static void PlayableContentManager(this IMPPlayableContentDelegate This, MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
 {
     This.InitiatePlaybackOfContentItem(contentManager, indexPath, completionHandler);
 }
 public virtual void PlayableContentManager(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
 {
     InitiatePlaybackOfContentItem(contentManager, indexPath, completionHandler);
 }
예제 #10
0
 public override void PlayableContentManager(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
 {
     base.PlayableContentManager(contentManager, indexPath, completionHandler);
 }
예제 #11
0
 public override void ContextUpdated(MPPlayableContentManager contentManager, MPPlayableContentManagerContext context)
 {
     base.ContextUpdated(contentManager, context);
 }
예제 #12
0
 public override void InitiatePlaybackOfContentItem(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
 {
 }
 private void Execute(MPPlayableContentManager contentManager, NSIndexPath indexPath)
 {
     DispatchQueue.MainQueue.DispatchAsync(async() => await ItemSelectedAsync(contentManager, indexPath));
 }
 public override void InitiatePlaybackOfContentItem(
     MPPlayableContentManager contentManager, NSIndexPath indexPath, Action <NSError> completionHandler)
 {
     Execute(contentManager, indexPath);
     completionHandler?.Invoke(null);
 }
예제 #15
0
 public static void PlayableContentManager(this IMPPlayableContentDelegate This, MPPlayableContentManager contentManager, NSIndexPath indexPath, Action<NSError> completionHandler)
 {
     This.InitiatePlaybackOfContentItem (contentManager, indexPath, completionHandler);
 }
예제 #16
0
 public virtual void PlayableContentManager(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action<NSError> completionHandler)
 {
     InitiatePlaybackOfContentItem (contentManager, indexPath, completionHandler);
 }