diff --git a/.idea/kplayer.iml b/.idea/kplayer.iml
index 4cf9904..3e4db0f 100644
--- a/.idea/kplayer.iml
+++ b/.idea/kplayer.iml
@@ -38,6 +38,7 @@
+
diff --git a/kplayer.xcodeproj/project.pbxproj b/kplayer.xcodeproj/project.pbxproj
index 934f774..731a24d 100644
--- a/kplayer.xcodeproj/project.pbxproj
+++ b/kplayer.xcodeproj/project.pbxproj
@@ -12,6 +12,7 @@
1C73640D928DE56D35175D39 /* UploadOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736260E748CF136FF37EA7 /* UploadOperation.swift */; };
1C73646F87B495A47D7943C7 /* NetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7369EC16B19B32B515169E /* NetData.swift */; };
1C736503B656C999E5E12081 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7365B06FA66294E99AC2D3 /* NetworkManager.swift */; };
+ 1C73651E1241702E5032A8A4 /* scratch.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1C736E3BE8EC464D6F5DC8FA /* scratch.txt */; };
1C73654C9EA6D255CFC039C5 /* NetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73620D01687FB4F1811C5C /* NetworkHelper.swift */; };
1C7365885FAF292F2221ED44 /* MediaPhotoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73673DC671535E3A049F54 /* MediaPhotoController.swift */; };
1C73675C34BE0990D44570BE /* ItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736253AB7A95EA41B605B7 /* ItemModel.swift */; };
@@ -69,6 +70,7 @@
1C736BC4450890C45F8FBC63 /* LayoutTools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutTools.swift; sourceTree = ""; };
1C736D9BB5498E7E8F11C754 /* HeaderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderCell.swift; sourceTree = ""; };
1C736DCCE3AA9993E15F7652 /* UIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = ""; };
+ 1C736E3BE8EC464D6F5DC8FA /* scratch.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = scratch.txt; sourceTree = ""; };
1C736F9338CE36708244D42A /* DataLoadOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataLoadOperation.swift; sourceTree = ""; };
5C6CBA548F885BF342F594EA /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; };
A170BFB886D61D57F7009BFC /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; };
@@ -211,6 +213,7 @@
1C73615846EE8B07DAAFD230 /* detail */,
1C7364808E72BFA7575E75E1 /* master */,
1C7363B608460DED4F522D1C /* photo */,
+ 1C736E3BE8EC464D6F5DC8FA /* scratch.txt */,
);
path = kplayer;
sourceTree = "";
@@ -330,6 +333,7 @@
C98AF5E41B124D6A00D196CC /* LaunchScreen.xib in Resources */,
C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */,
1C736A5FA5BA53B2597F2ED7 /* Kirschkeks-256x256.png in Resources */,
+ 1C73651E1241702E5032A8A4 /* scratch.txt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/kplayer/core/MediaItem.swift b/kplayer/core/MediaItem.swift
index dde18e3..0d968a6 100644
--- a/kplayer/core/MediaItem.swift
+++ b/kplayer/core/MediaItem.swift
@@ -146,8 +146,15 @@ class MediaItem: CustomDebugStringConvertible {
}
var playerURL: NSURL? {
- let enc = "/" + name.stringByReplacingOccurrencesOfString(" ", withString: "%20")
- return NSURL(string: NetworkManager.sharedInstance.baseurl + "/service/stream" + encodedDir! + enc)
+ let enc = name.stringByReplacingOccurrencesOfString(" ", withString: "%20")
+ let s = NetworkManager.sharedInstance.baseurl + "/service/stream" + encodedDir!
+
+ if s.endsWith("/") {
+ return NSURL(string: s + enc)
+ }
+ else {
+ return NSURL(string: s + "/" + enc)
+ }
}
/**
diff --git a/kplayer/detail/DetailViewController.swift b/kplayer/detail/DetailViewController.swift
index 422754b..e9fb054 100644
--- a/kplayer/detail/DetailViewController.swift
+++ b/kplayer/detail/DetailViewController.swift
@@ -123,13 +123,10 @@ class DetailViewController: UIViewController, UICollectionViewDelegateFlowLayout
if let detail: MediaItem = self.detailItem {
if i.type == ItemType.VIDEO {
-
- if i.parent!.type != ItemType.DETAILS {
- let path = NSIndexPath(forItem: index, inSection: i.parent!.index)
- self.collectionView.reloadItemsAtIndexPaths([path])
- }
-
-
+ if i.parent!.type != ItemType.DETAILS {
+ let path = NSIndexPath(forItem: index, inSection: i.parent!.index)
+ self.collectionView.reloadItemsAtIndexPaths([path])
+ }
} else {
if i.parent! !== detail {
return
@@ -257,7 +254,7 @@ class DetailViewController: UIViewController, UICollectionViewDelegateFlowLayout
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
if let detail: MediaItem = self.detailItem {
var items = detail.children[indexPath.section]
- if (items.loaded) {
+ if (items.type == ItemType.VIDEO || items.loaded) {
if indexPath.item >= items.children.count {
print(items.name)
} else {
@@ -268,7 +265,7 @@ class DetailViewController: UIViewController, UICollectionViewDelegateFlowLayout
self.currentItem = items
}
- if items.type == ItemType.VIDEO {
+ if items.type == ItemType.VIDEO || items.type == ItemType.SNAPSHOT {
performSegueWithIdentifier("showVideo", sender: self)
}
else {
@@ -348,10 +345,14 @@ class DetailViewController: UIViewController, UICollectionViewDelegateFlowLayout
self.collectionView.reloadData()
self.collectionView.collectionViewLayout.invalidateLayout()
- if self.currentItem!.type == ItemType.SNAPSHOT {
- self.currentItem = self.currentItem!.parent
+ if let ci = self.currentItem {
+ if ci.type == ItemType.SNAPSHOT {
+ self.currentItem = ci.parent
+ }
+ }
+ if let ci = self.currentItem {
+ NetworkManager.sharedInstance.saveItem(ci)
}
- NetworkManager.sharedInstance.saveItem(self.currentItem!)
self.dismissViewControllerAnimated(true, completion: nil);
}
}