Skip to content

Commit

Permalink
video player improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed May 30, 2024
1 parent 96cbaab commit d0ce0d7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
10 changes: 6 additions & 4 deletions Osmium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
13177F4E2C0645FF00E4CECA /* Other.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13177F4B2C0645FF00E4CECA /* Other.swift */; };
13177F4F2C0645FF00E4CECA /* Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13177F4C2C0645FF00E4CECA /* Video.swift */; };
13177F512C06460500E4CECA /* AboutPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13177F502C06460500E4CECA /* AboutPage.swift */; };
13177F542C07547900E4CECA /* MediaClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13177F532C07547900E4CECA /* MediaClass.swift */; };
13177F542C07547900E4CECA /* VideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13177F532C07547900E4CECA /* VideoPlayer.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -33,7 +33,7 @@
13177F4B2C0645FF00E4CECA /* Other.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Other.swift; sourceTree = "<group>"; };
13177F4C2C0645FF00E4CECA /* Video.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Video.swift; sourceTree = "<group>"; };
13177F502C06460500E4CECA /* AboutPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutPage.swift; sourceTree = "<group>"; };
13177F532C07547900E4CECA /* MediaClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaClass.swift; sourceTree = "<group>"; };
13177F532C07547900E4CECA /* VideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayer.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -101,7 +101,7 @@
13177F522C07546D00E4CECA /* Player */ = {
isa = PBXGroup;
children = (
13177F532C07547900E4CECA /* MediaClass.swift */,
13177F532C07547900E4CECA /* VideoPlayer.swift */,
);
path = Player;
sourceTree = "<group>";
Expand Down Expand Up @@ -178,7 +178,7 @@
buildActionMask = 2147483647;
files = (
13177F4D2C0645FF00E4CECA /* Audio.swift in Sources */,
13177F542C07547900E4CECA /* MediaClass.swift in Sources */,
13177F542C07547900E4CECA /* VideoPlayer.swift in Sources */,
13177F4F2C0645FF00E4CECA /* Video.swift in Sources */,
13177F372C0645A900E4CECA /* ViewController.swift in Sources */,
13177F332C0645A900E4CECA /* AppDelegate.swift in Sources */,
Expand Down Expand Up @@ -331,6 +331,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
Expand Down Expand Up @@ -360,6 +361,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
Expand Down
6 changes: 3 additions & 3 deletions Osmium/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
<rect key="frame" x="0.0" y="0.0" width="359.33333333333331" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="volume.3.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="9hK-SX-yff">
<rect key="frame" x="10" y="8" width="30" height="28"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="speaker.wave.2.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="9hK-SX-yff">
<rect key="frame" x="10" y="8.9999999999999982" width="30" height="26.333333333333329"/>
<color key="tintColor" name="AccentColor"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="GAq-kb-fPj"/>
Expand Down Expand Up @@ -1076,8 +1076,8 @@ Some services don’t support rich file names and always use the classic style.<
<image name="play.rectangle.fill" catalog="system" width="128" height="93"/>
<image name="play.rectangle.on.rectangle.fill" catalog="system" width="128" height="97"/>
<image name="slider.horizontal.3" catalog="system" width="128" height="100"/>
<image name="speaker.wave.2.fill" catalog="system" width="128" height="90"/>
<image name="trash.fill" catalog="system" width="121" height="128"/>
<image name="volume.3.fill" catalog="system" width="128" height="86"/>
<namedColor name="AccentColor">
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Expand Down
18 changes: 2 additions & 16 deletions Osmium/Player/MediaClass.swift → Osmium/Player/VideoPlayer.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MediaClass.swift
// VideoPlayer.swift
// Osmium
//
// Created by Francesco on 29/05/24.
Expand All @@ -9,7 +9,7 @@ import UIKit
import AVKit
import MobileCoreServices

class VideoPlayerViewController: UIViewController {
class VideoPlayerViewController: UIViewController, AVPictureInPictureControllerDelegate {

@IBOutlet weak var videoView: UIView!

Expand Down Expand Up @@ -87,17 +87,3 @@ extension VideoPlayerViewController: UIDocumentPickerDelegate {
dismiss(animated: true, completion: nil)
}
}

extension VideoPlayerViewController: AVPictureInPictureControllerDelegate {
func pictureInPictureControllerDidStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
print("PiP started")
}

func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
print("PiP will stop")
}

func pictureInPictureControllerDidStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
print("PiP stopped")
}
}
2 changes: 1 addition & 1 deletion Osmium/Settings/Video.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Video: UITableViewController {
@IBOutlet weak var Quality: UIButton!

var isPresentingActionSheet = false
var selectedQualityIndex = 4
var selectedQualityIndex = 5
let choices = ["8k+", "4k", "1440p", "1080p", "720p", "480p", "360p", "240p", "144p"]

@IBOutlet weak var codecControll: UISegmentedControl!
Expand Down
4 changes: 1 addition & 3 deletions Osmium/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ class ViewController: UIViewController, UITextFieldDelegate {
return
}

// Create the request
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData

// Perform the request
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
self.writeToConsole("Error: \(error)")
Expand All @@ -144,7 +142,6 @@ class ViewController: UIViewController, UITextFieldDelegate {
return
}

// Handle the response
if let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let mediaURLString = json["url"] as? String {
self.openURLInSafari(urlString: mediaURLString)
Expand All @@ -164,6 +161,7 @@ class ViewController: UIViewController, UITextFieldDelegate {
}
DispatchQueue.main.async {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
self.writeToConsole("Done!")
}
}

Expand Down

0 comments on commit d0ce0d7

Please sign in to comment.