Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Q] Loop video on login screen like Spotify

OP Moonbloom

24th March 2014, 06:59 PM   |  #1  
OP Senior Member
Thanks Meter: 97
 
442 posts
Join Date:Joined: Aug 2011
More
Hello

I'm currently making an app and i want to spruce up the login screen with a video like Spotify currently has.
It plays a small video in the background, behind the login buttons/logo etc and simply loops the video over and over again.

I've tried to mess around with a VideoView and a MediaPlayer to control it, but i can't seem to get a proper grip on it. And especially not with setting the correct size of the video dependent on different screen sizes or looping the video.

If anyone got an idea/link/knows how Spotify does it, i'd love to get some inputs

- Moon
25th March 2014, 01:13 AM   |  #2  
gh0stslayer's Avatar
Senior Member
Flag Bangalore
Thanks Meter: 203
 
255 posts
Join Date:Joined: Nov 2010
More
Quote:
Originally Posted by Moonbloom

Hello

I'm currently making an app and i want to spruce up the login screen with a video like Spotify currently has.
It plays a small video in the background, behind the login buttons/logo etc and simply loops the video over and over again.

I've tried to mess around with a VideoView and a MediaPlayer to control it, but i can't seem to get a proper grip on it. And especially not with setting the correct size of the video dependent on different screen sizes or looping the video.

If anyone got an idea/link/knows how Spotify does it, i'd love to get some inputs

- Moon

For the loop part you could try alarm manager. Now I know this is not the ideal solution for your case, but it works well if you want to loop a function
PHP Code:
 PendingIntent pi;
    
BroadcastReceiver br;
    
AlarmManager am;




private 
void replay() {
        
br = new BroadcastReceiver() {

               @
Override

               
public void onReceive(Context cIntent i) {

                   
//The method which runs video

                      
}

               };

        
registerReceiver(br, new IntentFilter("com.your.packagename") );

        
pi PendingIntent.getBroadcastthis0, new Intent("com.your.packagename"),);

        
int video_length =exact length of your video in seconds;
       
        
am = (AlarmManager)(this.getSystemServiceContext.ALARM_SERVICE ));
        

            
am.setRepeating(AlarmManager.RTCSystem.currentTimeMillis(), 1000 video_lengthpi);
        
  } 
call this replay method at the place where you are calling the method to play the video.
Worth a try, might work
29th March 2014, 09:33 PM   |  #3  
Junior Member
Thanks Meter: 5
 
15 posts
Join Date:Joined: Mar 2014
Quote:
Originally Posted by Moonbloom

Hello

I'm currently making an app and i want to spruce up the login screen with a video like Spotify currently has.
It plays a small video in the background, behind the login buttons/logo etc and simply loops the video over and over again.

I've tried to mess around with a VideoView and a MediaPlayer to control it, but i can't seem to get a proper grip on it. And especially not with setting the correct size of the video dependent on different screen sizes or looping the video.

If anyone got an idea/link/knows how Spotify does it, i'd love to get some inputs

- Moon

Did you tried to use MediaPlayer.OnCompletionListener to restart a video? To be honest I'm not sure, that this way will provide smooth restart.
I can't download Spotify, because it's not available in my country, but maybe Spotify uses something like looped AnimationDrawable?
AnimationDrawable works great with short animations.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes