Skip to content

Commit

Permalink
iOS: Now loading PlayerViewController right after splash when local r…
Browse files Browse the repository at this point in the history
…esume playback information is available. The playback now resumes, but there are still a few things to fix.
  • Loading branch information
ycastonguay committed Oct 29, 2013
1 parent 9da8034 commit 5486964
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 266 deletions.
4 changes: 2 additions & 2 deletions MPfm/MPfm.MVP/Config/Models/ResumePlaybackAppConfig.cs
Expand Up @@ -30,8 +30,8 @@ public class ResumePlaybackAppConfig : IAppConfig

public ResumePlaybackAppConfig()
{
CurrentAudioFileId = Guid.Empty.ToString();
CurrentPlaylistId = Guid.Empty.ToString();
//CurrentAudioFileId = Guid.Empty.ToString();
//CurrentPlaylistId = Guid.Empty.ToString();
}
}
}
47 changes: 46 additions & 1 deletion MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -28,6 +28,10 @@
using MPfm.Player.Objects;
using MPfm.Library.Objects;
using MPfm.Sound.AudioFiles;
using MPfm.MVP.Config;
using MPfm.MVP.Services.Interfaces;
using MPfm.Library.Services.Interfaces;
using System.Linq;

namespace MPfm.MVP.Navigation
{
Expand Down Expand Up @@ -153,6 +157,47 @@ public virtual void Start()
#endif
// Finally hide the splash screen, our UI is ready
//HideSplash();
AppConfigManager.Instance.Load();
Console.WriteLine("LaunchActivity - OnCreate - isFirstRun: {0} resumePlayback.currentAudioFileId: {1} resumePlayback.currentPlaylistId: {2}", AppConfigManager.Instance.Root.IsFirstRun, AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
if (AppConfigManager.Instance.Root.IsFirstRun)
//if(true == true)
{
Tracing.Log("LaunchActivity - First run of the application; launching FirstRun activity...");
CreateFirstRunView();
// var intent = new Intent(this, typeof(FirstRunActivity));
// StartActivity(intent);
// Finish();
}
else if (!string.IsNullOrEmpty(AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId))
{
var playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>();
var messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
var audioFileCacheService = Bootstrapper.GetContainer().Resolve<IAudioFileCacheService>();
var audioFile = audioFileCacheService.AudioFiles.FirstOrDefault(x => x.Id == new Guid(AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId));
if(audioFile != null)
{
Tracing.Log("LaunchActivity - Resume playback is available; launching Player activity...");
var audioFiles = audioFileCacheService.AudioFiles.Where(x => x.ArtistName == audioFile.ArtistName && x.AlbumTitle == audioFile.AlbumTitle).ToList();
playerService.Play(audioFiles, audioFile.FilePath);
Action<IBaseView> onViewBindedToPresenter = (theView) => messengerHub.PublishAsync<MobileLibraryBrowserItemClickedMessage>(new MobileLibraryBrowserItemClickedMessage(this)
{
Query = new LibraryQuery() {
ArtistName = audioFile.ArtistName,
AlbumTitle = audioFile.AlbumTitle
},
FilePath = audioFile != null ? audioFile.FilePath : string.Empty
});
CreatePlayerView(MobileNavigationTabType.Playlists, onViewBindedToPresenter);
}
}
HideSplash();
};
ShowSplash(CreateSplashView(onInitDone));
Expand Down Expand Up @@ -934,7 +979,7 @@ protected virtual void CreateFirstRunViewInternal(Action<IBaseView> onViewReady)
_firstRunView = Bootstrapper.GetContainer().Resolve<IFirstRunView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });

#if !ANDROID
PushTabView(MobileNavigationTabType.More, _resumePlaybackView);
PushDialogView(MobileDialogPresentationType.Overlay, "First Run", null, _firstRunView);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions MPfm/MPfm.MVP/Services/PlayerService.cs
Expand Up @@ -105,6 +105,7 @@ void HandleOnPlaylistIndexChanged(PlayerPlaylistIndexChangedData data)
// Store player status locally for resuming playback later
AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId = data.AudioFileStarted.Id.ToString();
AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId = _player.Playlist.PlaylistId.ToString();
AppConfigManager.Instance.Root.PositionUpdateFrequency = 777;
AppConfigManager.Instance.Save();
// Store player status on Cloud if enabled in preferences
Expand Down
13 changes: 13 additions & 0 deletions MPfm/MPfm.iOS/Classes/Controllers/FirstRunViewController.cs
Expand Up @@ -34,6 +34,19 @@ public FirstRunViewController(Action<IBaseView> onViewReady)
public override void ViewDidLoad()
{
base.ViewDidLoad();

btnClose.SetImage(UIImage.FromBundle("Images/Buttons/select"));
}

partial void actionClose(NSObject sender)
{
WillMoveToParentViewController(null);
UIView.Animate(0.2f, () => {
this.View.Alpha = 0;
}, () => {
View.RemoveFromSuperview();
RemoveFromParentViewController();
});
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -36,6 +36,19 @@ public StartResumePlaybackViewController(Action<IBaseView> onViewReady)
public override void ViewDidLoad()
{
base.ViewDidLoad();

btnResume.SetImage(UIImage.FromBundle("Images/Buttons/select"));
btnCancel.SetImage(UIImage.FromBundle("Images/Buttons/cancel"));
}

partial void actionResume(NSObject sender)
{

}

partial void actionCancel(NSObject sender)
{

}

#region IStartResumePlaybackView implementation
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs
Expand Up @@ -29,9 +29,6 @@ public class iOSAppConfigProvider : IAppConfigProvider
public RootAppConfig Load(string filePath)
{
var config = new RootAppConfig();
config.IsFirstRun = false;
SaveRecursive(config, "Root.");
config.IsFirstRun = true;
LoadRecursive(config, "Root.");
return config;
}
Expand All @@ -50,8 +47,6 @@ private void LoadRecursive(IAppConfig config, string keyPreset)
{
var propertyType = propertyInfo.PropertyType;
string fullName = keyPreset + propertyInfo.Name;
bool isAssignable = typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo());
//Debug.WriteLine("{0} - {1} - isAssignable: {2}", fullName, propertyInfo.PropertyType.Name, isAssignable);

if (propertyType == typeof(int))
{
Expand Down Expand Up @@ -91,8 +86,6 @@ private void SaveRecursive(IAppConfig config, string keyPreset)
var propertyType = propertyInfo.PropertyType;
string fullName = keyPreset + propertyInfo.Name;
object value = propertyInfo.GetValue(config);
bool isAssignable = typeof (IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo());
//Debug.WriteLine("{0} - {1} - isAssignable: {2}", fullName, propertyInfo.PropertyType.Name, isAssignable);

if (propertyType == typeof(int))
{
Expand Down

0 comments on commit 5486964

Please sign in to comment.