1. 程式人生 > >iOS學習筆記5-MPMoviePlayerController詳解

iOS學習筆記5-MPMoviePlayerController詳解

MPMoviePlayerController

在iOS中播放視訊可以使用MediaPlayer.framework種的MPMoviePlayerController類來完成,它支援本地視訊和網路視訊播放。這個類實現了MPMediaPlayback協議,因此具備一般的播放器控制功能,例如播放、暫停、停止等。但是MPMediaPlayerController自身並不是一個完整的檢視控制器,如果要在UI中展示視訊需要將view屬性新增到介面中。下面列出了MPMoviePlayerController的常用屬性和方法:

屬性 說明
@property (nonatomic, copy) NSURL *contentURL
播放媒體URL,這個URL可以是本地路徑,也可以是網路路徑
@property (nonatomic, readonly) UIView *view 播放器檢視,如果要顯示視訊必須將此檢視新增到控制器檢視中
@property (nonatomic, readonly) UIView *backgroundView 播放器背景檢視
@property (nonatomic, readonly) MPMoviePlaybackState playbackState 媒體播放狀態,列舉型別:
MPMoviePlaybackStateStopped:停止播放
MPMoviePlaybackStatePlaying:正在播放
MPMoviePlaybackStatePaused:暫停
MPMoviePlaybackStateInterrupted:中斷
MPMoviePlaybackStateSeekingForward:向前定位
MPMoviePlaybackStateSeekingBackward:向後定位
@property (nonatomic, readonly) MPMovieLoadState loadState 網路媒體載入狀態,列舉型別:
MPMovieLoadStateUnknown:位置型別
MPMovieLoadStatePlayable:
MPMovieLoadStatePlaythroughOK:這種狀態如果shouldAutoPlay為YES將自動播放
MPMovieLoadStateStalled:停滯狀態
@property (nonatomic) MPMovieControlStyle controlStyle 控制面板風格,列舉型別:
MPMovieControlStyleNone:無控制面板
MPMovieControlStyleEmbedded:嵌入視訊風格
MPMovieControlStyleFullscreen:全屏
MPMovieControlStyleDefault:預設風格
@property (nonatomic) MPMovieRepeatMode repeatMode; 重複播放模式,列舉型別:
MPMovieRepeatModeNone:不重複,預設值
MPMovieRepeatModeOne:重複播放
@property (nonatomic) BOOL shouldAutoplay 當網路媒體快取到一定資料時是否自動播放,預設為YES
@property (nonatomic, getter=isFullscreen) BOOL fullscreen 是否全屏展示,預設為NO,注意如果要通過此屬性設定全屏必須在檢視顯示完成後設定,否則無效
@property (nonatomic) MPMovieScalingMode scalingMode 視訊縮放填充模式,列舉型別:
MPMovieScalingModeNone:不進行任何縮放
MPMovieScalingModeAspectFit:固定縮放比例並且儘量全部展示視訊,不會裁切視訊
MPMovieScalingModeAspectFill:固定縮放比例並填充滿整個檢視展示,可能會裁切視訊
MPMovieScalingModeFill:不固定縮放比例壓縮填充整個檢視,視訊不會被裁切但是比例失衡
@property (nonatomic, readonly) BOOL readyForDisplay 是否有相關媒體被播放
@property (nonatomic, readonly) MPMovieMediaTypeMask movieMediaTypes 媒體類別,列舉型別:
MPMovieMediaTypeMaskNone:未知型別
MPMovieMediaTypeMaskVideo:視訊
MPMovieMediaTypeMaskAudio:音訊
@property (nonatomic) MPMovieSourceType movieSourceType 媒體源,列舉型別:
MPMovieSourceTypeUnknown:未知來源
MPMovieSourceTypeFile:本地檔案
MPMovieSourceTypeStreaming:流媒體(直播或點播)
@property (nonatomic, readonly) NSTimeInterval duration 媒體時長,如果未知則返回0
@property (nonatomic, readonly) NSTimeInterval playableDuration 媒體可播放時長,主要用於表示網路媒體已下載視訊時長
@property (nonatomic, readonly) CGSize naturalSize 視訊實際尺寸,如果未知則返回CGSizeZero
@property (nonatomic) NSTimeInterval initialPlaybackTime 起始播放時間
@property (nonatomic) NSTimeInterval endPlaybackTime 終止播放時間
@property (nonatomic) BOOL allowsAirPlay 是否允許無線播放,預設為YES
@property (nonatomic, readonly, getter=isAirPlayVideoActive) BOOL airPlayVideoActive 當前媒體是否正在通過AirPlay播放
@property(nonatomic, readonly) BOOL isPreparedToPlay 是否準備好播放
@property(nonatomic) NSTimeInterval currentPlaybackTime 當前播放時間,單位:秒
@property(nonatomic) float currentPlaybackRate 當前播放速度,如果暫停則為0,正常速度為1.0,非0資料表示倍率
物件方法 說明
- (instancetype)initWithContentURL:(NSURL *)url 使用指定的URL初始化媒體播放控制器物件
- (void)setFullscreen:(BOOL)fullscreen animated:(BOOL)animated 設定視訊全屏,注意如果要通過此方法設定全屏則必須在其檢視顯示之後設定,否則無效
- (void)requestThumbnailImagesAtTimes:(NSArray *)playbackTimes timeOption:(MPMovieTimeOption)option 獲取在指定播放時間的視訊縮圖,第一個引數是獲取縮圖的時間點陣列;第二個引數代表時間點精度,列舉型別:
MPMovieTimeOptionNearestKeyFrame:時間點附近
MPMovieTimeOptionExact:準確時間
- (void)cancelAllThumbnailImageRequests 取消所有縮圖獲取請求
- (void)prepareToPlay 準備播放,載入視訊資料到快取,當呼叫play方法時如果沒有準備好會自動呼叫此方法
- (void)play 開始播放
- (void)pause 暫停播放
- (void)stop 停止播放
- (void)beginSeekingForward 向前定位
- (void)beginSeekingBackward 向後定位
- (void)endSeeking 停止快進/快退
通知 說明
MPMoviePlayerScalingModeDidChangeNotification 視訊縮放填充模式發生改變
MPMoviePlayerPlaybackDidFinishNotification 媒體播放完成或使用者手動退出,具體完成原因可以通過通知userInfo中的key為MPMoviePlayerPlaybackDidFinishReasonUserInfoKey的物件獲取
MPMoviePlayerPlaybackStateDidChangeNotification 播放狀態改變,可配合playbakcState屬性獲取具體狀態
MPMoviePlayerLoadStateDidChangeNotification 媒體網路載入狀態改變
MPMoviePlayerNowPlayingMovieDidChangeNotification 當前播放的媒體內容發生改變
MPMoviePlayerWillEnterFullscreenNotification 將要進入全屏
MPMoviePlayerDidEnterFullscreenNotification 進入全屏後
MPMoviePlayerWillExitFullscreenNotification 將要退出全屏
MPMoviePlayerDidExitFullscreenNotification 退出全屏後
MPMoviePlayerIsAirPlayVideoActiveDidChangeNotification 當媒體開始通過AirPlay播放或者結束AirPlay播放
MPMoviePlayerReadyForDisplayDidChangeNotification 視訊顯示狀態改變
MPMovieMediaTypesAvailableNotification 確定了媒體可用型別後
MPMovieSourceTypeAvailableNotification 確定了媒體來源後
MPMovieDurationAvailableNotification 確定了媒體播放時長後
MPMovieNaturalSizeAvailableNotification 確定了媒體的實際尺寸後
MPMoviePlayerThumbnailImageRequestDidFinishNotification 縮圖請求完成之後
MPMediaPlaybackIsPreparedToPlayDidChangeNotification 做好播放準備後

