Android: Can't use own video player implementation to play content

85 views
Skip to first unread message

Michael Hughes

unread,
Jun 17, 2014, 1:56:28 PM6/17/14
to ima...@googlegroups.com
Hey IMA Team,

I have an existing solution which leverages another video player which isn't based off of Google's MediaPlayer interface (lets call it XPlayer). We want to keep using XPlayer for playing content because we have a tried and true tested solution. We want to move the IMA SDK to deliver ads. We will be using whatever video player Google uses to play ads. This is leading us to implement a dual player solution.

I was hoping to create a player exactly like the sample since it is using DFP ad rules and fires events when to pause and play the content. My approach was to setup the DemoPlayer (from your sample) to return the proper progress when the content is playing, and the proper progress when an ad is playing. I call play on the XPlayer when I get the right event and pause on the XPlayer when I get the proper event.

I have run into an issue however, if Google's MediaPlayer isn't playing content then the getProgress() method is never called on the DemoPlayer (from your sample) and the ad events are never fired after the preroll. This means I don't get the IMA SDK triggering midrolls and the endroll. It seems like the IMA SDK automagically knows if the VideoView's MediaPlayer is playing content. It only polls the DemoPlayer's getProgress function IF content is playing through the MediaPlayer in the VideoView.

If I debug I see that the getProgress method is called from a handler so there is no way to easily figure out where that call is coming from. If I play dummy content on Google's video player then, since I am returning the correct time from the XPlayer in getProgress (and because the IMA SDK just seems to know when content is playing and then starts polling the DemoPlayer for time), everything just works.

TLDR; Is there a way I can explicitly tell the IMA SDK that content is playing so it polls the DemoPlayer instead of having it automagically figure this out from the VideoView's MediaPlayer. Is there another way to implement a dual player solution?


Some code:

DemoPlayer.java
    public void resumeContent() {
        contentPlaying = true;
        video.setMediaController(mediaController);
        //video.setVideoPath(CONTENT_URL); REMOVED because I use my own video player
        xPlayer.play();
        play();
    }

    public void play() {
        video.start();
    }

    public void pauseContent() {
        xPlayer.pause();
        video.stopPlayback();
        video.setMediaController(null);
    }

    public void playContent(String contentUrl) {
        contentPlaying = true;
        xPlayer.play();
        //video.setVideoPath(CONTENT_URL); REMOVED since I want my own content to play
        video.setMediaController(mediaController);
        play();
    }


1) Which SDK are you using? (Flash, HTML5, iOS, Android)
 - Android, Beta v8
2) What ad tag are you using in your request?
- The ones from the sample application
3) Are you able to reproduce this in the downloadable sample app or the ? If not, please include a link to a test page or app so we can see the issue.
- N/A
4) What steps must we take to reproduce your issue?
- Put a timer or something that updates the getProgress() method that simulates content playing from outside the IMA SDK. Comment out the video.setVideoPath() lines to make sure the default video player isn't playing any content...

Shawn Busolits (IMA SDK Team)

unread,
Jun 18, 2014, 10:50:31 AM6/18/14
to ima...@googlegroups.com
Hey Michael,

I'm taking a look at our SDK code to see what should be triggering that progress poller. It looks like it should eventually be kicked off as a result of your app calling an onPlay() method of a callback sent to you by the SDK (see this section of the TrackingVideoView in our sample app). Can you confirm that you have this set up as in the sample? If you do and you're still seeing the issue let me know and I can look into it further.

Thanks,
Shawn Busolits
IMA SDK Team

Michael Hughes

unread,
Jun 18, 2014, 11:04:32 AM6/18/14
to ima...@googlegroups.com
Hey Shawn,

I actually just solved the problem. The issue was that I was calling onStart on the TrackingVideoView when content was starting to play. This would call super.onStart on the VideoView. This would cause the onError condition to be hit because the video path was not set which caused an onStop call to occur. What I needed to do was just add a playContent method to the TrackingVideoView which set the state and updated the listeners without calling start on the super. As a side note it would be great if it were possible to toggle logging on the IMA SDK to see logs for when things like this occur, in the meantime I'll add logging in my listeners.

Thanks for your quick response, everything is working on my end :).

Cheers,
Michael


--
You received this message because you are subscribed to a topic in the Google Groups "Interactive Media Ads SDK" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ima-sdk/HgR3WvpBYgU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ima-sdk+u...@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at http://groups.google.com/group/ima-sdk.
For more options, visit https://groups.google.com/d/optout.

Shawn Busolits (IMA SDK Team)

unread,
Jun 18, 2014, 11:06:28 AM6/18/14
to ima...@googlegroups.com
Hey Mike,

Glad you got it working! I'll definitely pass along the info about adding a logging toggle to the SDK.

Shawn Busolits
IMA SDK Team


On Wednesday, June 18, 2014 11:04:32 AM UTC-4, Michael Hughes wrote:
Hey Shawn,

I actually just solved the problem. The issue was that I was calling onStart on the TrackingVideoView when content was starting to play. This would call super.onStart on the VideoView. This would cause the onError condition to be hit because the video path was not set which caused an onStop call to occur. What I needed to do was just add a playContent method to the TrackingVideoView which set the state and updated the listeners without calling start on the super. As a side note it would be great if it were possible to toggle logging on the IMA SDK to see logs for when things like this occur, in the meantime I'll add logging in my listeners.

Thanks for your quick response, everything is working on my end :).

Cheers,
Michael
To unsubscribe from this group and all its topics, send an email to ima-sdk+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages