Skip to content

Commit

Permalink
demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
libobjc committed Aug 15, 2019
1 parent 3348222 commit 7024879
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 41 deletions.
20 changes: 20 additions & 0 deletions demo/demo-common/SGVideoItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SGVideoItem.h
// demo-common
//
// Created by Single on 2017/3/15.
// Copyright © 2017年 single. All rights reserved.
//

#import <SGPlayer/SGPlayer.h>

@interface SGVideoItem : NSObject

@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) SGAsset *asset;
@property (nonatomic) SGDisplayMode displayMode;

+ (NSArray<SGVideoItem *> *)videoItems;

@end

39 changes: 39 additions & 0 deletions demo/demo-common/SGVideoItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// SGVideoItem.m
// demo-common
//
// Created by Single on 2017/3/15.
// Copyright © 2017年 single. All rights reserved.
//

#import "SGVideoItem.h"

@implementation SGVideoItem

+ (NSArray<SGVideoItem *> *)videoItems
{
NSURL *i_see_fire = [[NSBundle mainBundle] URLForResource:@"i-see-fire" withExtension:@"mp4"];
NSURL *google_help_vr = [[NSBundle mainBundle] URLForResource:@"google-help-vr" withExtension:@"mp4"];

NSMutableArray *items = [NSMutableArray array];
{
SGVideoItem *item = [[SGVideoItem alloc] init];
item.name = @"I See Fire";
item.asset = [[SGURLAsset alloc] initWithURL:i_see_fire];
item.displayMode = SGDisplayModePlane;
[items addObject:item];
}
{
SGVideoItem *item = [[SGVideoItem alloc] init];
item.name = @"Google Help VR";
item.asset = [[SGURLAsset alloc] initWithURL:google_help_vr];
item.displayMode = SGDisplayModeVR;
[items addObject:item];
}
//rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
//http://ivi.bupt.edu.cn/hls/cctv5phd.m3u8
//rtmp://live.hkstv.hk.lxdns.com/live/hks1
return items;
}