注意MPMediaPlayerController的狀態等資訊並不是通過代理來和外界互動的,而是通過通知中心,因此從上面的列表中可以看到常用的一些通知。由於MPMoviePlayerController本身對於媒體播放做了深度的封裝,使用起來就相當簡單:建立MPMoviePlayerController物件,設定frame屬性,將MPMoviePlayerController的view新增到控制器檢視中。下面的示例中將建立一個播放控制器並新增播放狀態改變及播放完成的通知:

//
//  ViewController.m
//  MPMoviePlayerController
//
//  Created by Kenshin Cui on 14/03/30.
//  Copyright (c) 2014年 cmjstudio. All rights reserved.
//

#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>

@interface ViewController ()

@property (nonatomic,strong) MPMoviePlayerController *moviePlayer;//視訊播放控制器

@end

@implementation ViewController

#pragma mark - 控制器檢視方法
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //播放
    [self.moviePlayer play];
    
    //新增通知
    [self addNotification];
    
}

-(void)dealloc{
    //移除所有通知監控
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


#pragma mark - 私有方法
/**
 *  取得本地檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getFileUrl{
    NSString *urlStr=[[NSBundle mainBundle] pathForResource:@"The New Look of OS X Yosemite.mp4" ofType:nil];
    NSURL *url=[NSURL fileURLWithPath:urlStr];
    return url;
}

/**
 *  取得網路檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getNetworkUrl{
    NSString *[email protected]"http://192.168.1.161/The New Look of OS X Yosemite.mp4";
    urlStr=[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url=[NSURL URLWithString:urlStr];
    return url;
}

/**
 *  建立媒體播放控制器
 *
 *  @return 媒體播放控制器
 */
-(MPMoviePlayerController *)moviePlayer{
    if (!_moviePlayer) {
        NSURL *url=[self getNetworkUrl];
        _moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:url];
        _moviePlayer.view.frame=self.view.bounds;
        _moviePlayer.view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:_moviePlayer.view];
    }
    return _moviePlayer;
}

