Get current position of MPMusicPlayer - ios

I was wondering how to get the current position of an MPMusicPlayer. For example, if the music player is playing a song and it is currently at 0 minutes 23 seconds, how would I get that value as well as set it?

Please use below property to get current position
mpMusicPlayer.currentPlaybackTime

The following links can help you-
How to set music playback slider in music player
Problems with currentPlaybackTime and MPMusicPlayerController and iOS 7.1.
Using MPMusicPlayerController, setting musicPlayer.currentPlaybackTime to seek but takes second to take effect
https://github.com/gangverk/GVMusicPlayerController

Related

How to get current play time of GVRVideoView

I'm using GoogleVR library for iOS to play VR video. I use GVRVideoView. But there is a problem that I don't know how to get current play time. I need to show a Slider on UI, that includes current play time.
https://developers.google.com/vr/ios/get-started
So, how can I get current play back time of GVRVideoView?
GVRVideoView has a delegate method
- (void)videoView:(GVRVideoView*)videoView didUpdatePosition:(NSTimeInterval)position;
You can do with the position, for example, set progress with position/videoView.duration.

AVPlayer setRate property create glitchy if we use setRate frequently

I have used AVPlayer to play videos in slow motion. I am using addPeriodicTimeObserverForInterval: message to get time at specific interval, and checking some condition according to current playback time. once condition is fulfilled, I am calculating rate and using setRate: message of AVPlayer. i.e I am setting rate frequently. but once I have done with this, video is not playing smoothly, it's glitchy.
Can anybody please let me know how can I set setRate: frequently.
Thanks
We were having kind of the same issue. We were using setRate:1 (or 1.5/2.0 depending on what the user chose) to play the video instead of calling play. We have changed to call play then setRate: and the video plays smoothly now.

MPMoviePlayerController play/pause toggle issue

I have used MPMoviePlayerController in my application to play selected video. There is also facility to start video from different location like from 10 min, 20 min, 40 min etc.
Problem in iOS 7:
The problem is when video is played I am able to pause it but it does not resume after pausing. And also the pause button does not turn into play button. After clicking pause button none of the notification like "MPMoviePlayerPlaybackStateDidChangeNotification" get invoked. And same problem occurs when video is playing in fullscreen mode.
Problem in iOS 6:
Here only problem is that pause button does not turn into play button. Here video pause and resume works properly in fullscreenmode also.
one strange behaviour:
For one video when I play it from 40 min it just works perfectly. None of the above issues occur for it. But same video does not work when played from starting or 10,20 min durations.
I have searched a lot but I found only one post here related to this issue. But this solution is not working for me.
Does anybody know how to solve this?
Use AVPlayer as MPMoviePlayer is now deprecated.

Do i need to stop MusicPlayerController first before i play to next song in iOS?

In my app , i have to play songs from iPod Library with MPMusicPlayerContrller's iPodMusicPlayer.
I just want to know , in my app , first song is playing from Album and when i want to play another song from Playlists that selected from UITableView do i need to use stop function [self.player stop]; before change next songs?
Or i can directly play without stop current playing song?
Thanks for your help.
no need to stop.my question is "Why to stop?". no,never nothing, there is no need of stop.
ios already given you facility of playing new song from playlist through the properties.
if you stops it & again play it,its just wastage of execution time.
Since you probably use skipToNextItem or skipToPreviousItem it's perfectly legit to use them directly.
Documentation for MPMusicPlayerController.

GaugeField progress forward and rewind when playing audio?

I'm developing a player Application which plays audio for some fixed time. I need to use Gaugefield such that it should fast-forward and rewind the Audio that is currently Playing.
I am able to get the time from the player and displaying on the screen. I need to update the time when the progress of Gaugefield is increased or decreased and at the same time I need to stream the player according to the level of the Gaugefield.
I used the sample code below but it is not working.
Player.stop();
Player.setMediaTime();
Player.start();
I am working on 6.0 OS.
Are you implementing a PlayerListener? If you implement PlayerListener, then you can use the playerUpdate() method to update your GaugeField.

Resources