@end
27 changes: 21 additions & 6 deletions demo/demo-ios/demo-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
9C3DD16C1E8FBD420003B17A /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C3DD16B1E8FBD420003B17A /* VideoToolbox.framework */; };
9C3DD16E1E8FBD4A0003B17A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C3DD16D1E8FBD4A0003B17A /* AudioToolbox.framework */; };
9C3DD1701E8FBD4F0003B17A /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C3DD16F1E8FBD4F0003B17A /* CoreMedia.framework */; };
9C49E5F32304F77B00C5FB1F /* SGVideoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C49E5F12304F77B00C5FB1F /* SGVideoItem.m */; };
9C886B981E78EC9F00F2CFD1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C886B971E78EC9F00F2CFD1 /* main.m */; };
9C886B9B1E78EC9F00F2CFD1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C886B9A1E78EC9F00F2CFD1 /* AppDelegate.m */; };
9C886B9E1E78EC9F00F2CFD1 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C886B9D1E78EC9F00F2CFD1 /* ViewController.m */; };
9C886B9E1E78EC9F00F2CFD1 /* SGListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C886B9D1E78EC9F00F2CFD1 /* SGListViewController.m */; };
9C886BA11E78EC9F00F2CFD1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9C886B9F1E78EC9F00F2CFD1 /* Main.storyboard */; };
9C886BA31E78EC9F00F2CFD1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9C886BA21E78EC9F00F2CFD1 /* Assets.xcassets */; };
9C886BA61E78EC9F00F2CFD1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9C886BA41E78EC9F00F2CFD1 /* LaunchScreen.storyboard */; };
Expand All @@ -40,12 +41,14 @@
9C3DD16D1E8FBD4A0003B17A /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
9C3DD16F1E8FBD4F0003B17A /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
9C4032C41FAB1188005AEB36 /* SGPlayer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SGPlayer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9C49E5F12304F77B00C5FB1F /* SGVideoItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SGVideoItem.m; sourceTree = "<group>"; };
9C49E5F22304F77B00C5FB1F /* SGVideoItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGVideoItem.h; sourceTree = "<group>"; };
9C886B931E78EC9F00F2CFD1 /* SGPlayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SGPlayer.app; sourceTree = BUILT_PRODUCTS_DIR; };
9C886B971E78EC9F00F2CFD1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
9C886B991E78EC9F00F2CFD1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
9C886B9A1E78EC9F00F2CFD1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9C886B9C1E78EC9F00F2CFD1 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
9C886B9D1E78EC9F00F2CFD1 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
9C886B9C1E78EC9F00F2CFD1 /* SGListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGListViewController.h; sourceTree = "<group>"; };
9C886B9D1E78EC9F00F2CFD1 /* SGListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGListViewController.m; sourceTree = "<group>"; };
9C886BA01E78EC9F00F2CFD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
9C886BA21E78EC9F00F2CFD1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9C886BA51E78EC9F00F2CFD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -81,9 +84,20 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
9C49E5F02304F77B00C5FB1F /* demo-common */ = {
isa = PBXGroup;
children = (
9C49E5F22304F77B00C5FB1F /* SGVideoItem.h */,
9C49E5F12304F77B00C5FB1F /* SGVideoItem.m */,
);
name = "demo-common";
path = "../demo-common";
sourceTree = "<group>";
};
9C886B8A1E78EC9F00F2CFD1 = {
isa = PBXGroup;
children = (
9C49E5F02304F77B00C5FB1F /* demo-common */,
9C886B951E78EC9F00F2CFD1 /* demo-ios */,
9C886B941E78EC9F00F2CFD1 /* Products */,
9C886BAE1E78ECE500F2CFD1 /* Frameworks */,
Expand All @@ -103,8 +117,8 @@
children = (
9C886B991E78EC9F00F2CFD1 /* AppDelegate.h */,
9C886B9A1E78EC9F00F2CFD1 /* AppDelegate.m */,
9C886B9C1E78EC9F00F2CFD1 /* ViewController.h */,
9C886B9D1E78EC9F00F2CFD1 /* ViewController.m */,
9C886B9C1E78EC9F00F2CFD1 /* SGListViewController.h */,
9C886B9D1E78EC9F00F2CFD1 /* SGListViewController.m */,
9C02F64E1E79293A00932489 /* SGPlayViewController.h */,
9C03E5F2212E732B001F0E1B /* SGPlayViewController.m */,
9C02F6501E79293A00932489 /* SGPlayViewController.xib */,
Expand Down Expand Up @@ -233,8 +247,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9C886B9E1E78EC9F00F2CFD1 /* ViewController.m in Sources */,
9C886B9E1E78EC9F00F2CFD1 /* SGListViewController.m in Sources */,
9C03E5F3212E732B001F0E1B /* SGPlayViewController.m in Sources */,
9C49E5F32304F77B00C5FB1F /* SGVideoItem.m in Sources */,
9C886B9B1E78EC9F00F2CFD1 /* AppDelegate.m in Sources */,
9C886B981E78EC9F00F2CFD1 /* main.m in Sources */,
);
Expand Down
1 change: 0 additions & 1 deletion demo/demo-ios/demo-ios/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

@property (strong, nonatomic) UIWindow *window;


@end

10 changes: 5 additions & 5 deletions demo/demo-ios/demo-ios/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Kj3-RG-50E">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Kj3-RG-50E">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--SGPlayer-->
<scene sceneID="O56-9X-n8a">
<objects>
<tableViewController id="JJz-Ax-uSc" customClass="ViewController" sceneMemberID="viewController">
<tableViewController id="JJz-Ax-uSc" customClass="SGListViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="IR7-Rq-qmw">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -22,7 +22,7 @@
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZOb-NY-ggN" id="W1E-TW-hEv">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
Expand All @@ -43,7 +43,7 @@
<objects>
<navigationController id="Kj3-RG-50E" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="Xor-1P-YTU">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ViewController.h
// SGListViewController.h
// demo-ios
//
// Created by Single on 2017/3/15.
Expand All @@ -8,7 +8,7 @@

#import <UIKit/UIKit.h>

@interface ViewController : UITableViewController
@interface SGListViewController : UITableViewController

@end

Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
//
// ViewController.m
// SGListViewController.m
// demo-ios
//
// Created by Single on 2017/3/15.
// Copyright © 2017年 single. All rights reserved.
//

#import "ViewController.h"
#import "SGListViewController.h"
#import "SGPlayViewController.h"
#import "SGVideoItem.h"

@implementation ViewController
@interface SGListViewController ()

@property (nonatomic, strong) NSArray<SGVideoItem *> *videoItems;

@end

@implementation SGListViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.videoItems = [SGVideoItem videoItems];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
Expand All @@ -18,39 +43,21 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
return self.videoItems.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = @"Demo";
cell.textLabel.text = self.videoItems[indexPath.row].name;
return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
/*
rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
http://ivi.bupt.edu.cn/hls/cctv5phd.m3u8
rtmp://live.hkstv.hk.lxdns.com/live/hks1
*/
NSURL *URL = [[NSBundle mainBundle] URLForResource:@"i-see-fire" withExtension:@"mp4"];
SGPlayViewController *vc = [[SGPlayViewController alloc] init];
vc.asset = [[SGURLAsset alloc] initWithURL:URL];
vc.videoItem = self.videoItems[indexPath.row];
[self.navigationController pushViewController:vc animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

@end
4 changes: 2 additions & 2 deletions demo/demo-ios/demo-ios/SGPlayViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//

#import <UIKit/UIKit.h>
#import <SGPlayer/SGPlayer.h>
#import "SGVideoItem.h"

@interface SGPlayViewController : UIViewController

@property (nonatomic, strong) SGAsset *asset;
@property (nonatomic, strong) SGVideoItem *videoItem;

@end
3 changes: 2 additions & 1 deletion demo/demo-ios/demo-ios/SGPlayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ - (void)viewDidLoad
[super viewDidLoad];

self.player.videoRenderer.view = self.view;
[self.player replaceWithAsset:self.asset];
self.player.videoRenderer.displayMode = self.videoItem.displayMode;
[self.player replaceWithAsset:self.videoItem.asset];
[self.player play];
}

Expand Down

0 comments on commit 7024879

Please sign in to comment.