/**
 *  新增通知監控媒體播放控制器狀態
 */
-(void)addNotification{
    NSNotificationCenter *notificationCenter=[NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackStateChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.moviePlayer];
    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
    
}

/**
 *  播放狀態改變,注意播放完成時的狀態是暫停
 *
 *  @param notification 通知物件
 */
-(void)mediaPlayerPlaybackStateChange:(NSNotification *)notification{
    switch (self.moviePlayer.playbackState) {
        case MPMoviePlaybackStatePlaying:
            NSLog(@"正在播放...");
            break;
        case MPMoviePlaybackStatePaused:
            NSLog(@"暫停播放.");
            break;
        case MPMoviePlaybackStateStopped:
            NSLog(@"停止播放.");
            break;
        default:
            NSLog(@"播放狀態:%li",self.moviePlayer.playbackState);
            break;
    }
}

/**
 *  播放完成
 *
 *  @param notification 通知物件
 */
-(void)mediaPlayerPlaybackFinished:(NSNotification *)notification{
    NSLog(@"播放完成.%li",self.moviePlayer.playbackState);
}


@end

執行效果:

MPMoviePlayerController
從上面的API大家也不難看出其實MPMoviePlayerController功能相當強大,日常開發中作為一般的媒體播放器也完全沒有問題。MPMoviePlayerController除了一般的視訊播放和控制外還有一些強大的功能,例如擷取視訊縮圖。請求視訊縮圖時只要呼叫- (void)requestThumbnailImagesAtTimes:(NSArray *)playbackTimes timeOption:(MPMovieTimeOption)option方法指定獲得縮圖的時間點,然後監控MPMoviePlayerThumbnailImageRequestDidFinishNotification通知,每個時間點的縮圖請求完成就會呼叫通知,在通知呼叫方法中可以通過MPMoviePlayerThumbnailImageKey獲得UIImage物件處理即可。例如下面的程式演示了在程式啟動後獲得兩個時間點的縮圖的過程,截圖成功後儲存到相簿:

//
//  ViewController.m
//  MPMoviePlayerController
//
//  Created by Kenshin Cui on 14/03/30.
//  Copyright (c) 2014年 cmjstudio. All rights reserved.
//  視訊截圖

#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>

@interface ViewController ()

@property (nonatomic,strong) MPMoviePlayerController *moviePlayer;//視訊播放控制器

@end

@implementation ViewController

#pragma mark - 控制器檢視方法
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //播放
    [self.moviePlayer play];
    
    //新增通知
    [self addNotification];
    
    //獲取縮圖
    [self thumbnailImageRequest];
}

