//
//  PlayerViewController.h
//  Allzic
//
//  Created by Alia Bourouis on 24/03/14.
//  Copyright (c) 2014 Alia Bourouis. All rights reserved.
//

#import "UniversalViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreGraphics/CoreGraphics.h>

@interface PlayerViewController : UniversalViewController <UIScrollViewDelegate, UIWebViewDelegate> {
    
    MPMoviePlayerController *player;
    NSDictionary *currentRadio;
    UIView *radioHeaderView;
    
    
    
    UILabel *headerReadMoreLabel;
    UIButton *headerReadMoreButton;
    UIButton *hideDescriptionButton;
    
    UIView *defaultRadioImage;
    UIImageView *radioImage;
    UILabel *radioTitle;
    
    
    UIScrollView *descriptionScrollview;
    UILabel *radioDescription;
    UIButton *displayHideDescriptionButton;
    
    
    UIView *playerControlView;
    UIImageView *playStopImage;
    
    
    UIView *loadingView;
    
    
    UIButton *playStopButton;
    UIImageView *coverImage;
    UIView *tempCoverLeft;
    UIView *tempCoverRight;
    UIImageView *previousIndicator;
    UIImageView *nextIndicator;
    UIImageView *songInfoBackground;
    UILabel *songSinger;
    UILabel *songTitle;
    UIImageView *likeRadioImage;
    UIButton *likeRadioButton;
    UIScrollView *scrollview;
    IconDownloader *radioLogoDownloader;
    IconDownloader *radioCoverDownloader;
    NSDictionary *playlistData;
    NSTimer *playlistTimer;
    NSString *radioUrlToPlay;
    UIView *adView;
    UIWebView *adBannerWebview;
    UIButton *adBannerButton;
    UIView *adBar;
    UILabel *adLabel;
    UIButton *adButton;
    int adBannerAdjustedHeight;
    UIWebView *adInterstitialWebview;
    UIButton *adInterstitialButton;
    BOOL isAdOpen;
    BOOL isAdLoaded;
    NSTimer *adDisplayTimer;
    NSTimer *adTrackingTimer;
    int adTrackingIndex;
    BOOL isAudioAdToPlay;
    BOOL isDisplayAdToPlay;
    BOOL isNewsRadio;
    BOOL isAacError;
    BOOL isMp3Error;
    
    NSTimer *radioLoadingTimeout;
}

@property(nonatomic,strong) MPMoviePlayerController *player;
@property(nonatomic,strong) UIScrollView *scrollview;
@property(nonatomic) BOOL isAudioAdToPlay;
@property(nonatomic) BOOL isDisplayAdToPlay;

- (void)displayRadioDescription;
- (void)hideRadioDescription;
- (void)selectRadio:(NSDictionary *)radio;
- (void)refreshPlaylistWithData:(NSArray *)data;
- (void)startRadio;
- (void)playAudioAd;
- (void)playRadio;
- (void)stopRadio;
- (void)checkPlayerState;
- (void)moviePlayBackStateDidChange:(NSNotification*)notification;
- (void)moviePlayBackDidFinish:(NSNotification*)notification;
- (void)handleNotification:(NSNotification *)notification;
- (void)loadImageWithType:(int)imageType;
- (void)likeRadioButtonPressed;
- (void)unlikeRadioButtonPressed;
- (void)refreshRadioWithFavorite:(BOOL)isFavorite;
- (void)facebookButtonPressed;
- (void)twitterButtonPressed;
- (void)initAdBanner;
- (void)loadAdBanner;
- (void)displayAdBanner;
- (void)hideAdBanner;
- (void)initAdInterstitial;
- (void)loadAdInterstitial;
- (void)displayAdInterstitial;
- (void)hideAdInterstitial;
- (void)adButtonPressed:(UIButton *)button;
- (void)sendAudioAdTracking;

@end
