CocoaでAVFoundationを使うサンプル
修訂 | 1d59899c4ebee589157acbb34d04085f3d60da38 (tree) |
---|---|
時間 | 2012-06-13 22:34:33 |
作者 | Hori <masaki@MBP....> |
Commiter | Hori |
UIのenabled
@@ -14,6 +14,7 @@ | ||
14 | 14 | @property (assign) IBOutlet NSButton *playButton; |
15 | 15 | |
16 | 16 | @property (assign) NSTimeInterval currentTime; |
17 | +@property (assign) BOOL canPlay; | |
17 | 18 | |
18 | 19 | - (IBAction)togglePlayAndPause:(id)sender; |
19 | 20 | - (IBAction)changeCurrentTime:(id)sender; |
@@ -28,6 +28,7 @@ | ||
28 | 28 | @synthesize view = _view; |
29 | 29 | @synthesize playButton = _playButton; |
30 | 30 | @synthesize currentTime = _currentTime; |
31 | +@synthesize canPlay = _canPlay; | |
31 | 32 | |
32 | 33 | @synthesize asset = _asset; |
33 | 34 | @synthesize item = _item; |
@@ -101,10 +102,10 @@ | ||
101 | 102 | { |
102 | 103 | if((_player.currentItem != nil) && |
103 | 104 | ([_player.currentItem status] == AVPlayerItemStatusReadyToPlay)) { |
104 | - _playButton.enabled = YES; | |
105 | + self.canPlay = YES; | |
105 | 106 | } |
106 | 107 | else { |
107 | - _playButton.enabled = NO; | |
108 | + self.canPlay = NO; | |
108 | 109 | } |
109 | 110 | |
110 | 111 | CGFloat rate = _player.rate; |
@@ -24,6 +24,7 @@ | ||
24 | 24 | <string>NSView</string> |
25 | 25 | <string>NSWindowTemplate</string> |
26 | 26 | <string>NSTextField</string> |
27 | + <string>NSUserDefaultsController</string> | |
27 | 28 | </array> |
28 | 29 | <array key="IBDocument.PluginDependencies"> |
29 | 30 | <string>com.apple.InterfaceBuilder.CocoaPlugin</string> |
@@ -380,6 +381,9 @@ | ||
380 | 381 | <object class="NSCustomObject" id="796877042"> |
381 | 382 | <string key="NSClassName">NSApplication</string> |
382 | 383 | </object> |
384 | + <object class="NSUserDefaultsController" id="40310097"> | |
385 | + <bool key="NSSharedInstance">YES</bool> | |
386 | + </object> | |
383 | 387 | </array> |
384 | 388 | <object class="IBObjectContainer" key="IBDocument.Objects"> |
385 | 389 | <array class="NSMutableArray" key="connectionRecords"> |
@@ -416,14 +420,6 @@ | ||
416 | 420 | <int key="connectionID">100393</int> |
417 | 421 | </object> |
418 | 422 | <object class="IBConnectionRecord"> |
419 | - <object class="IBOutletConnection" key="connection"> | |
420 | - <string key="label">playButton</string> | |
421 | - <reference key="source" ref="512844837"/> | |
422 | - <reference key="destination" ref="16104508"/> | |
423 | - </object> | |
424 | - <int key="connectionID">100053</int> | |
425 | - </object> | |
426 | - <object class="IBConnectionRecord"> | |
427 | 423 | <object class="IBActionConnection" key="connection"> |
428 | 424 | <string key="label">fastForward:</string> |
429 | 425 | <reference key="source" ref="512844837"/> |
@@ -449,6 +445,14 @@ | ||
449 | 445 | </object> |
450 | 446 | <object class="IBConnectionRecord"> |
451 | 447 | <object class="IBOutletConnection" key="connection"> |
448 | + <string key="label">playButton</string> | |
449 | + <reference key="source" ref="512844837"/> | |
450 | + <reference key="destination" ref="16104508"/> | |
451 | + </object> | |
452 | + <int key="connectionID">100788</int> | |
453 | + </object> | |
454 | + <object class="IBConnectionRecord"> | |
455 | + <object class="IBOutletConnection" key="connection"> | |
452 | 456 | <string key="label">delegate</string> |
453 | 457 | <reference key="source" ref="275939982"/> |
454 | 458 | <reference key="destination" ref="512844837"/> |
@@ -465,6 +469,22 @@ | ||
465 | 469 | </object> |
466 | 470 | <object class="IBConnectionRecord"> |
467 | 471 | <object class="IBBindingConnection" key="connection"> |
472 | + <string key="label">enabled: canPlay</string> | |
473 | + <reference key="source" ref="16104508"/> | |
474 | + <reference key="destination" ref="512844837"/> | |
475 | + <object class="NSNibBindingConnector" key="connector"> | |
476 | + <reference key="NSSource" ref="16104508"/> | |
477 | + <reference key="NSDestination" ref="512844837"/> | |
478 | + <string key="NSLabel">enabled: canPlay</string> | |
479 | + <string key="NSBinding">enabled</string> | |
480 | + <string key="NSKeyPath">canPlay</string> | |
481 | + <int key="NSNibBindingConnectorVersion">2</int> | |
482 | + </object> | |
483 | + </object> | |
484 | + <int key="connectionID">100787</int> | |
485 | + </object> | |
486 | + <object class="IBConnectionRecord"> | |
487 | + <object class="IBBindingConnection" key="connection"> | |
468 | 488 | <string key="label">maxValue: asset.duration</string> |
469 | 489 | <reference key="source" ref="491353793"/> |
470 | 490 | <reference key="destination" ref="512844837"/> |
@@ -502,6 +522,22 @@ | ||
502 | 522 | </object> |
503 | 523 | <object class="IBConnectionRecord"> |
504 | 524 | <object class="IBBindingConnection" key="connection"> |
525 | + <string key="label">enabled: canPlay</string> | |
526 | + <reference key="source" ref="491353793"/> | |
527 | + <reference key="destination" ref="512844837"/> | |
528 | + <object class="NSNibBindingConnector" key="connector"> | |
529 | + <reference key="NSSource" ref="491353793"/> | |
530 | + <reference key="NSDestination" ref="512844837"/> | |
531 | + <string key="NSLabel">enabled: canPlay</string> | |
532 | + <string key="NSBinding">enabled</string> | |
533 | + <string key="NSKeyPath">canPlay</string> | |
534 | + <int key="NSNibBindingConnectorVersion">2</int> | |
535 | + </object> | |
536 | + </object> | |
537 | + <int key="connectionID">100786</int> | |
538 | + </object> | |
539 | + <object class="IBConnectionRecord"> | |
540 | + <object class="IBBindingConnection" key="connection"> | |
505 | 541 | <string key="label">value: currentTime</string> |
506 | 542 | <reference key="source" ref="868760446"/> |
507 | 543 | <reference key="destination" ref="512844837"/> |
@@ -558,6 +594,22 @@ | ||
558 | 594 | </object> |
559 | 595 | <object class="IBConnectionRecord"> |
560 | 596 | <object class="IBBindingConnection" key="connection"> |
597 | + <string key="label">enabled: canPlay</string> | |
598 | + <reference key="source" ref="194457650"/> | |
599 | + <reference key="destination" ref="512844837"/> | |
600 | + <object class="NSNibBindingConnector" key="connector"> | |
601 | + <reference key="NSSource" ref="194457650"/> | |
602 | + <reference key="NSDestination" ref="512844837"/> | |
603 | + <string key="NSLabel">enabled: canPlay</string> | |
604 | + <string key="NSBinding">enabled</string> | |
605 | + <string key="NSKeyPath">canPlay</string> | |
606 | + <int key="NSNibBindingConnectorVersion">2</int> | |
607 | + </object> | |
608 | + </object> | |
609 | + <int key="connectionID">100785</int> | |
610 | + </object> | |
611 | + <object class="IBConnectionRecord"> | |
612 | + <object class="IBBindingConnection" key="connection"> | |
561 | 613 | <string key="label">value: player.muted</string> |
562 | 614 | <reference key="source" ref="872147288"/> |
563 | 615 | <reference key="destination" ref="512844837"/> |
@@ -572,6 +624,70 @@ | ||
572 | 624 | </object> |
573 | 625 | <int key="connectionID">100439</int> |
574 | 626 | </object> |
627 | + <object class="IBConnectionRecord"> | |
628 | + <object class="IBBindingConnection" key="connection"> | |
629 | + <string key="label">enabled: canPlay</string> | |
630 | + <reference key="source" ref="872147288"/> | |
631 | + <reference key="destination" ref="512844837"/> | |
632 | + <object class="NSNibBindingConnector" key="connector"> | |
633 | + <reference key="NSSource" ref="872147288"/> | |
634 | + <reference key="NSDestination" ref="512844837"/> | |
635 | + <string key="NSLabel">enabled: canPlay</string> | |
636 | + <string key="NSBinding">enabled</string> | |
637 | + <string key="NSKeyPath">canPlay</string> | |
638 | + <int key="NSNibBindingConnectorVersion">2</int> | |
639 | + </object> | |
640 | + </object> | |
641 | + <int key="connectionID">100784</int> | |
642 | + </object> | |
643 | + <object class="IBConnectionRecord"> | |
644 | + <object class="IBBindingConnection" key="connection"> | |
645 | + <string key="label">enabled: canPlay</string> | |
646 | + <reference key="source" ref="147538621"/> | |
647 | + <reference key="destination" ref="512844837"/> | |
648 | + <object class="NSNibBindingConnector" key="connector"> | |
649 | + <reference key="NSSource" ref="147538621"/> | |
650 | + <reference key="NSDestination" ref="512844837"/> | |
651 | + <string key="NSLabel">enabled: canPlay</string> | |
652 | + <string key="NSBinding">enabled</string> | |
653 | + <string key="NSKeyPath">canPlay</string> | |
654 | + <int key="NSNibBindingConnectorVersion">2</int> | |
655 | + </object> | |
656 | + </object> | |
657 | + <int key="connectionID">100783</int> | |
658 | + </object> | |
659 | + <object class="IBConnectionRecord"> | |
660 | + <object class="IBBindingConnection" key="connection"> | |
661 | + <string key="label">enabled: canPlay</string> | |
662 | + <reference key="source" ref="796465416"/> | |
663 | + <reference key="destination" ref="512844837"/> | |
664 | + <object class="NSNibBindingConnector" key="connector"> | |
665 | + <reference key="NSSource" ref="796465416"/> | |
666 | + <reference key="NSDestination" ref="512844837"/> | |
667 | + <string key="NSLabel">enabled: canPlay</string> | |
668 | + <string key="NSBinding">enabled</string> | |
669 | + <string key="NSKeyPath">canPlay</string> | |
670 | + <int key="NSNibBindingConnectorVersion">2</int> | |
671 | + </object> | |
672 | + </object> | |
673 | + <int key="connectionID">100782</int> | |
674 | + </object> | |
675 | + <object class="IBConnectionRecord"> | |
676 | + <object class="IBBindingConnection" key="connection"> | |
677 | + <string key="label">enabled: canPlay</string> | |
678 | + <reference key="source" ref="936500016"/> | |
679 | + <reference key="destination" ref="512844837"/> | |
680 | + <object class="NSNibBindingConnector" key="connector"> | |
681 | + <reference key="NSSource" ref="936500016"/> | |
682 | + <reference key="NSDestination" ref="512844837"/> | |
683 | + <string key="NSLabel">enabled: canPlay</string> | |
684 | + <string key="NSBinding">enabled</string> | |
685 | + <string key="NSKeyPath">canPlay</string> | |
686 | + <int key="NSNibBindingConnectorVersion">2</int> | |
687 | + </object> | |
688 | + </object> | |
689 | + <int key="connectionID">100781</int> | |
690 | + </object> | |
575 | 691 | </array> |
576 | 692 | <object class="IBMutableOrderedSet" key="objectRecords"> |
577 | 693 | <array key="orderedObjects"> |
@@ -1506,6 +1622,11 @@ | ||
1506 | 1622 | <reference key="object" ref="139574575"/> |
1507 | 1623 | <reference key="parent" ref="568628114"/> |
1508 | 1624 | </object> |
1625 | + <object class="IBObjectRecord"> | |
1626 | + <int key="objectID">100778</int> | |
1627 | + <reference key="object" ref="40310097"/> | |
1628 | + <reference key="parent" ref="0"/> | |
1629 | + </object> | |
1509 | 1630 | </array> |
1510 | 1631 | </object> |
1511 | 1632 | <dictionary class="NSMutableDictionary" key="flattenedProperties"> |
@@ -1614,6 +1735,7 @@ | ||
1614 | 1735 | <string key="100772.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> |
1615 | 1736 | <string key="100773.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> |
1616 | 1737 | <string key="100774.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> |
1738 | + <string key="100778.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> | |
1617 | 1739 | <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> |
1618 | 1740 | <string key="5.IBWindowTemplateEditedContentRect">{{133, 170}, {507, 413}}</string> |
1619 | 1741 | <array key="6.IBNSViewMetadataConstraints"> |
@@ -1643,7 +1765,7 @@ | ||
1643 | 1765 | <nil key="activeLocalization"/> |
1644 | 1766 | <dictionary class="NSMutableDictionary" key="localizations"/> |
1645 | 1767 | <nil key="sourceID"/> |
1646 | - <int key="maxID">100777</int> | |
1768 | + <int key="maxID">100788</int> | |
1647 | 1769 | </object> |
1648 | 1770 | <object class="IBClassDescriber" key="IBDocument.Classes"> |
1649 | 1771 | <array class="NSMutableArray" key="referencedPartialClassDescriptions"> |
@@ -1709,6 +1831,47 @@ | ||
1709 | 1831 | </object> |
1710 | 1832 | </object> |
1711 | 1833 | <object class="IBPartialClassDescription"> |
1834 | + <string key="className">NSDocument</string> | |
1835 | + <dictionary class="NSMutableDictionary" key="actions"> | |
1836 | + <string key="printDocument:">id</string> | |
1837 | + <string key="revertDocumentToSaved:">id</string> | |
1838 | + <string key="runPageLayout:">id</string> | |
1839 | + <string key="saveDocument:">id</string> | |
1840 | + <string key="saveDocumentAs:">id</string> | |
1841 | + <string key="saveDocumentTo:">id</string> | |
1842 | + </dictionary> | |
1843 | + <dictionary class="NSMutableDictionary" key="actionInfosByName"> | |
1844 | + <object class="IBActionInfo" key="printDocument:"> | |
1845 | + <string key="name">printDocument:</string> | |
1846 | + <string key="candidateClassName">id</string> | |
1847 | + </object> | |
1848 | + <object class="IBActionInfo" key="revertDocumentToSaved:"> | |
1849 | + <string key="name">revertDocumentToSaved:</string> | |
1850 | + <string key="candidateClassName">id</string> | |
1851 | + </object> | |
1852 | + <object class="IBActionInfo" key="runPageLayout:"> | |
1853 | + <string key="name">runPageLayout:</string> | |
1854 | + <string key="candidateClassName">id</string> | |
1855 | + </object> | |
1856 | + <object class="IBActionInfo" key="saveDocument:"> | |
1857 | + <string key="name">saveDocument:</string> | |
1858 | + <string key="candidateClassName">id</string> | |
1859 | + </object> | |
1860 | + <object class="IBActionInfo" key="saveDocumentAs:"> | |
1861 | + <string key="name">saveDocumentAs:</string> | |
1862 | + <string key="candidateClassName">id</string> | |
1863 | + </object> | |
1864 | + <object class="IBActionInfo" key="saveDocumentTo:"> | |
1865 | + <string key="name">saveDocumentTo:</string> | |
1866 | + <string key="candidateClassName">id</string> | |
1867 | + </object> | |
1868 | + </dictionary> | |
1869 | + <object class="IBClassDescriptionSource" key="sourceIdentifier"> | |
1870 | + <string key="majorKey">IBProjectSource</string> | |
1871 | + <string key="minorKey">./Classes/NSDocument.h</string> | |
1872 | + </object> | |
1873 | + </object> | |
1874 | + <object class="IBPartialClassDescription"> | |
1712 | 1875 | <string key="className">NSLayoutConstraint</string> |
1713 | 1876 | <string key="superclassName">NSObject</string> |
1714 | 1877 | <object class="IBClassDescriptionSource" key="sourceIdentifier"> |