-(void)dealloc{
    //移除所有通知監控
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


#pragma mark - 私有方法
/**
 *  取得本地檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getFileUrl{
    NSString *urlStr=[[NSBundle mainBundle] pathForResource:@"The New Look of OS X Yosemite.mp4" ofType:nil];
    NSURL *url=[NSURL fileURLWithPath:urlStr];
    return url;
}

/**
 *  取得網路檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getNetworkUrl{
    NSString *[email protected]"http://192.168.1.161/The New Look of OS X Yosemite.mp4";
    urlStr=[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url=[NSURL URLWithString:urlStr];
    return url;
}

/**
 *  建立媒體播放控制器
 *
 *  @return 媒體播放控制器
 */
-(MPMoviePlayerController *)moviePlayer{
    if (!_moviePlayer) {
        NSURL *url=[self getNetworkUrl];
        _moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:url];
        _moviePlayer.view.frame=self.view.bounds;
        _moviePlayer.view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:_moviePlayer.view];
    }
    return _moviePlayer;
}

/**
 *  獲取視訊縮圖
 */
-(void)thumbnailImageRequest{
    //獲取13.0s、21.5s的縮圖
    [self.moviePlayer requestThumbnailImagesAtTimes:@[@13.0,@21.5] timeOption:MPMovieTimeOptionNearestKeyFrame];
}

#pragma mark - 控制器通知
/**
 *  新增通知監控媒體播放控制器狀態
 */
-(void)addNotification{
    NSNotificationCenter *notificationCenter=[NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackStateChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.moviePlayer];
    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
    [notificationCenter addObserver:self selector:@selector(mediaPlayerThumbnailRequestFinished:) name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:self.moviePlayer];
    
}

/**
 *  播放狀態改變,注意播放完成時的狀態是暫停
 *
 *  @param notification 通知物件
 */
-(void)mediaPlayerPlaybackStateChange:(NSNotification *)notification{
    switch (self.moviePlayer.playbackState) {
        case MPMoviePlaybackStatePlaying:
            NSLog(@"正在播放...");
            break;
        case MPMoviePlaybackStatePaused:
            NSLog(@"暫停播放.");
            break;
        case MPMoviePlaybackStateStopped:
            NSLog(@"停止播放.");
            break;
        default:
            NSLog(@"播放狀態:%li",self.moviePlayer.playbackState);
            break;
    }
}

/**
 *  播放完成
 *
 *  @param notification 通知物件
 */
-(void)mediaPlayerPlaybackFinished:(NSNotification *)notification{
    NSLog(@"播放完成.%li",self.moviePlayer.playbackState);
}

/**
 *  縮圖請求完成,此方法每次截圖成功都會呼叫一次
 *
 *  @param notification 通知物件
 */
-(void)mediaPlayerThumbnailRequestFinished:(NSNotification *)notification{
    NSLog(@"視訊截圖完成.");
    UIImage *image=notification.userInfo[MPMoviePlayerThumbnailImageKey];
    //儲存圖片到相簿(首次呼叫會請求使用者獲得訪問相簿許可權)
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

@end

截圖效果:

MPMoviePlayerController_Thumbnail1     MPMoviePlayerController_Thumbnail2

擴充套件--使用AVFoundation生成縮圖

通過前面的方法大家應該已經看到,使用MPMoviePlayerController來生成縮圖足夠簡單,但是如果僅僅是是為了生成縮圖而不進行視訊播放的話,此刻使用MPMoviePlayerController就有點大材小用了。其實使用AVFundation框架中的AVAssetImageGenerator就可以獲取視訊縮圖。使用AVAssetImageGenerator獲取縮圖大致分為三個步驟:

  1. 建立AVURLAsset物件(此類主要用於獲取媒體資訊,包括視訊、聲音等)。
  2. 根據AVURLAsset建立AVAssetImageGenerator物件。
  3. 使用AVAssetImageGenerator的copyCGImageAtTime::方法獲得指定時間點的截圖。
//
//  ViewController.m
//  AVAssetImageGenerator
//
//  Created by Kenshin Cui on 14/03/30.
//  Copyright (c) 2014年 cmjstudio. All rights reserved.
//

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //獲取第13.0s的縮圖
    [self thumbnailImageRequest:13.0];
}

#pragma mark - 私有方法
/**
 *  取得本地檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getFileUrl{
    NSString *urlStr=[[NSBundle mainBundle] pathForResource:@"The New Look of OS X Yosemite.mp4" ofType:nil];
    NSURL *url=[NSURL fileURLWithPath:urlStr];
    return url;
}

/**
 *  取得網路檔案路徑
 *
 *  @return 檔案路徑
 */
