`
lizaochengwen
  • 浏览: 641565 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

iphone播放视频时遇到的一个错误解决办法 An AVPlayerItem can occupy only one position in a player’

 
阅读更多



While playing a video using MPMoviePlayerViewController or MPMoviePlayerController, iOS SDK 5.2 generates an error as follows.

An AVPlayerItem can occupy only one position in a player’s queue at a time.

The exact error is as follows.

*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘An AVPlayerItem can occupy only one position in a player’s queue at a time.’

Please have a look into following code - WHICH GENERATES ERROR.

#pragma mark - Media player  
-(void)initAndPlayMovie:(NSURL *)movieURL andViewController:(UIViewController*)vCtr { 
 self.mPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];  // set source type streaming  
[self.mPlayer.moviePlayer setMovieSourceType:MPMovieSourceTypeStreaming];   [self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];   
// fit to screen mode  
[self.mPlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];   
// full screen mode 
 [self.mPlayer.moviePlayer setFullscreen:YES animated:YES];   
[vCtr presentMoviePlayerViewControllerAnimated:self.mPlayer]; 
}
Now, have a look into following code WHICH WILL WORK FINE

#pragma mark - Media player 
 -(void)initAndPlayMovie:(NSURL *)movieURL andViewController:(UIViewController*)vCtr {  
self.mPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];  
// set source type streaming 
 [self.mPlayer.moviePlayer setMovieSourceType:MPMovieSourceTypeUnknown];   [self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];   
// fit to screen mode  
[self.mPlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];   
// full screen mode  [self.mPlayer.moviePlayer setFullscreen:YES animated:YES];  
 [vCtr presentMoviePlayerViewControllerAnimated:self.mPlayer]; 
}
The main difference in both code is as follows.

MovieSourceType is modified to “MPMovieSourceTypeUnknown” instead of “MPMovieSourceTypeStreaming”.

If you have a streaming URL, It is recommended to use “MPMovieSourceTypeStreaming”.

While having a static movie URL, It is recommended to use “MPMovieSourceTypeUnknown”.

If you have a URL from file or video from application itself, It is recommended to use ”MPMovieSourceTypeFile”.
分享到:
评论

相关推荐

    WPF 国际象棋 棋子 ChessProgrammingTest.zip

    * Only one piece can occupy any position on the board at a given time. * All pieces can “jump” any occupied position. Note: Although the game bears a striking resemblance to Chess, this is entirely...

    Choose Test.zip

    项目的实现代码,提供了网站登录时的验证码实现DEMO,可以下载下来运行实现,

    LuaUnicode icu-lua

    octets in the range 0x80 to 0xBF (128-191) can only appear in the second and subsequent octets of a multi-octet encoding. Remember that you cannot use \0 in a Lua pattern. For example, you could ...

    怪异字符串转换

    An int type variable always occupy 4 bytes consecutively, so is an array of 4 char type elements. Write a function to convert an unsigned int type variable into an array of 4 char type elements.

    GoodReader_v3.8.1.ipa

    • “Free 5GB SugarSync Account” button in the SugarSync connection parameters window lets you create a free new account in case if you haven't got one • PDF's Freehand drawing mode now lets you ...

    吴建业作文观点汇总

    3. Build up one’s confidence and offer one a sense of achievement (accomplishment), because one can realize his value and capability. 4. Learn to cooperate and master interpersonal skills, which are ...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a corrupt...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-Part1

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a corrupt...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part2

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a ...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-part2

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a corrupt...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part1

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a ...

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part2

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a corrupt...

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part1

    Q433283 - A layout group with a label layout item that is set to occupy the entire client area of its group has an incorrect width B218895 - Documentation - Incorrect topic navigation due to a corrupt...

    qam.zip_PAM pdf_Separated_qam

    Quadrature amplitude modulation (QAM) is a modulation scheme in which two sinusoidal carriers, one exactly 90 degrees out of phase with respect to the other, are used to transmit data over a given ...

    Microprocessor Simulation

    That is, the high word of a two-word address will always occupy the lower word of memory. ?Memory is 256 words. ?There are two accumulators, A and B, each storing one word. ?There are nine ...

    DevExpress VCL 13.2.5 D7-DXE6 FullSource

    •Q583166 - Restoring the tree list from an empty or corrupted store using RestoreFrom~ method calls assigns incorrect Coilumn.Position.BandIndex property values, and as a result, hides these columns ...

    Big.Data.and.IT.Professionals.1514870622

    Big Data and IT Professionals: A Study of the Perceptions Held by IT Professionals in Relation to the Maturity, Value, and Practical Deployment of Big Data Solutions This work documents a research ...

    雷达技术知识

    date, however, no one has tested if LiDAR returns from water surfaces can be used to measure local water surface slopes within the active channel. Much of the reason that researchers have not ...

    Packtpub.Python.2.6.Text.Processing.Beginners.Guide.Dec.2010

    Extract, decrypt, parse, restructure – these are just some of the text tasks that can occupy much of a programmer’s life. If this is your life, this book will make it better – a practical guide on...

    A Textbook of Java Programming

    A Textbook of Java Programming By 作者: Surbhi Kakar ISBN-10 书号: 9385909665 ISBN-13 书号: 9789385909665 出版日期: 2017-12-18 pages 页数: 468 $35 This book covers all the core java concepts of ...

Global site tag (gtag.js) - Google Analytics