[StreamingAudio] Add MainViewController instead of using viewController outlet in AppDelegate.cs

This commit is contained in:
olegoid 2014-01-31 21:52:39 +04:00
Родитель 621c7f7eb0
Коммит 43dc5c9dbf
3 изменённых файлов: 167 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,56 @@
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace StreamingAudio
{
public enum PlayerOption
{
Stream = 0,
StreamAndSave
}
public partial class MainViewController : UIViewController
{
private const string LetsStopTheWarUrl = "http://ccmixter.org/content/bradstanfield/bradstanfield_-_People_Let_s_Stop_The_War.mp3";
public MainViewController () : base ("MainViewController", null)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "Streaming MP3";
streamAndPlayButton.TouchUpInside += (sender, e) => OpenPlayerView(PlayerOption.Stream);
streamSaveAndPlayButton.TouchUpInside += (sender, e) => OpenPlayerView(PlayerOption.StreamAndSave);
urlTextbox.Text = LetsStopTheWarUrl;
urlTextbox.EditingDidEnd += (sender, e) => urlTextbox.ResignFirstResponder ();
}
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
statusLabel.Text = string.Empty;
}
private void OpenPlayerView(PlayerOption option)
{
statusLabel.Text = "Starting HTTP request";
var playerViewController = new PlayerViewController (option, LetsStopTheWarUrl);
playerViewController.ErrorOccurred += HandleError;
NavigationController.PushViewController (playerViewController, true);
}
private void HandleError(string message)
{
InvokeOnMainThread (delegate {
statusLabel.Text = message;
});
}
}
}

50
StreamingAudio/MainViewController.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,50 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using System.CodeDom.Compiler;
namespace StreamingAudio
{
[Register ("MainViewController")]
partial class MainViewController
{
[Outlet]
MonoTouch.UIKit.UILabel statusLabel { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton streamAndPlayButton { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton streamSaveAndPlayButton { get; set; }
[Outlet]
MonoTouch.UIKit.UITextField urlTextbox { get; set; }
void ReleaseDesignerOutlets ()
{
if (streamAndPlayButton != null) {
streamAndPlayButton.Dispose ();
streamAndPlayButton = null;
}
if (streamSaveAndPlayButton != null) {
streamSaveAndPlayButton.Dispose ();
streamSaveAndPlayButton = null;
}
if (urlTextbox != null) {
urlTextbox.Dispose ();
urlTextbox = null;
}
if (statusLabel != null) {
statusLabel.Dispose ();
statusLabel = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MainViewController">
<connections>
<outlet property="statusLabel" destination="wqe-i1-u8R" id="DRs-Hb-Iuy"/>
<outlet property="streamAndPlayButton" destination="qym-3Y-Odb" id="twT-Ib-yZZ"/>
<outlet property="streamSaveAndPlayButton" destination="TQf-lT-om3" id="fZe-QB-GQt"/>
<outlet property="urlTextbox" destination="GKC-gZ-GjM" id="X3a-fq-pgI"/>
<outlet property="view" destination="BZr-aN-H8B" id="H4Z-kC-4Gd"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="BZr-aN-H8B">
<rect key="frame" x="0.0" y="0.0" width="320" height="416"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Select URL of MP3 file to stream:" lineBreakMode="tailTruncation" minimumFontSize="10" id="z8w-wt-H10">
<rect key="frame" x="20" y="20" width="257" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="qym-3Y-Odb">
<rect key="frame" x="52" y="111" width="225" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<state key="normal" title="Stream and Play">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<textField opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" clearsOnBeginEditing="YES" minimumFontSize="17" id="GKC-gZ-GjM">
<rect key="frame" x="20" y="63" width="280" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="17"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Label" lineBreakMode="wordWrap" numberOfLines="13" minimumFontSize="10" adjustsFontSizeToFit="NO" id="wqe-i1-u8R">
<rect key="frame" x="20" y="156" width="285" height="240"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="TQf-lT-om3">
<rect key="frame" x="52" y="163" width="225" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<state key="normal" title="Stream, Save and Play">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</objects>
</document>