This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AuthProvider | |
import FluentProvider | |
import HTTP | |
import Vapor | |
extension User: ResponseRepresentable {} | |
extension User: Timestampable {} | |
final class User: Model { | |
let storage = Storage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import FluentProvider | |
import HTTP | |
final class Pet: Model { | |
let storage = Storage() | |
var name: String | |
static let idKey = "id" | |
static let nameKey = "name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import FluentProvider | |
import HTTP | |
final class User: Model { | |
let storage = Storage() | |
var name: String | |
static let idKey = "id" | |
static let nameKey = "name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Vapor | |
import HTTP | |
import AuthProvider | |
import JWT | |
final class ExampleUsersController { | |
private let droplet: Droplet | |
init(droplet: Droplet) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ExampleUser: ResponseRepresentable {} | |
extension ExampleUser: Timestampable {} | |
final class ExampleUser: Model, PasswordAuthenticatable { | |
let storage = Storage() | |
public static let hasher = BCryptHasher(cost: 10) | |
static let nameKey = "email" // Vapor expects this to be set to email, even though it is the username | |
static let passwordKey = "password" | |
static let confirmPasswordKey = "confirmPassword" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PART 1 | |
So basically, for me the trick to getting this done is to move the video playing outside the cell, meaning outside cellForRowAtIndexPath. For my video, i had it auto play once the table view stopped scrolling, but if you want it to auto play while scrolling, I think that is possible as well, and I'll discuss how a little later. But first some code. | |
For the time being, I will assume the videos are not coming from a server (in my case they did, and I can cover that too if you want, just you didn't specify in the beginning so I won't immediately get complicated). | |
First, you will need a preview image--an image of the first frame of the video. This will be set in cellForRowAtIndexPath: | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
VideoCell *cell = (VideoCell *)[[self.tableView dequeueReusableCellWithIdentifier:@"cellReuseId"]] | |
// asynchronously download and set image: | |
YourObject *image = self.yourDataSourceArray[indexPath.row].im |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Part1. | |
First, make a file, subclassing NSObject. Call it Download. In the .h file, put this: | |
@property (strong, nonatomic)NSString *url; | |
@property BOOL isDownloading; | |
@property float progress; | |
@property (strong, nonatomic)NSURLSessionDownloadTask *downloadTask; | |
Leave the .m file empty. | |
Now to the view controller. So basically, for me the trick to getting this done is to move the video playing outside the cell, meaning outside cellForRowAtIndexPath. For my video, i had it auto play once the table view stopped scrolling, but if you want it to auto play while scrolling, I think that is possible as well, and I'll discuss how a little later. But first some code. | |
First, you will need a preview image--an image of the first frame of the video. This will be set in cellForRowAtIndexPath: | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath *)indexPath { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
VideoCell *videoCell = (VideoCell *)[self.tableView dequeueReusableCellWithIdentifier:@"VideoCell"]; | |
NSString *urlString = @"streaming://download.wavetlan.com/SVV/Media/HTTP/MOV/ConvertedFiles/MediaCoder/MediaCoder_test11_36s_H263_VBR_590kbps_176x144_25fps_MPEG1Layer3_CBR_160kbps_Stereo_22050Hz.mov"; | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); | |
// Configure Video Cell Here: | |
NSURL *url = [NSURL URLWithString:urlString]; | |
videoCell.contentView.backgroundColor = [UIColor clearColor]; | |
videoCell.backgroundColor = [UIColor clearColor]; |