如何在iOS应用程序中添加Kaltura Player

时间:2015-07-31 11:50:24

标签: ios objective-c kaltura

我尝试在iOS应用程序中添加Kaltura Player。 我已经阅读了本文档中的示例(http://knowledge.kaltura.com/kaltura-player-sdk-ios)但是,对我来说,他们不能工作,bcs KPViewController没有方法initWithURL。 所以,我在viewDidAppear方法

中执行此操作
if ( self.KPlayer == nil ) 
{
    self.KPlayer = [[KPViewController alloc] init];
    [self.KPlayer.player setContentURL:fileURL];
    [self.KPlayer.player play];
    [self presentViewController:self.KPlayer animated:YES completion:nil];
}

但视频没有显示,在日志中我收到了一条消息:

::Error:: -[KPViewController viewDidAppear:] (line:168) 
Delegate MUST be set and respond to selector -getInitialKIframeUrl

我做错了什么?

2 个答案:

答案 0 :(得分:1)

Kaltura SDK for iOS和Android中有更新,到目前为止他们的文档中没有更改/更新。 :

根据旧版SDK,KPViewController中有方法initWithUrl 你可以使用以下方式播放视频:

NSString *videoUrl = [NSString stringWithFormat:@"https://cdnapisec.kaltura.com/p/243342/sp/24334200/embedIframeJs/uiconf_id/12905712/partner_id/1988382?iframeembed=true&entry_id=%@",entryId];
    NSURL *url = [NSURL URLWithString:videoUrl];

    self.player = [[KPViewController alloc] initWithURL:url];
    self.player.view.frame = [self.viewVideo bounds];
    [self.player loadPlayerIntoViewController:self];
    [self.viewVideo addSubview:self.player.view];

但根据新的SDK和Demo参考App:https://github.com/kaltura/IOSReferenceApp

install the SDK using pod :
1) on terminal,go to the Project Directory and run -> pod init
2) open the Podfile and copy and paste
 pod 'player-sdk-native-ios', '~> 1.1' 
before this line : target 'KalturaVideo_ObjC' do
close and save the file
3) pod install
4) close your current XCode project and open your ProjectName.xcworkspace file

MediaInfoViewController_iPhone.m中有 - (void)drawPlayer方法,它将KPViewController * playerViewController添加到ViewController

如果您无法使用演示应用播放视频,请调用[self playButtonPressed];在drawPlayer方法结束时,会直接播放视频,playButtonPressed方法有实现播放视频。

答案 1 :(得分:0)

您确定要导入KPViewController,因为它有一个自定义初始化程序initWithURL:。此外,KPViewController没有任何播放器属性(至少不是公共属性)。播放器(id)由KPlayerController(它也不是KPViewController的公共属性)懒惰创建。所以你的实现对我来说听起来很糟糕:-)(很遗憾地说:-))。需要看到更多才能正确回答。

相关问题