浏览代码

set Audio (mute) video

marinofaggiana 4 年之前
父节点
当前提交
21cfc118d9

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1047,9 +1047,9 @@
 		F78ACD50219046AC0088454D /* Section Header Footer */ = {
 			isa = PBXGroup;
 			children = (
+				F78ACD53219047D40088454D /* NCSectionFooter.xib */,
 				F78ACD51219046DC0088454D /* NCSectionHeaderFooter.swift */,
 				F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */,
-				F78ACD53219047D40088454D /* NCSectionFooter.xib */,
 			);
 			path = "Section Header Footer";
 			sourceTree = "<group>";

+ 15 - 0
iOSClient/Images.xcassets/audioOff.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "audioOff.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 53 - 0
iOSClient/Images.xcassets/audioOff.imageset/audioOff.pdf

@@ -0,0 +1,53 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201031065104+00'00')
+/ModDate (D:20201031065104+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 174>> stream
+xœmNK1Ýs
+Ö&"Ж¶'píÊ?‹õþ‰´u̘I߃Â{�†ÚÙsK«RqÁÓh"Fæ‘lMŸg8nðî3‘Š‰kWú­\d·x}A"È"{ΠBÁ:—º°	œ×Ô¹2å²tÝߨ„A•ú^rÌTIú­Š¤Òl&â&ê—M¯é²Ñ�jFòñ¶Rä¡‘)å±÷™žà8x¾‡BL
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 28.08 28.08]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000582 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000774 00000 n 
+0000000829 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+876
+%%EOF

+ 15 - 0
iOSClient/Images.xcassets/audioOn.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "audioOn.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 52 - 0
iOSClient/Images.xcassets/audioOn.imageset/audioOn.pdf

@@ -0,0 +1,52 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201031060355+00'00')
+/ModDate (D:20201031060355+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 232>> stream
+xœU�MnÄ0…÷>ëJC
Ž
9Á¬»šXýY4•ÚÞ_ꃸÕÔ–‚	�Çg³¶=Uìߥê\�æQ>KÔD¬>î�_Ïåö@ÐlìCDª¦Óÿ&�×F¯ßE6jBGœ:ëNïnî9t°ôŠ%$;9»ž,HDi–ˆ�Å–ä¯MŒ}#Šó*Îð×Êf1Àa ¬hvª‡Î2kDc“°ƒØÁ/m
_Ä38{¨�uª¬	؃ªƒ×$ÔÆ{B´BF„@ò¾goc¼Ï¯ë,�vx7èÐag@Aë·üÖòûV^ÊöÄßVì
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 28.08 28.08]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000640 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000832 00000 n 
+0000000887 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+934
+%%EOF

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -173,6 +173,9 @@
 + (NSInteger)getLogLevel;
 + (void)setLogLevel:(NSInteger)value;
 
++ (BOOL)getAudioMute;
++ (void)setAudioMute:(BOOL)set;
+
 // ===== Varius =====
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 11 - 0
iOSClient/Utility/CCUtility.m

@@ -707,6 +707,17 @@
     [UICKeyChainStore setString:valueString forKey:@"logLevel" service:k_serviceShareKeyChain];
 }
 
++ (BOOL)getAudioMute
+{
+    return [[UICKeyChainStore stringForKey:@"audioMute" service:k_serviceShareKeyChain] boolValue];
+}
+
++ (void)setAudioMute:(BOOL)set
+{
+    NSString *sSet = (set) ? @"true" : @"false";
+    [UICKeyChainStore setString:sSet forKey:@"audioMute" service:k_serviceShareKeyChain];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------

+ 3 - 0
iOSClient/Viewer/NCViewerImage/NCViewerImage.storyboard

@@ -37,6 +37,8 @@
                                 <rect key="frame" x="0.0" y="813" width="414" height="49"/>
                                 <items>
                                     <barButtonItem systemItem="play" id="hHF-Q3-tyB"/>
+                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="tYH-bL-I0G"/>
+                                    <barButtonItem image="audioOn" id="6mg-K7-nwa"/>
                                 </items>
                             </toolbar>
                         </subviews>
@@ -148,6 +150,7 @@
     </scenes>
     <resources>
         <image name="1" width="320" height="206"/>
+        <image name="audioOn" width="28" height="28"/>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>

+ 34 - 10
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -108,6 +108,8 @@ class NCViewerImage: UIViewController {
         progressView.tintColor = NCBrandColor.sharedInstance.brandElement
         progressView.trackTintColor = .clear
         progressView.progress = 0
+        
+        setToolBar()
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -398,6 +400,7 @@ class NCViewerImage: UIViewController {
         if let url = videoURL {
             
             player = AVPlayer(url: url)
+            player?.isMuted = CCUtility.getAudioMute()
             videoLayer = AVPlayerLayer(player: player)
             
             if videoLayer != nil && currentViewerImageZoom != nil {
@@ -460,23 +463,44 @@ class NCViewerImage: UIViewController {
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
         
         if keyPath != nil && keyPath == "rate" {
-            
-            if player?.rate == 1 {
-                print("start")
-                let item = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.pause, target: self, action: #selector(playerPause))
-                toolBar.setItems([item], animated: true)
-            } else {
-                print("pause")
-                let item = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.play, target: self, action: #selector(playerPlay))
-                toolBar.setItems([item], animated: true)
-            }
+           setToolBar()
         }
     }
     
+    //MARK: - Tool Bar
+
+    func setToolBar() {
+        
+        let mute = CCUtility.getAudioMute()
+        
+        var itemPlay = toolBar.items![0]
+        let itemFlexibleSpace = toolBar.items![1]
+        var itemMute = toolBar.items![2]
+        
+        if player?.rate == 1 {
+            itemPlay = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.pause, target: self, action: #selector(playerPause))
+        } else {
+            itemPlay = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.play, target: self, action: #selector(playerPlay))
+        }
+        if mute {
+            itemMute = UIBarButtonItem(image: UIImage(named: "audioOff"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(SetMute))
+        } else {
+            itemMute = UIBarButtonItem(image: UIImage(named: "audioOn"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(SetMute))
+        }
+        toolBar.setItems([itemPlay, itemFlexibleSpace, itemMute], animated: true)
+    }
+
     @objc func playerPause() { player?.pause() }
     @objc func playerPlay() { player?.play() }
+    @objc func SetMute() {
+        let mute = CCUtility.getAudioMute()
+        CCUtility.setAudioMute(!mute)
+        player?.isMuted = !mute
+        setToolBar()
+    }
 }
 
+
 //MARK: - UIPageViewController Delegate Datasource
 
 extension NCViewerImage: UIPageViewControllerDelegate, UIPageViewControllerDataSource {

+ 5 - 0
iOSClient/Viewer/NCViewerVideo/NCViewerVideo.swift

@@ -80,12 +80,17 @@ protocol NCViewerVideoDelegate {
                 player?.seek(to: seekTime!)
                 seekTime = nil
             }
+            player?.isMuted = CCUtility.getAudioMute()
         }
     }
     
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         
+        if let player = self.player {
+            CCUtility.setAudioMute(player.isMuted)
+        }
+        
         if !pictureInPicture {
             player?.pause()