我正在使用视频播放器应用程序,我使用let showMerchantInfoUrl=NSURL(string:"http://www.someurlhere.com")
let showMerchantInfoRequest=NSMutableURLRequest(URL:showMerchantInfoUrl!)
showMerchantInfoRequest.HTTPMethod="POST"
let showMerchantInfoString="token=\(KeychainWrapper.stringForKey("tokenValue")!)";
showMerchantInfoRequest.HTTPBody=showMerchantInfoString.dataUsingEncoding(NSUTF8StringEncoding)
//send the request
let task=NSURLSession.sharedSession().dataTaskWithRequest(showMerchantInfoRequest) {
data, response, error in
if error != nil {
print("error=\(error)")
return
}
do {
let json=try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
if let parseJSON=json {
let codeValue = parseJSON["code"] as? Int
let msgValue = parseJSON["msg"] as? String
if codeValue! == 1 {
print(json)
dispatch_async(dispatch_get_main_queue(), {
if let retDictionary = parseJSON["ret"]!["info"] as? NSDictionary {
self.shopName.text = retDictionary.valueForKey("mer_name") as? String
if retDictionary.valueForKey("mer_name") as? String != nil {
KeychainWrapper.setString(self.shopName.text!, forKey: "shopName")
self.totalCouponsTaken.text = String(self.nullToZero(retDictionary.valueForKey("visits"))!) + "人"
self.unusedCoupons.text = String(self.nullToZero(retDictionary.valueForKey("coupon_not_used_yet"))!) + "人"
self.totalCouponsTaken.text = String(self.nullToZero(retDictionary.valueForKey("coupon_taken_total_numbers"))!) + "人"
self.merchantRatingCV.rating = Double(self.nullToZero(retDictionary.valueForKey("star"))! as! NSNumber)
KeychainWrapper.setString(String(self.nullToZero(retDictionary.valueForKey("star"))!), forKey: "shopRating")
self.merchantRatingCV.text = String(self.nullToZero(retDictionary.valueForKey("star"))!)
}
}
if let retAlbumArray = parseJSON["ret"]!["album"] as? NSArray {
print("REEET :\(retAlbumArray)")
self.albumImagePathArray = retAlbumArray.flatMap({ element in
(element["mer_thumb"] as? String)!
})
self.albumImageID = retAlbumArray.flatMap({ element in (element["album_id"] as? String)! })
self.coverableArray = retAlbumArray.flatMap({ element in
(element["coverable"] as? String)!
})
for i in 0 ..< self.albumImagePathArray.count {
let request: NSURLRequest = NSURLRequest(URL: NSURL(string: self.albumImagePathArray[i])!)
let mainQueue = NSOperationQueue.mainQueue()
NSURLConnection.sendAsynchronousRequest(request, queue: mainQueue, completionHandler: { (response, data, error) -> Void in
print("asdfasdfasdfasfdasfasdf")
if error == nil {
let image = UIImage(data: data!)
self.albumImages.append(image!)
}
else { print(error) }
})
}
if self.albumImages.count >= self.maximumImagesAllowed {
disableAdditionOfImages=true
}
else {
self.albumImages.append(UIImage(named:"Plus.png")!)
}
if self.disableAdditionOfAlbumImages == false && self.albumImages.count > 1 {
let bannerPhoto=self.albumImages[0]
self.bannerImage.image = bannerPhoto
}
UIView.performWithoutAnimation {
self.albumCollectionView?.reloadData()
self.activeIndicator.stopAnimating()
}
if self.albumImagePathArray==[] {
self.activeIndicator.stopAnimating()
}
}
else {
self.activeIndicator.stopAnimating()
}
if codeValue!==1
{
print(json)
}
else
{
self.showSimpleAlert(msgValue!, message: nil, segueToLogin: false)
}
})
}
else {
self.showSimpleAlert(msgValue!, message: nil, segueToLogin: true)
}
}
}
catch let err {
print(err)
}
}
task.resume();
和MediaPlayer
来控制视频播放。一切都还可以,但我的问题是我必须实现全屏功能,用户点击全屏按钮全屏显示带控制器的播放器(如:播放,暂停,搜索栏e.t.c)。我希望和Youtube的全屏功能一样。我怎样才能做到这一点 ?
布局文件 - &gt;
SurfaceView
看起来像这样 - &gt;
此外,活动 - &gt;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="match_parent"/>
<com.ssl.testvideo.FontAwesome
android:id="@+id/btnPayPause"
android:textColor="#fff"
android:layout_centerInParent="true"
android:text=""
android:textSize="45sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="40dp">
<TextView
android:id="@+id/timeForMediaPlayer"
android:textStyle="bold"
android:textColor="#fff"
android:gravity="center"
android:layout_gravity="center_vertical"
android:text="00:00:00"
android:layout_width="60dp"
android:layout_height="wrap_content" />
<SeekBar
android:id="@+id/progressBar"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<com.ssl.testvideo.FontAwesome
android:id="@+id/fullScreen"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:textSize="20sp"
android:textColor="#fff"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
我正在使用this教程来实现视频播放器。我只需要实现全屏功能。
请不要告诉我任何第三方图书馆