Skip to content

Commit

Permalink
iOS: More bug fixes for resuming playback from MobileNavigationManage…
Browse files Browse the repository at this point in the history
…r. Added DateTime to iOSAppConfigProvider. The UI for StartResumePlayback is complete on iOS.
  • Loading branch information
ycastonguay committed Nov 4, 2013
1 parent d436712 commit f2e1603
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 37 deletions.
7 changes: 5 additions & 2 deletions MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -224,10 +224,13 @@ private void ContinueAfterSplash()
}
}

// Limit the value in case we try to skip beyond 100%
if (positionPercentage > 1)
positionPercentage = 0.99;

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, true, true);
playerService.Play(audioFiles, audioFile.FilePath, positionPercentage*100, true, true);
CreatePlayerView(MobileNavigationTabType.Playlists);
}
else
Expand Down
Expand Up @@ -49,24 +49,48 @@ public override void ViewDidLoad()

partial void actionResume(NSObject sender)
{

OnResumePlayback();
Close();
}

partial void actionCancel(NSObject sender)
{
Close();
}

private void Close()
{
WillMoveToParentViewController(null);
UIView.Animate(0.2f, () => {
this.View.Alpha = 0;
}, () => {
View.RemoveFromSuperview();
RemoveFromParentViewController();
});
}

#region IStartResumePlaybackView implementation

public Action<CloudDeviceInfo> OnResumePlayback { get; set; }
public Action OnResumePlayback { get; set; }

public void StartResumePlaybackError(Exception ex)
{
InvokeOnMainThread(() => {
var alertView = new UIAlertView("StartResumePlayback Error", ex.Message, null, "OK", null);
alertView.Show();
});
}

public void RefreshDevices(IEnumerable<CloudDeviceInfo> devices)
public void RefreshCloudDeviceInfo(CloudDeviceInfo device)
{
InvokeOnMainThread(() => {
lblDeviceName.Text = device.DeviceName;
lblPlaylistName.Text = "On-the-fly Playlist";
lblArtistName.Text = device.ArtistName;
lblAlbumTitle.Text = device.AlbumTitle;
lblSongTitle.Text = device.SongTitle;
lblTimestamp.Text = string.Format("Last updated: {0} {1}", device.Timestamp.ToShortDateString(), device.Timestamp.ToLongTimeString());
});
}

#endregion
Expand Down

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

12 changes: 12 additions & 0 deletions MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs
Expand Up @@ -21,6 +21,7 @@
using System.Diagnostics;
using MonoTouch.Foundation;
using MPfm.MVP.Config.Models;
using System;

namespace MPfm.iOS.Classes.Providers
{
Expand Down Expand Up @@ -68,6 +69,12 @@ private void LoadRecursive(IAppConfig config, string keyPreset)
{
propertyInfo.SetValue(config, keyStore.GetString(fullName));
}
else if (propertyType == typeof(DateTime))
{
long ticks = keyStore.GetLong(fullName);
DateTime dateTime = new DateTime(ticks);
propertyInfo.SetValue(config, dateTime);
}
else if (typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
{
var subConfig = (IAppConfig)propertyInfo.GetValue(config);
Expand Down Expand Up @@ -104,6 +111,11 @@ private void SaveRecursive(IAppConfig config, string keyPreset)
string stringValue = value == null ? string.Empty : (string)value;
keyStore.SetString(fullName, stringValue);
}
else if (propertyType == typeof(DateTime))
{
DateTime dateTime = (DateTime)value;
keyStore.SetLong(fullName, dateTime.Ticks);
}
else if (typeof (IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
{
var subConfig = (IAppConfig)propertyInfo.GetValue(config);
Expand Down
10 changes: 5 additions & 5 deletions MPfm/MPfm.iOS/XIB/iPhone/PlayerMetadataViewController_iPhone.xib
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
Expand All @@ -24,28 +24,28 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="[Title]" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4">
<rect key="frame" x="0.0" y="56" width="320" height="27"/>
<rect key="frame" x="8" y="56" width="304" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="16"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="[Song Count]" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="g3G-wS-cVL">
<rect key="frame" x="0.0" y="79" width="320" height="27"/>
<rect key="frame" x="8" y="79" width="304" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="12"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="[ArtistName]" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5">
<rect key="frame" x="0.0" y="3" width="320" height="32"/>
<rect key="frame" x="8" y="3" width="304" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="[AlbumTitle]" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="6">
<rect key="frame" x="0.0" y="31" width="320" height="28"/>
<rect key="frame" x="8" y="31" width="304" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="18"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
Expand Down

0 comments on commit f2e1603

Please sign in to comment.