`
lizaochengwen
  • 浏览: 662553 次
  • 性别: 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

    "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 ...

    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 ...

    计算机组成教学课件:Chapter2 Machine Instruction.ppt

    Instructions in a computer system can be categorized into four main types. These include data transfers between memory and processor registers, arithmetic and logic operations on data, program ...

    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 ...

    AST20114_1314 Test

    - **Increase in Levels in Line Coding Scheme**: The statement "An increase in the number of levels used in a line coding scheme increases the baud rate" is **False**. In fact, increasing the number of...

    雷达技术知识

    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 ...

Global site tag (gtag.js) - Google Analytics