# -*- coding: utf-8 -*-
from Plugins.Extensions.WebInterface.WebScreens import WebScreen
from Plugins.Extensions.WebInterface.WebComponents.Sources.Volume import Volume
from Components.Sources.StaticText import StaticText
from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE

class NetcastWebScreen(WebScreen):
	def __init__(self, session, request):
		WebScreen.__init__(self, session, request)
		from enigma import eServiceReference, iServiceInformation
		from Plugins.Bp.geminimain.gLocale import _
		from Plugins.Bp.geminimain.plugin import cgevent
		from Plugins.Bp.geminimain.gTools import pathExists
		from Plugins.Bp.gemininetcastwebif.WebComponents.Sources.Netcast import Netcast
		DEFAULT_MVI = resolveFilename(SCOPE_SKIN_IMAGE, "radio.mvi")
		
		self["NetcastList"] = Netcast(session, func=Netcast.LIST)
		self["PlayNetcast"] = Netcast(session, func=Netcast.PLAY)
		self["AddNetcast"] = Netcast(session, func=Netcast.ADD)
		self["EditNetcast"] = Netcast(session, func=Netcast.EDIT)
		self["DelNetcast"] = Netcast(session, func=Netcast.DEL)
		self["SaveNetcastSettings"] = Netcast(session, func=Netcast.SET)
		self["SortNetcast"] = Netcast(session, func=Netcast.SORT)
		self["NetcastListWap"] = Netcast(session, func=Netcast.LIST, wap=True)
		
		self["Bitrate"] = StaticText(str(cgevent.getConfig("Netcast_bitrate", 0)))
		self["OnlyMpeg"] = StaticText(str(cgevent.getConfig("Netcast_OnlyMpeg", 1)))
		self["SortBy"] = StaticText(str(cgevent.getConfig("Netcast_SortBy", 0)))
		self["Background"] = StaticText(cgevent.getConfig("Netcast_backgroundmvi", DEFAULT_MVI))
		self["OnlyMpeg_txt"] = StaticText(_("only MPEG-Streams"))
		self["Bitrate_txt"] = StaticText(_("Minimum Bitrate"))
		self["Background_txt"] = StaticText(_("background") + " (MVI)")
		self["Btn_save"] = StaticText(_("Save"))
			
		self["Menu_index"] = StaticText(_("Index"))
		self["Menu_name"] = StaticText(_("Name"))
		self["Menu_bitrate"] = StaticText(_("Bitrate"))
		self["Menu_genre"] = StaticText(_("Genre"))
		self["Menu_addfavo"] = StaticText(_("Add to favourites"))
		self["Menu_delfavo"] = StaticText(_("Delete Favourites"))
		self["Menu_info"] = StaticText(_("Info"))
		self["Menu_menu"] = StaticText(_("Menu"))
		self["Menu_toplist"] = StaticText(_("Top List"))
		self["Menu_genrelist"] = StaticText(_("Genre List"))
		self["Menu_favo"] = StaticText(_("Favourites"))
		self["Menu_search"] = StaticText(_("Search"))
		self["Menu_setup"] = StaticText(_("Setup"))
		self["Menu_Stations"] = StaticText(_("Stations"))
		self["Menu_Sort"] = StaticText(_("Sort by"))
		
		self["Info_title_txt"] = StaticText(_("Title"))
		currPlay = self.session.nav.getCurrentService()
		if currPlay is not None:
			self["Info_title"] = StaticText(currPlay.info().getInfoString(iServiceInformation.sTagTitle))
			self["Info_codec"] = StaticText(currPlay.info().getInfoString(iServiceInformation.sTagAudioCodec))
			self["Info_location"] = StaticText(currPlay.info().getInfoString(iServiceInformation.sTagLocation))
			self["Info_organisation"] = StaticText(currPlay.info().getInfoString(iServiceInformation.sTagOrganization))
		else:
			self["Info_title"] = StaticText("N/A")
			self["Info_codec"] = StaticText("N/A")
			self["Info_location"] = StaticText("N/A")
			self["Info_organisation"] = StaticText("N/A")

		self["Volume"] = Volume(session)
		
class NetcastExternalWebScreen(WebScreen):
	def __init__(self, session, request):
		WebScreen.__init__(self, session, request)

		from Plugins.Bp.gemininetcastwebif.WebComponents.Sources.External import External
		self["External"] = External()

