Skip to content

Commit

Permalink
#30 Play audio
Browse files Browse the repository at this point in the history
  • Loading branch information
dallaszkorben committed Dec 22, 2018
1 parent 00191c1 commit 6506beb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 33 deletions.
28 changes: 21 additions & 7 deletions akoteka/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import configparser
import cgi, cgitb

pattern_media = re.compile("^.+[.](avi|mpg|mkv|mp4|flv|mp3)$")
pattern_image = re.compile( "^image[.]jp(eg|g)$" )
pattern_card = re.compile("^card.ini$")
from akoteka.handle_property import media_player_video_ext
from akoteka.handle_property import media_player_audio_ext

filter_key = {
"best":{
Expand Down Expand Up @@ -56,6 +55,21 @@
}
}


def get_pattern_video():
ptrn = '|'.join( media_player_video_ext.split(",") )
return re.compile( '^.+[.](' + ptrn + ')$' )

def get_pattern_audio():
ptrn = '|'.join( media_player_audio_ext.split(",") )
return re.compile( '^.+[.](' + ptrn + ')$' )

def get_pattern_image():
return re.compile( '^image[.]jp(eg|g)$' )

def get_pattern_card():
return re.compile('^card.ini$')

def folder_investigation( actual_dir, json_list):

# Collect files and and dirs in the current directory
Expand All @@ -78,16 +92,16 @@ def folder_investigation( actual_dir, json_list):
#

# find the Card
if pattern_card.match( file_name ):
if get_pattern_card().match( file_name ):
card_path_os = os.path.join(actual_dir, file_name)

# find the Media
if pattern_media.match(file_name):
# find the Media (video or audio)
if get_pattern_audio().match(file_name) or get_pattern_video().match(file_name):
media_path_os = os.path.join(actual_dir, file_name)
media_name = file_name

# find the Image
if pattern_image.match( file_name ):
if get_pattern_image().match( file_name ):
image_path_os = os.path.join(actual_dir, file_name)


Expand Down
48 changes: 22 additions & 26 deletions akoteka/gui/card_holder_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from PyQt5.QtCore import pyqtSignal

from akoteka.accessories import filter_key
from akoteka.accessories import get_pattern_video
from akoteka.accessories import get_pattern_audio


from akoteka.handle_property import _
from akoteka.handle_property import dic
Expand Down Expand Up @@ -441,25 +444,7 @@ def __init__(self, card_holder):
card_layout.addWidget( self.card_rating )

self.borderRadius = 5

# def mousePressEvent(self, event):
#
# # Play media
# if self.get_media_path():
#
# switch_list = media_player_video_param.split(" ")
# param_list = []
# param_list.append(media_player_video)
# param_list += switch_list
# param_list.append(self.get_media_path())
#
# thread = Thread(target = call, args = (param_list, ))
# thread.start()
# #call( param_list )
#
# else:
# self.card_holder.go_deeper(self.get_sub_cards(), self.card_information.get_title() )


def get_card_holder( self ):
return self.card_holder

Expand Down Expand Up @@ -753,18 +738,29 @@ def get_sub_cards( self ):

def mousePressEvent(self, event):

# Play media
if self.get_media_path():
media_path = self.get_media_path()

switch_list = media_player_video_param.split(" ")
# Play media
if media_path:

param_list = []
param_list.append(media_player_video)
param_list += switch_list
param_list.append(self.get_media_path())

# audio
if get_pattern_audio().match(media_path):
switch_list = media_player_audio_param.split(" ")
param_list.append(media_player_audio)
#param_list += switch_list
param_list.append(media_path)

# video
elif get_pattern_video().match(media_path):
switch_list = media_player_video_param.split(" ")
param_list.append(media_player_video)
param_list += switch_list
param_list.append(media_path)

thread = Thread(target = call, args = (param_list, ))
thread.start()
#call( param_list )

else:
self.card.get_card_holder().go_deeper(self.get_sub_cards(), self.card.get_title() )
Expand Down

0 comments on commit 6506beb

Please sign in to comment.