Skip to content

Commit

Permalink
Android: Bug fixes for resume playback on app start.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Nov 4, 2013
1 parent 8815bf7 commit d436712
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -19,6 +19,7 @@
using System.Collections.Generic;
using System.Xml;
using MPfm.Core;
using MPfm.Library;
using MPfm.MVP.Bootstrap;
using TinyIoC;
using MPfm.MVP.Views;
Expand Down Expand Up @@ -152,17 +153,20 @@ private void ContinueAfterSplash()
{
var playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>();
var cloudLibraryService = Bootstrapper.GetContainer().Resolve<ICloudLibraryService>();
var audioFileCacheService = Bootstrapper.GetContainer().Resolve<IAudioFileCacheService>();
var audioFileCacheService = Bootstrapper.GetContainer().Resolve<IAudioFileCacheService>();
var syncDeviceSpecs = Bootstrapper.GetContainer().Resolve<ISyncDeviceSpecifications>();

// Compare timestamps from cloud vs local
var infos = cloudLibraryService.PullDeviceInfos().OrderByDescending(x => x.Timestamp).ToList();
CloudDeviceInfo cloudDeviceInfo = null;
AudioFile audioFileCloud = null;
AudioFile audioFileLocal = null;
string localDeviceName = syncDeviceSpecs.GetDeviceName();
DateTime localTimestamp = AppConfigManager.Instance.Root.ResumePlayback.Timestamp;
foreach (var deviceInfo in infos)
{
if (deviceInfo.Timestamp > localTimestamp)
// Make sure the timestamp is earlier than local, and that this isn't actually the same device!
if (deviceInfo.Timestamp > localTimestamp && deviceInfo.DeviceName != localDeviceName)
{
// Check if the file can be found in the database
Tracing.Log("MobileNavigationManager - ContinueAfterSplash - Cloud device {0} has earlier timestamp {1} compared to local timestamp {2}", deviceInfo.DeviceName, deviceInfo.Timestamp, localTimestamp);
Expand Down Expand Up @@ -222,7 +226,8 @@ private void ContinueAfterSplash()

Tracing.Log("MobileNavigationManager - ContinueAfterSplash - Resume playback is available; showing Player view...");
var audioFiles = audioFileCacheService.AudioFiles.Where(x => x.ArtistName == audioFile.ArtistName && x.AlbumTitle == audioFile.AlbumTitle).ToList();
playerService.Play(audioFiles, audioFile.FilePath, positionPercentage*100, true, true);
//playerService.Play(audioFiles, audioFile.FilePath, positionPercentage*100, true, true);
playerService.Play(audioFiles, audioFile.FilePath, positionPercentage, true, true);
CreatePlayerView(MobileNavigationTabType.Playlists);
}
else
Expand Down
6 changes: 3 additions & 3 deletions MPfm/MPfm.MVP/Services/PlayerService.cs
Expand Up @@ -110,10 +110,10 @@ void HandleOnPlaylistIndexChanged(PlayerPlaylistIndexChangedData data)
AppConfigManager.Instance.Save();
// Store player status on Cloud if enabled in preferences
if (AppConfigManager.Instance.Root.Cloud.IsDropboxResumePlaybackEnabled)
{
//if (AppConfigManager.Instance.Root.Cloud.IsDropboxResumePlaybackEnabled)
//{
_cloudLibraryService.PushDeviceInfo(data.AudioFileStarted, 0, "0:00.000");
}
//}
}
catch (Exception ex)
{
Expand Down

0 comments on commit d436712

Please sign in to comment.