     func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
         return UIEdgeInsetsZero
     }
+
+
+    func scrollViewDidScroll(scrollView: UIScrollView) {
+
+        let currentIndex = Int(scrollView.contentOffset.x / scrollView.frame.width)
+
+        let indexPath = NSIndexPath(forItem: currentIndex, inSection: 0)
+
+        guard let cell = mediasCollectionView.cellForItemAtIndexPath(indexPath) as? MediaViewCell else {
+            return
+        }
+
+        let previewMedia = previewMedias[currentIndex]
+
+        prepareForShareWithCell(cell, previewMedia: previewMedia)
+    }
+
+    private func prepareForShareWithCell(cell: MediaViewCell, previewMedia: PreviewMedia) {
+
+        switch previewMedia {
+
+        case .MessageType(let message):
+
+            switch message.mediaType {
+
+            case MessageMediaType.Image.rawValue:
+
+                mediaControlView.type = .Image
+
+                if
+                    let imageFileURL = NSFileManager.yepMessageImageURLWithName(message.localAttachmentName),
+                    let image = UIImage(contentsOfFile: imageFileURL.path!) {
+
+                        mediaControlView.shareAction = {
+
+                            let info = MonkeyKing.Info(
+                                title: nil,
+                                description: nil,
+                                thumbnail: nil,
+                                media: .Image(image)
+                            )
+
+                            let sessionMessage = MonkeyKing.Message.WeChat(.Session(info: info))
+
+                            let weChatSessionActivity = WeChatActivity(
+                                type: .Session,
+                                message: sessionMessage,
+                                finish: { success in
+                                    println("share Image to WeChat Session success: \(success)")
+                                }
+                            )
+
+                            let timelineMessage = MonkeyKing.Message.WeChat(.Timeline(info: info))
+
+                            let weChatTimelineActivity = WeChatActivity(
+                                type: .Timeline,
+                                message: timelineMessage,
+                                finish: { success in
+                                    println("share Image to WeChat Timeline success: \(success)")
+                                }
+                            )
+
+                            let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: [weChatSessionActivity, weChatTimelineActivity])
+
+                            self.presentViewController(activityViewController, animated: true, completion: nil)
+                        }
+                }
+
+            case MessageMediaType.Video.rawValue:
+
+                mediaControlView.type = .Video
+                mediaControlView.playState = .Playing
+
+                if
+                    let imageFileURL = NSFileManager.yepMessageImageURLWithName(message.localThumbnailName),
+                    let image = UIImage(contentsOfFile: imageFileURL.path!) {
+                        cell.mediaView.image = image
+                }
+
+                if
+                    let videoFileURL = NSFileManager.yepMessageVideoURLWithName(message.localAttachmentName) {
+                        let asset = AVURLAsset(URL: videoFileURL, options: [:])
+                        let playerItem = AVPlayerItem(asset: asset)
+
+                        //let x = NSFileManager.defaultManager().fileExistsAtPath(videoFileURL.path!)
+
+                        playerItem.seekToTime(kCMTimeZero)
+                        //mediaView.videoPlayerLayer.player.replaceCurrentItemWithPlayerItem(playerItem)
+                        let player = AVPlayer(playerItem: playerItem)
+
+                        mediaControlView.timeLabel.text = ""
+
+                        player.addPeriodicTimeObserverForInterval(CMTimeMakeWithSeconds(0.1, Int32(NSEC_PER_SEC)), queue: nil, usingBlock: { time in
+
+                            guard let currentItem = player.currentItem else {
+                                return
+                            }
+
+                            if currentItem.status == .ReadyToPlay {
+                                let durationSeconds = CMTimeGetSeconds(currentItem.duration)
+                                let currentSeconds = CMTimeGetSeconds(time)
+                                let coundDownTime = Double(Int((durationSeconds - currentSeconds) * 10)) / 10
+                                self.mediaControlView.timeLabel.text = "\(coundDownTime)"
+                            }
+                        })
+
+                        NSNotificationCenter.defaultCenter().addObserver(self, selector: "playerItemDidReachEnd:", name: AVPlayerItemDidPlayToEndTimeNotification, object: player.currentItem)
+
+                        mediaControlView.playAction = { mediaControlView in
+                            player.play()
+
+                            mediaControlView.playState = .Playing
+                        }
+
+                        mediaControlView.pauseAction = { mediaControlView in
+                            player.pause()
+
+                            mediaControlView.playState = .Pause
+                        }
+
+                        cell.mediaView.videoPlayerLayer.player = player
+
+                        cell.mediaView.videoPlayerLayer.player?.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
+
+                        //mediaView.videoPlayerLayer.player.play()
+                        //mediaView.imageView.removeFromSuperview()
+
+                        mediaControlView.shareAction = {
+                            let activityViewController = UIActivityViewController(activityItems: [videoFileURL], applicationActivities: nil)
+
+                            self.presentViewController(activityViewController, animated: true, completion: { () -> Void in
+                            })
+                        }
+                }
+
+            default:
+                break
+            }
+
+        case .AttachmentType:
+
+            guard let image = cell.mediaView.image else {
+                return
+            }
+
+            mediaControlView.type = .Image
+
+            mediaControlView.shareAction = { [weak self] in
+
+                let info = MonkeyKing.Info(
+                    title: nil,
+                    description: nil,
+                    thumbnail: nil,
+                    media: .Image(image)
+                )
+
+                let sessionMessage = MonkeyKing.Message.WeChat(.Session(info: info))
+
+                let weChatSessionActivity = WeChatActivity(
+                    type: .Session,
+                    message: sessionMessage,
+                    finish: { success in
+                        println("share Image to WeChat Session success: \(success)")
+                    }
+                )
+
+                let timelineMessage = MonkeyKing.Message.WeChat(.Timeline(info: info))
+
+                let weChatTimelineActivity = WeChatActivity(
+                    type: .Timeline,
+                    message: timelineMessage,
+                    finish: { success in
+                        println("share Image to WeChat Timeline success: \(success)")
+                    }
+                )
+
+                let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: [weChatSessionActivity, weChatTimelineActivity])
+                
+                self?.presentViewController(activityViewController, animated: true, completion: nil)
+            }
+        }
+    }
 }
 


            mediaControlView.type = .Image

            cell.mediaView.helperImageView.kf_setImageWithURL(imageURL, placeholderImage: nil, optionsInfo: nil, completionHandler: { [weak self] (image, error, cacheType, imageURL) in

                guard let image = image else {
                    return
                }

                cell.mediaView.image = image
                //println("image.size: \(image.size)")

                //cell.mediaView.updateImageViewWithImage(image)

                /*
                self?.mediaControlView.shareAction = {

                    let info = MonkeyKing.Info(
                        title: nil,
                        description: nil,
                        thumbnail: nil,
                        media: .Image(image)
                    )

                    let sessionMessage = MonkeyKing.Message.WeChat(.Session(info: info))

                    let weChatSessionActivity = WeChatActivity(
                        type: .Session,
                        message: sessionMessage,
                        finish: { success in
                            println("share Image to WeChat Session success: \(success)")
                        }
                    )
                    
                    let timelineMessage = MonkeyKing.Message.WeChat(.Timeline(info: info))
                    
                    let weChatTimelineActivity = WeChatActivity(
                        type: .Timeline,
                        message: timelineMessage,
                        finish: { success in
                            println("share Image to WeChat Timeline success: \(success)")
                        }
                    )
                    
                    let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: [weChatSessionActivity, weChatTimelineActivity])
                    
                    self?.presentViewController(activityViewController, animated: true, completion: nil)
                }
                */
            })
        }
    }

//                    }
//                }
//            }
//        }
    }

    func playerItemDidReachEnd(notification: NSNotification) {
