An AVPlayerItem cannot be associated with more than one instance of AVPlayer

2014-03-11 14:03 295人阅读 评论(0) 收藏 举报

如果出现这个问题可以在初始化的时候不设置ContentURL
moviePlayerController_ = [[MPMoviePlayerViewController alloc] init];
moviePlayerController_.movieSourceType = MPMovieSourceTypeStreaming;
[moviePlayerController_.moviePlayer setContentURL:url];
原代码:(dingdone)

NSString *titleStr = [mediaDic objectForKey:kMediaVideoTitleKey];

NSURL *vodurl = [mediaDic objectForKey:kMediaVideoUrlKey];

HGMoviePlayerViewController *mediaPlayerController = [[HGMoviePlayerViewController alloc] initWithFrame:self.view.bounds contentURL:vodurl initialType:HGMoviePlayerControlStyleFullScreen withController:nil];

[mediaPlayerController alwaysHideComment:YES];

[mediaPlayerController alwaysHideShare:YES];

mediaPlayerController.contentTitle = titleStr;

[AppNavigationController presentViewController:mediaPlayerController animated:YES completion:^{

}];

播放MP4文件会闪退,改为

NSString *titleStr = [mediaDic objectForKey:kMediaVideoTitleKey];

NSURL *vodurl = [mediaDic objectForKey:kMediaVideoUrlKey];

HGMoviePlayerViewController *mediaPlayerController = [[HGMoviePlayerViewController alloc] initWithFrame:self.view.bounds contentURL:nil initialType:HGMoviePlayerControlStyleFullScreen withController:nil];

[mediaPlayerController setContentURL:vodurl];

[mediaPlayerController play];

[mediaPlayerController alwaysHideComment:YES];

[mediaPlayerController alwaysHideShare:YES];

mediaPlayerController.contentTitle = titleStr;

[AppNavigationController presentViewController:mediaPlayerController animated:YES completion:^{

}];

闪退问题解决,黄底部分是修改的代码。

An AVPlayerItem cannot be associated with more than one instance of AVPlayer错误的更多相关文章

  1. AVPlayer

    AVPlayer     AVPlayerLayer是CALayer的一个子类,由于AVPlayer这个播放器只能安置在AVPlayerLayer 这个图层之上,所以我们需要实例化一个UIView,并 ...

  2. AVAudioSesion和AVAudioPlayer的基本使用

    iOS基础篇-AVPLayer和AVAudioSession 2018.02.27 16:17 字数 215 阅读 1516评论 0喜欢 4 作用 AVPLayer:可以用来播放在线及本地音视频 AV ...

  3. 关于AVPlayerItem对象的属性duration返回播放总时长的坑

    最近在使用AVPlayer播放网络流媒体,发现一个坑: 就是playerItem.duration有可能不返回该网络多媒体资源的播放总时间长度,而是返回了一个奇怪的数据:nan, 因为我通过CMTim ...

  4. iOS开发系列--音频播放、录音、视频播放、拍照、视频录制

    --iOS多媒体 概览 随着移动互联网的发展,如今的手机早已不是打电话.发短信那么简单了,播放音乐.视频.录音.拍照等都是很常用的功能.在iOS中对于多媒体的支持是非常强大的,无论是音视频播放.录制, ...

  5. ZFPlayer 源码解读

    源码下载地址:https://github.com/renzifeng/ZFPlayer 之前自己实现过一个模仿百思不得姐的demo https://github.com/agelessman/FFm ...

  6. ios 音视频实现边播边缓存的思路和解决方案 (转)

    本片为转载内容,主要是以后自己看起来方便一些 原文地址:iOS音视频实现边下载边播放 其实音视频本地缓存的思想都差不多,都需要一个中间对象来连接播放器和服务器. 近段时间制作视频播放社区的功能,期间查 ...

  7. iOS从零开始学习直播之音频3.歌曲切换

      上周迟到了,周末去参加OSC源创会了,还是有点启发的.但这不是重点,重点是 上一篇我只是实现了一首歌曲的在线播放,这肯定是不够的.这一篇博客主要是实现了多首歌曲的顺序播放以及上一首和下一首切换. ...

  8. iOS从零开始学习直播之音频2.后台播放和在线播放

    本篇主要讲音频的后台播放和在线播放. 后台播放   上一篇写的工程运行之后程序退至后台,发现运行不了,歌停止了,这显然不行,音乐后台播放是标配啊.今天就来讲一下后台播放. 1.在plist文件里,告诉 ...

  9. 老司机学新平台 - Xamarin开发之我的第一个MvvmCross跨平台插件:SimpleAudioPlayer

    大家好,老司机学Xamarin系列又来啦!上一篇MvvmCross插件精选文末提到,Xamarin平台下,一直没找到一个可用的跨平台AudioPlayer插件.那就自力更生,让我们就自己来写一个吧! ...

随机推荐

  1. iOS学习09C语言函数指针

    本次主要学习和理解函数指针 1.函数指针 void printValue(int number) { printf("number = %d\n", number); } int ...

  2. BZOJ4635 : 数论小测验

    第一问: 设$a[i]$表示使用$[1,i]$的数字$n$次形成的数组里有多少个$\gcd=1$. 考虑容斥,则$a[i]=i^n-\sum_{j=2}^i a[\lfloor\frac{i}{j}\ ...

  3. bzoj2962 序列操作 题解

    题目大意: 有一个长度为n的序列,有三个操作1.I a b c表示将[a,b]这一段区间的元素集体增加c,2.R a b表示将[a,b]区间内所有元素变成相反数,3.Q a b c表示询问[a,b]这 ...

  4. ACM 最少步数

    最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 ...

  5. 3分钟wamp中php安装 pear 然而并没有用 并没能借此安装phpunit 不得不借用了其他的方式安装phpunit

    15:42 2015/11/233分钟wamp中php安装 pear环境介绍:windows10,wamp2.5(推荐博客的博主是win7,所以系统应该不是问题)注意:在过程中要输入一次 yes,不要 ...

  6. 定时器的fireDate指的是触发时间

    1.定时器开启后,会在经过设定的时间间隔后才会执行第一次定时操作.而不是立马开启. NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: ...

  7. Notification Once

    Notification Once 前段时间整理项目中的AppDelegate,发现很多写在- application:didFinishLaunchingWithOptions:中的代码都只是为了在 ...

  8. 纪念逝去的岁月——C/C++快速排序

    快速排序 代码 #include <stdio.h> void printList(int iList[], int iLen) { ; ; i < iLen; i++) { pri ...

  9. 测试简单for循环的效率

    os : CentOS 5.2 代码:test-usecond.c #include <stdio.h> #include <sys/time.h> // for gettim ...

  10. How to use the Isolated Storage Explorer tool for Windows Phone

    Isolated Storage Explorer is installed in the following location: Program Files (x86)\Microsoft SDKs ...