-(NSURL *)getNetworkUrl{
    NSString *[email protected]"http://192.168.1.161/The New Look of OS X Yosemite.mp4";
    urlStr=[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url=[NSURL URLWithString:urlStr];
    return url;
}

/**
 *  擷取指定時間的視訊縮圖
 *
 *  @param timeBySecond 時間點
 */
-(void)thumbnailImageRequest:(CGFloat )timeBySecond{
    //建立URL
    NSURL *url=[self getNetworkUrl];
    //根據url建立AVURLAsset
    AVURLAsset *urlAsset=[AVURLAsset assetWithURL:url];
    //根據AVURLAsset建立AVAssetImageGenerator
    AVAssetImageGenerator *imageGenerator=[AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];
    /*截圖
     * requestTime:縮圖建立時間
     * actualTime:縮圖實際生成的時間
     */
    NSError *error=nil;
    CMTime time=CMTimeMakeWithSeconds(timeBySecond, 10);//CMTime是表示電影時間資訊的結構體,第一個引數表示是視訊第幾秒,第二個引數表示每秒幀數.(如果要活的某一秒的第幾幀可以使用CMTimeMake方法)
    CMTime actualTime;
    CGImageRef cgImage= [imageGenerator copyCGImageAtTime:time actualTime:&actualTime error:&error];
    if(error){
        NSLog(@"擷取視訊縮圖時發生錯誤,錯誤資訊:%@",error.localizedDescription);
        return;
    }
    CMTimeShow(actualTime);
    UIImage *image=[UIImage imageWithCGImage:cgImage];//轉化為UIImage
    //儲存到相簿
    UIImageWriteToSavedPhotosAlbum(image,nil, nil, nil);
    CGImageRelease(cgImage);
}

@end

生成的縮圖效果:

AVAssetImageGenerator_Thumbnail

相關推薦

iOS學習筆記5-MPMoviePlayerController

MPMoviePlayerController 在iOS中播放視訊可以使用MediaPlayer.framework種的MPMoviePlayerController類來完成,它支援本地視訊和網路視訊播放。這個類實現了MPMediaPlayback協議,因此具備一般的播放器

expect學習筆記及例項

expect學習筆記及例項詳解 引用自:http://wenku.baidu.com/view/b65e103610661ed9ad51f374.html   1. expect 是基於tcl 演變而來的,所以很多語法和tcl 類似,基本的語法如下 所示: 1.1 首行

C語言學習筆記---malloc函式

                                                                                            malloc函式詳解 一、malloc函式標頭檔案: #include<stdli

斯坦福大學的機器學習筆記SVM初探

最近在看斯坦福大學的機器學習的公開課,學習了支援向量機,再結合網上各位大神的學習經驗總結了自己的一些關於支援向量機知識。 一、什麼是支援向量機(SVM)? 1、支援向量機(Support Vector Machine,常簡稱為SVM)是一種監督式學習的方法,可廣泛地應用於統

Spring學習筆記 —— AOP標籤()

引言 但是,除了面向切面程式設計之外,AOP的名字空間中還包含了一些重要的標籤,比如”scoped-proxy”。這篇文章就會詳細介紹這個標籤的作用,以及它的實現方式分析。 scoped-proxy 標籤介紹 在 Spring學習筆記 —

YOLOv2--論文學習筆記(演算法

主要包括三個部分:Better,Faster,Stronger,其中前面兩部分基本上講的是YOLO v2,最後一部分講的是YOLO9000。 Better 這部分細節很多,要詳細瞭解的話還是需要結合原始碼來看。 本篇論文是YOLO作者為了改進原有的YOLO演

PHPUnit學習筆記(四)斷言

斷言(Assertions)是PHPUnit提供的一系列對程式執行結果測試的方法。通俗的講,就是斷言執行程式結果為我們期待的值,如果不是則測試失敗,下面是斷言方法的詳細介紹,內容全部來翻譯自PHPUnit的官方文件,部分方法官方介紹的很模糊,我根據官方的原始碼註釋增加了說明和註釋

Android學習筆記之選單

選單概述 每個Activity都可以指定它自己的選單,按下硬體選單鍵即可顯示選項選單。。但是從 Android 3.0(API 級別 11)開始,硬體選單就變成了可選擇的。Activity推薦使用應用欄和溢位選單來代替傳統的6鍵選單。儘管某些選單項的設計和使用

TCP-IP卷1:協議 學習筆記(5) RARP ICMP

參考:TCP-IP詳解卷1:協議 RARP RARP分組的格式與ARP分組基本一致,它們之間的主要差別是RARP請求或應答的幀型別為0x8035,RARP請求的操作碼為3,應答操作碼為4。 RARP請求以廣播的方式傳送,RARP應答一般是單播傳送的。 RARP伺服器實現

TCP/IP學習筆記(5)-IP選路,動態選路,和一些細節

1.靜態IP選路 1.1.一個簡單的路由表 選路是IP層最重要的一個功能之一。前面的部分已經簡單的講過路由器是通過何種規則來根據IP資料包的IP地址來選擇路由。這裡就不重複了。首先來看看一個簡單的系統路由表。 Destination     Gateway        

10.5-全棧Java筆記:常見流(三)

java上節我們講到「Java中常用流:緩沖流」,本節我們學習數據流和對象流~ 數據流數據流將“基本數據類型變量”作為數據源,從而允許程序以與機器無關方式從底層輸入輸出流中操作java基本數據類型。 DataInputStream和DataOutputStream提供了可以存取與機器無關的所有Java基礎類

深度學習 --- 卷積神經網路CNN(LeNet-5網路

卷積神經網路(Convolutional Neural Network,CNN)是一種前饋型的神經網路,其在大型影象處理方面有出色的表現,目前已經被大範圍使用到影象分類、定位等領域中。相比於其他神經網路結構,卷積神經網路需要的引數相對較少,使的其能夠廣泛應用。 本節打算先介紹背景和簡單的基本

學習筆記:強化學習之A3C程式碼

寫在前面:我是根據莫煩的視訊學習的Reinforce learning,具體程式碼實現包括Q-learning,SARSA,DQN,Policy-Gradient,Actor-Critic以及A3C。(莫凡老師的網站:https://morvanzhou.git

ios筆記-runtime Method

Runtime Method 介紹:Method型別是一個objc_method結構體指標,objc_method有三個成員 typedef struct objc_method Method;

Linux 學習筆記 5 檔案的下載、壓縮、壓、初步認識yum

寫在前面 上節我們通過簡單的幾組命令,已經完全的實現了檔案的移動、刪除、更名、以及複製,我們最常用的基本玩法,本節將帶著大家學習壓縮、解壓的相關步驟。 Linux 學習筆記 4 建立、複製、移動、檔案的基本操作 壓縮解壓還是比較常見並且常用的,比如從Apache 這種開源網站下載比如Tomcat Maven

mysql學習筆記(5-DDL命令)

mysql服務器端命令: DDL:數據定義語言,主要用於管理數據庫組件,例如表、索引、視圖、用戶、存儲過程 CREATE、ALTER、DROP DML:數據操縱語言,主要用管理表中的數據,實現數據的增、刪、改、查; INSERT, DELETE, UPDAT

python學習筆記5-自定義函數

函數調用 筆記 取值 修改 args pytho class 名稱 func 1 自定義函數   (1)函數代碼塊以def關鍵字開頭,然後函數標識符名稱和圓括號   (2)任何傳入參數和自變量必須放在圓括號中間。圓括號之間可以用於定義參數   (3)函數的第一行語句可以選擇

ios學習筆記---ios完整學習路線

size tle spa mage 技術分享 soft 分享 -s 學習筆記 ios完整學習路線 ios學習筆記---ios完整學習路線

Jmeter學習筆記5-檢查點

sogo arc logs blog 繼續 sample com arch 毫秒 1.定義:Jmeter中的檢查點就是斷言中的響應斷言。 2.通過實例進行介紹: 以sogou.com搜索為例,檢查搜索關鍵字,search.jmx badboy錄制後導入Jmeter 集行參數

Python學習筆記5 【轉載】基本矩陣運算_20170618

ros class 簡單 lba spa 使用 常見 port 模塊 需要 numpy 庫支持 保存鏈接 http://www.cnblogs.com/chamie/p/4870078.html 1.numpy的導入和使用 from numpy import *;